mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
6 lines
3.0 KiB
JavaScript
6 lines
3.0 KiB
JavaScript
/*!
|
|
* Bowser - a browser detector
|
|
* https://github.com/ded/bowser
|
|
* MIT License | (c) Dustin Diaz 2014
|
|
*/
|
|
!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/firefox/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/windows phone/i.test(r),w=/blackberry/i.test(r),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x={};f&&(u=!1);if(b)x={name:"Windows Phone",windowsphone:e,msie:e,mobile:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,E,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),x={name:"Opera",opera:e,version:t},h&&(x.android=e,x.mobile=e),s&&(x.webkit=e);else if(i)x={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){x={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios)\/(\d+(\.\d+)?)/i,1)},h&&(x.android=e);if(a||f||u)x[u?"iphone":a?"ipad":"ipod"]=e,x.ios=e;if(x.android||x.ios)x.mobile=e}else o?x={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?x={name:"Amazon Silk",silk:e,webkit:e,android:e,mobile:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(x={name:u?"iPhone":a?"iPad":"iPod",webkit:e,mobile:e,ios:e},x[u?"iphone":a?"ipad":"ipod"]=e,E.test(r)&&(x.version=n(r,E,1))):w?(x={name:"BlackBerry",blackberry:e,mobile:e},(t=n(r,E,1))?(x.version=t,x.webkit=e):x.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(x={name:"WebOS",mobile:e,webkit:e,webos:e,version:n(r,E,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},/touchpad\//i.test(r)&&(x.touchpad=e)):m?(x={name:"Gecko",gecko:e,mozilla:e,version:n(r,S,1)},g?(x.name="SeaMonkey",x.seamonkey=e,x.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(x.name="Firefox",x.firefox=e),h?(x.android=e,x.mobile=e):!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(x.firefoxos=e,x.mobile=e)):h?x={name:"Android",webkit:e,android:e,mobile:e,version:n(r,E,1)}:c&&(x={name:"Safari",webkit:e,safari:e,version:n(r,E,1)});var T;return h?(T=n(r,/android[ \/](\d+(\.\d+)*)/i,1),T&&(x.osversion=T)):u||a||f?(T=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),T=(T||"").replace(/[_\s]/g,".")):b?T=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y&&(T=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1)),T&&(x.osversion=T),x.msie&&x.version>=9||x.chrome&&x.version>=20||x.firefox&&x.version>=10||x.safari&&x.version>=5||x.opera&&x.version>=10||x.ios&&x.osversion&&x.osversion.split(".")[0]>=6?x.a=e:x.msie&&x.version<9||x.chrome&&x.version<20||x.firefox&&x.version<10||x.safari&&x.version<5||x.opera&&x.version<10||x.ios&&x.osversion&&x.osversion.split(".")[0]<6?x.c=e:x.x=e,x}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) |