1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Merge pull request #41 from BendingBender/make-testable-and-add-tests

Expanded detection and tests
This commit is contained in:
Dustin Diaz 2014-02-21 16:56:21 -08:00
commit 2f3c3e7e3d
5 changed files with 516 additions and 150 deletions

View File

@ -10,18 +10,35 @@ if (bowser.msie && bowser.version <= 6) {
}
```
Detected Browsers
Detected Browsers[Engines]
-----
* msie
* safari[webkit]
* chrome[webkit]
* firefox[gecko]
* opera
* msie
* opera[webkit if >12]
* phantomjs[webkit]
* safari[webkit]
* seamonkey[gecko]
* touchpad[webkit]
Detected mobile operating systems
-----
* android
* windows phone
* ios (iphone/ipad/ipod)
* blackberry
* firefoxos
* webos
Android, iOS and Windows Phone will all report the OS version number if it is contained in the UA string in the `osversion` field. iOS is always reported as `ios` and additionally as `iphone`/`ipad`/`ipod`, whichever one matches best. Windows Phone is reported as `windowsphone`.
All detected mobile OSes are additionally flagged `mobile`.
Notes
----
Safari, Chrome, and Firefox will report that they have webkit|gecko engines
Safari, Chrome and some other minor browsers will report that they have `webkit` engines, Firefox and Seamonkey will report that they have `gecko` engines.
``` js
if (bowser.webkit) {

156
bowser.js
View File

@ -9,13 +9,18 @@
else if (typeof define == 'function') define(definition)
else this[name] = definition()
}('bowser', function () {
/**
/**
* See useragents.js for examples of navigator.userAgent
*/
var t = true,
v /* temporary placeholder for versions. */
function getVersion(ua, regex, matchedIdx) {
var match = ua.match(regex);
return (match && match.length > matchedIdx && match[matchedIdx]) || 0;
}
function detect(ua) {
var ie = /(msie|trident)/i.test(ua)
@ -32,69 +37,131 @@
, firefox = /firefox/i.test(ua)
, gecko = /gecko\//i.test(ua)
, seamonkey = /seamonkey\//i.test(ua)
, webos = /webos/i.test(ua)
, windowsphone = /windows phone/i.test(ua)
, blackberry = /blackberry/i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i
// , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
, mobile = /mobile/i.test(ua)
, o = {}
if (opera) {
if ((v = ua.match(webkitVersion)) && v.length > 1) v = v[1]
else if ((v = ua.match(/opr\/(\d+(\.\d+)?)/i)) && v.length > 1) v = v[1]
else if ((v = ua.match(/opera[ \/](\d+(\.\d+)?)/i)) && v.length > 1) v = v[1]
else v = 0
if (ipod) iphone = false
if (windowsphone) o = {
name: 'Windows Phone'
, windowsphone: t
, msie: t
, mobile: t
, version: getVersion(ua, /iemobile\/(\d+(\.\d+)?)/i, 1)
}
else if (opera) {
v = getVersion(ua, webkitVersion, 1) ||
getVersion(ua, /opr\/(\d+(\.\d+)?)/i, 1) ||
getVersion(ua, /opera[ \/](\d+(\.\d+)?)/i, 1);
o = {
name: 'Opera'
, opera: t
, version: v
}
} else if (ie) o = {
if (android) {
o.android = t
o.mobile = t
}
if (chrome) {
o.webkit = t
}
}
else if (ie) o = {
name: 'Internet Explorer'
, msie: t
, version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]
, version: getVersion(ua, /(msie |rv:)(\d+(\.\d+)?)/i, 2)
}
else if (chrome) o = {
else if (chrome) {
o = {
name: 'Chrome'
, webkit: t
, chrome: t
, version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]
, ipad: ipad
, iphone: iphone
, ios: !!ua.match(/crios/i)
, mobile: mobile
, version: getVersion(ua, /(?:chrome|crios)\/(\d+(\.\d+)?)/i, 1)
}
if (android) o.android = t
if (ipad || ipod || iphone) {
o[iphone ? 'iphone' : ipad ? 'ipad' : 'ipod'] = t
o.ios = t
}
if (o.android || o.ios) o.mobile = t
}
else if (phantom) o = {
name: 'PhantomJS'
, webkit: t
, phantom: t
, version: ua.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]
, version: getVersion(ua, /phantomjs\/(\d+(\.\d+)?)/i, 1)
}
else if (touchpad) o = {
name: 'TouchPad'
, webkit: t
, touchpad: t
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
, version : getVersion(ua, /touchpad\/(\d+(\.\d+)?)/i, 1)
}
else if (silk) o = {
name: 'Amazon Silk'
, webkit: t
, android: t
, mobile: t
, version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1]
, version : getVersion(ua, /silk\/(\d+(\.\d+)?)/i, 1)
}
else if (iphone || ipad || ipod) {
o = {
name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod'
, webkit: t
, mobile: iphone
, mobile: t
, ios: t
, iphone: iphone
, ipad: ipad
, ipod: ipod
}
o[iphone ? 'iphone' : ipad ? 'ipad' : 'ipod'] = t
// WTF: version is not part of user agent in web apps
if (webkitVersion.test(ua)) {
o.version = ua.match(webkitVersion)[1]
o.version = getVersion(ua, webkitVersion, 1)
}
}
else if (blackberry) {
o = {
name: 'BlackBerry'
, blackberry: t
, mobile: t
}
if ((v = getVersion(ua, webkitVersion, 1))) {
o.version = v
o.webkit = t
} else {
o.version = getVersion(ua, /blackberry[\d]+\/(\d+(\.\d+)?)/i, 1)
}
}
else if (webos) o = {
name: 'WebOS'
, mobile: t
, webkit: t
, webos: t
, version: (getVersion(ua, webkitVersion, 1) || getVersion(ua, /wosbrowser\/(\d+(\.\d+)?)/i, 1))
}
else if (gecko) {
o = {
name: 'Gecko'
, gecko: t
, mozilla: t
, version: getVersion(ua, firefoxVersion, 1)
}
if (seamonkey) {
o.name = 'SeaMonkey'
o.seamonkey = t
o.version = getVersion(ua, /seamonkey\/(\d+(\.\d+)?)/i, 1)
} else if (firefox) {
o.name = 'Firefox'
o.firefox = t
}
if (android) {
o.android = t
o.mobile = t
} else if (!android && firefox && /\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
o.firefoxos = t
o.mobile = t
}
}
else if (android) o = {
@ -102,31 +169,32 @@
, webkit: t
, android: t
, mobile: t
, version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1]
, version: getVersion(ua, webkitVersion, 1)
}
else if (safari) o = {
name: 'Safari'
, webkit: t
, safari: t
, version: ((v = ua.match(webkitVersion)) ? v[1] : 0)
, version: getVersion(ua, webkitVersion, 1)
}
else if (gecko) {
o = {
name: 'Gecko'
, gecko: t
, mozilla: t
, version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0)
var osVersion;
if (android) {
osVersion = getVersion(ua, /android[ \/](\d+(\.\d+)*)/i, 1);
if (osVersion) {
o.osversion = osVersion;
}
if (firefox) {
o.name = 'Firefox';
o.firefox = t;
} else if (iphone || ipad || ipod) {
osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1);
if (osVersion) {
o.osversion = osVersion.replace(/[_\s]/g, '.');
}
} else if (windowsphone) {
osVersion = getVersion(ua, /windows phone (?:os)?\s?(\d+(\.\d+)*)/i, 1);
if (osVersion) {
o.osversion = osVersion;
}
}
else if (seamonkey) o = {
name: 'SeaMonkey'
, seamonkey: t
, version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]
}
// Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs
@ -134,7 +202,9 @@
(o.chrome && o.version >= 20) ||
(o.firefox && o.version >= 10.0) ||
(o.safari && o.version >= 5) ||
(o.opera && o.version >= 10.0)) {
(o.opera && o.version >= 10.0) ||
(o.ios && o.osversion && o.osversion.split(".")[0] >= 6)
) {
o.a = t;
}
@ -142,7 +212,9 @@
(o.chrome && o.version < 20) ||
(o.firefox && o.version < 10.0) ||
(o.safari && o.version < 5) ||
(o.opera && o.version < 10.0)) {
(o.opera && o.version < 10.0) ||
(o.ios && o.osversion && o.osversion.split(".")[0] < 6)
) {
o.c = t
} else o.x = t

2
bowser.min.js vendored
View File

@ -3,4 +3,4 @@
* 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(n){var r=/(msie|trident)/i.test(n),i=/chrome|crios/i.test(n),s=/phantom/i.test(n),o=/iphone/i.test(n),u=/ipad/i.test(n),a=/ipod/i.test(n),f=/touchpad/i.test(n),l=/silk/i.test(n),c=/safari/i.test(n)&&!i&&!s&&!l,h=/android/i.test(n),p=/opera/i.test(n)||/opr/i.test(n),d=/firefox/i.test(n),m=/gecko\//i.test(n),g=/seamonkey\//i.test(n),y=/version\/(\d+(\.\d+)?)/i,b=/firefox[ \/](\d+(\.\d+)?)/i,w=/mobile/i.test(n),E={};return p?((t=n.match(y))&&t.length>1?t=t[1]:(t=n.match(/opr\/(\d+(\.\d+)?)/i))&&t.length>1?t=t[1]:(t=n.match(/opera[ \/](\d+(\.\d+)?)/i))&&t.length>1?t=t[1]:t=0,E={name:"Opera",opera:e,version:t}):r?E={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?E={name:"Chrome",webkit:e,chrome:e,version:n.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:u,iphone:o,ios:!!n.match(/crios/i),mobile:w}:s?E={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?E={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?E={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(E={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:o,ios:e,iphone:o,ipad:u,ipod:a},y.test(n)&&(E.version=n.match(y)[1])):h?E={name:"Android",webkit:e,android:e,mobile:e,version:(n.match(y)||n.match(b))[1]}:c?E={name:"Safari",webkit:e,safari:e,version:(t=n.match(y))?t[1]:0}:m?(E={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(b))&&t?t[1]:0},d&&(E.name="Firefox",E.firefox=e)):g&&(E={name:"SeaMonkey",seamonkey:e,version:n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}),E.msie&&E.version>=9||E.chrome&&E.version>=20||E.firefox&&E.version>=10||E.safari&&E.version>=5||E.opera&&E.version>=10?E.a=e:E.msie&&E.version<9||E.chrome&&E.version<20||E.firefox&&E.version<10||E.safari&&E.version<5||E.opera&&E.version<10?E.c=e:E.x=e,E}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r})
!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=/touchpad/i.test(r),c=/silk/i.test(r),h=/safari/i.test(r)&&!s&&!o&&!c,p=/android/i.test(r),d=/opera/i.test(r)||/opr/i.test(r),m=/firefox/i.test(r),g=/gecko\//i.test(r),y=/seamonkey\//i.test(r),b=/webos/i.test(r),w=/windows phone/i.test(r),E=/blackberry/i.test(r),S=/version\/(\d+(\.\d+)?)/i,x=/firefox[ \/](\d+(\.\d+)?)/i,T={};f&&(u=!1);if(w)T={name:"Windows Phone",windowsphone:e,msie:e,mobile:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(d)t=n(r,S,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),T={name:"Opera",opera:e,version:t},p&&(T.android=e,T.mobile=e),s&&(T.webkit=e);else if(i)T={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){T={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios)\/(\d+(\.\d+)?)/i,1)},p&&(T.android=e);if(a||f||u)T[u?"iphone":a?"ipad":"ipod"]=e,T.ios=e;if(T.android||T.ios)T.mobile=e}else o?T={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?T={name:"TouchPad",webkit:e,touchpad:e,version:n(r,/touchpad\/(\d+(\.\d+)?)/i,1)}:c?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(T={name:u?"iPhone":a?"iPad":"iPod",webkit:e,mobile:e,ios:e},T[u?"iphone":a?"ipad":"ipod"]=e,S.test(r)&&(T.version=n(r,S,1))):E?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n(r,S,1))?(T.version=t,T.webkit=e):T.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):b?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:n(r,S,1)||n(r,/wosbrowser\/(\d+(\.\d+)?)/i,1)}:g?(T={name:"Gecko",gecko:e,mozilla:e,version:n(r,x,1)},y?(T.name="SeaMonkey",T.seamonkey=e,T.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):m&&(T.name="Firefox",T.firefox=e),p?(T.android=e,T.mobile=e):!p&&m&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(T.firefoxos=e,T.mobile=e)):p?T={name:"Android",webkit:e,android:e,mobile:e,version:n(r,S,1)}:h&&(T={name:"Safari",webkit:e,safari:e,version:n(r,S,1)});var N;return p?(N=n(r,/android[ \/](\d+(\.\d+)*)/i,1),N&&(T.osversion=N)):u||a||f?(N=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),N&&(T.osversion=N.replace(/[_\s]/g,"."))):w&&(N=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1),N&&(T.osversion=N)),T.msie&&T.version>=9||T.chrome&&T.version>=20||T.firefox&&T.version>=10||T.safari&&T.version>=5||T.opera&&T.version>=10||T.ios&&T.osversion&&T.osversion.split(".")[0]>=6?T.a=e:T.msie&&T.version<9||T.chrome&&T.version<20||T.firefox&&T.version<10||T.safari&&T.version<5||T.opera&&T.version<10||T.ios&&T.osversion&&T.osversion.split(".")[0]<6?T.c=e:T.x=e,T}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i})

View File

@ -3,13 +3,18 @@
else if (typeof define == 'function') define(definition)
else this[name] = definition()
}('bowser', function () {
/**
/**
* See useragents.js for examples of navigator.userAgent
*/
var t = true,
v /* temporary placeholder for versions. */
function getVersion(ua, regex, matchedIdx) {
var match = ua.match(regex);
return (match && match.length > matchedIdx && match[matchedIdx]) || 0;
}
function detect(ua) {
var ie = /(msie|trident)/i.test(ua)
@ -26,69 +31,131 @@
, firefox = /firefox/i.test(ua)
, gecko = /gecko\//i.test(ua)
, seamonkey = /seamonkey\//i.test(ua)
, webos = /webos/i.test(ua)
, windowsphone = /windows phone/i.test(ua)
, blackberry = /blackberry/i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i
// , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
, mobile = /mobile/i.test(ua)
, o = {}
if (opera) {
if ((v = ua.match(webkitVersion)) && v.length > 1) v = v[1]
else if ((v = ua.match(/opr\/(\d+(\.\d+)?)/i)) && v.length > 1) v = v[1]
else if ((v = ua.match(/opera[ \/](\d+(\.\d+)?)/i)) && v.length > 1) v = v[1]
else v = 0
if (ipod) iphone = false
if (windowsphone) o = {
name: 'Windows Phone'
, windowsphone: t
, msie: t
, mobile: t
, version: getVersion(ua, /iemobile\/(\d+(\.\d+)?)/i, 1)
}
else if (opera) {
v = getVersion(ua, webkitVersion, 1) ||
getVersion(ua, /opr\/(\d+(\.\d+)?)/i, 1) ||
getVersion(ua, /opera[ \/](\d+(\.\d+)?)/i, 1);
o = {
name: 'Opera'
, opera: t
, version: v
}
} else if (ie) o = {
if (android) {
o.android = t
o.mobile = t
}
if (chrome) {
o.webkit = t
}
}
else if (ie) o = {
name: 'Internet Explorer'
, msie: t
, version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]
, version: getVersion(ua, /(msie |rv:)(\d+(\.\d+)?)/i, 2)
}
else if (chrome) o = {
else if (chrome) {
o = {
name: 'Chrome'
, webkit: t
, chrome: t
, version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]
, ipad: ipad
, iphone: iphone
, ios: !!ua.match(/crios/i)
, mobile: mobile
, version: getVersion(ua, /(?:chrome|crios)\/(\d+(\.\d+)?)/i, 1)
}
if (android) o.android = t
if (ipad || ipod || iphone) {
o[iphone ? 'iphone' : ipad ? 'ipad' : 'ipod'] = t
o.ios = t
}
if (o.android || o.ios) o.mobile = t
}
else if (phantom) o = {
name: 'PhantomJS'
, webkit: t
, phantom: t
, version: ua.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]
, version: getVersion(ua, /phantomjs\/(\d+(\.\d+)?)/i, 1)
}
else if (touchpad) o = {
name: 'TouchPad'
, webkit: t
, touchpad: t
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
, version : getVersion(ua, /touchpad\/(\d+(\.\d+)?)/i, 1)
}
else if (silk) o = {
name: 'Amazon Silk'
, webkit: t
, android: t
, mobile: t
, version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1]
, version : getVersion(ua, /silk\/(\d+(\.\d+)?)/i, 1)
}
else if (iphone || ipad || ipod) {
o = {
name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod'
, webkit: t
, mobile: iphone
, mobile: t
, ios: t
, iphone: iphone
, ipad: ipad
, ipod: ipod
}
o[iphone ? 'iphone' : ipad ? 'ipad' : 'ipod'] = t
// WTF: version is not part of user agent in web apps
if (webkitVersion.test(ua)) {
o.version = ua.match(webkitVersion)[1]
o.version = getVersion(ua, webkitVersion, 1)
}
}
else if (blackberry) {
o = {
name: 'BlackBerry'
, blackberry: t
, mobile: t
}
if ((v = getVersion(ua, webkitVersion, 1))) {
o.version = v
o.webkit = t
} else {
o.version = getVersion(ua, /blackberry[\d]+\/(\d+(\.\d+)?)/i, 1)
}
}
else if (webos) o = {
name: 'WebOS'
, mobile: t
, webkit: t
, webos: t
, version: (getVersion(ua, webkitVersion, 1) || getVersion(ua, /wosbrowser\/(\d+(\.\d+)?)/i, 1))
}
else if (gecko) {
o = {
name: 'Gecko'
, gecko: t
, mozilla: t
, version: getVersion(ua, firefoxVersion, 1)
}
if (seamonkey) {
o.name = 'SeaMonkey'
o.seamonkey = t
o.version = getVersion(ua, /seamonkey\/(\d+(\.\d+)?)/i, 1)
} else if (firefox) {
o.name = 'Firefox'
o.firefox = t
}
if (android) {
o.android = t
o.mobile = t
} else if (!android && firefox && /\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
o.firefoxos = t
o.mobile = t
}
}
else if (android) o = {
@ -96,31 +163,32 @@
, webkit: t
, android: t
, mobile: t
, version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1]
, version: getVersion(ua, webkitVersion, 1)
}
else if (safari) o = {
name: 'Safari'
, webkit: t
, safari: t
, version: ((v = ua.match(webkitVersion)) ? v[1] : 0)
, version: getVersion(ua, webkitVersion, 1)
}
else if (gecko) {
o = {
name: 'Gecko'
, gecko: t
, mozilla: t
, version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0)
var osVersion;
if (android) {
osVersion = getVersion(ua, /android[ \/](\d+(\.\d+)*)/i, 1);
if (osVersion) {
o.osversion = osVersion;
}
if (firefox) {
o.name = 'Firefox';
o.firefox = t;
} else if (iphone || ipad || ipod) {
osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1);
if (osVersion) {
o.osversion = osVersion.replace(/[_\s]/g, '.');
}
} else if (windowsphone) {
osVersion = getVersion(ua, /windows phone (?:os)?\s?(\d+(\.\d+)*)/i, 1);
if (osVersion) {
o.osversion = osVersion;
}
}
else if (seamonkey) o = {
name: 'SeaMonkey'
, seamonkey: t
, version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]
}
// Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs
@ -128,7 +196,9 @@
(o.chrome && o.version >= 20) ||
(o.firefox && o.version >= 10.0) ||
(o.safari && o.version >= 5) ||
(o.opera && o.version >= 10.0)) {
(o.opera && o.version >= 10.0) ||
(o.ios && o.osversion && o.osversion.split(".")[0] >= 6)
) {
o.a = t;
}
@ -136,7 +206,9 @@
(o.chrome && o.version < 20) ||
(o.firefox && o.version < 10.0) ||
(o.safari && o.version < 5) ||
(o.opera && o.version < 10.0)) {
(o.opera && o.version < 10.0) ||
(o.ios && o.osversion && o.osversion.split(".")[0] < 6)
) {
o.c = t
} else o.x = t

View File

@ -7,72 +7,82 @@
*/
module.exports.useragents = {
Chrome: {
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36': {
'Mozilla/5.0 (Linux; Android 4.3; Galaxy Nexus Build/JWR66Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Mobile Safari/537.36': {
chrome: true
, android: true
, osversion: '4.3'
, mobile: true
, version: '32.0'
, webkit: true
, a: true
}
, 'Mozilla/5.0 (Linux; Android 4.1; Galaxy Nexus Build/JRN84D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19': {
chrome: true
, android: true
, osversion: '4.1'
, mobile: true
, version: '18.0'
, webkit: true
, c: true
}
, 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3': {
chrome: true
, iphone: true
, ios: true
, osversion: '5.1.1'
, mobile: true
, version: '19.0'
, webkit: true
, c: true
}
, 'Mozilla/5.0 (iPad; U; CPU OS 5_1_1 like Mac OS X; en-us) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3': {
chrome: true
, ipad: true
, ios: true
, osversion: '5.1.1'
, mobile: true
, version: '19.0'
, webkit: true
, c: true
}
, 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36': {
chrome: true
, ipad: false
, iphone: false
, ios: false
, mobile: false
, version: '30.0'
, webkit: true
, a: true
}
}
, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36': {
chrome: true
, ipad: false
, iphone: false
, ios: false
, mobile: false
, version: '29.0'
, webkit: true
, a: true
}
, 'Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36': {
chrome: true
, ipad: false
, iphone: false
, ios: false
, mobile: false
, version: '29.0'
, webkit: true
, a: true
}
, 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36': {
chrome: true
, ipad: false
, iphone: false
, ios: false
, mobile: false
, version: '29.0'
, webkit: true
, a: true
}
, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36': {
chrome: true
, ipad: false
, iphone: false
, ios: false
, mobile: false
, version: '28.0'
, webkit: true
, a: true
}
, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24': {
chrome: true
, ipad: false
, iphone: false
, ios: false
, mobile: false
, version: '11.0'
, webkit: true
, c: true
}
, 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.462.0 Safari/534.3': {
chrome: true
, ipad: false
, iphone: false
, ios: false
, mobile: false
, version: '6.0'
, webkit: true
, c: true
@ -89,7 +99,30 @@ module.exports.useragents = {
}
}
, Opera: {
'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14': {
'Mozilla/5.0 (Linux; Android 4.3; Galaxy Nexus Build/JWR66Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.72 Mobile Safari/537.36 OPR/19.0.1340.69721': {
opera: true
, webkit: true
, android: true
, osversion: '4.3'
, mobile: true
, version: '19.0'
, a: true
}
, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100': {
opera: true
, webkit: true
, version: '15.0'
, a: true
}
, 'Opera/9.80 (Android 4.3; Linux; Opera Mobi/ADR-1309251116) Presto/2.11.355 Version/12.10': {
opera: true
, version: '12.10'
, android: true
, osversion: '4.3'
, mobile: true
, a: true
}
, 'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14': {
opera: true
, version: '12.14'
, a: true
@ -190,7 +223,12 @@ module.exports.useragents = {
}
}
, 'Internet Explorer': {
'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; Media Center PC 6.0; rv:11.0) like Gecko': {
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; ARM; Touch; WPDesktop)': {
msie: true
, version: '10.0'
, a: true
}
, 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; Media Center PC 6.0; rv:11.0) like Gecko': {
msie: true
, version: '11.0'
, a: true
@ -237,7 +275,52 @@ module.exports.useragents = {
}
}
, Firefox: {
'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0': {
'Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0': {
mozilla: true
, gecko: true
, firefox: true
, version: '26.0'
, mobile: true
, firefoxos: true
, a: true
}
, 'Mozilla/5.0 (Tablet; rv:26.0) Gecko/26.0 Firefox/26.0': {
mozilla: true
, gecko: true
, firefox: true
, version: '26.0'
, mobile: true
, firefoxos: true
, a: true
}
, 'Mozilla/5.0 (Mobile; LG-D300; rv:18.1) Gecko/18.1 Firefox/18.1': {
mozilla: true
, gecko: true
, firefox: true
, version: '18.1'
, mobile: true
, firefoxos: true
, a: true
}
, 'Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.0': {
mozilla: true
, gecko: true
, firefox: true
, version: '27.0'
, mobile: true
, android: true
, a: true
}
, 'Mozilla/5.0 (Android; Tablet; rv:26.0) Gecko/26.0 Firefox/26.0': {
mozilla: true
, gecko: true
, firefox: true
, version: '26.0'
, mobile: true
, android: true
, a: true
}
, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0': {
mozilla: true
, gecko: true
, firefox: true
@ -315,43 +398,68 @@ module.exports.useragents = {
, c: true
}
}
, SeaMonkey: {
'Mozilla/5.0 (Windows NT 5.2; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 SeaMonkey/2.7.1': {
mozilla: true
, gecko: true
, seamonkey: true
, version: '2.7'
, x: true
}
, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 SeaMonkey/2.7.1': {
mozilla: true
, gecko: true
, seamonkey: true
, version: '2.7'
, x: true
}
, 'Mozilla/5.0 (X11; Linux i686; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 SeaMonkey/2.7.1': {
mozilla: true
, gecko: true
, seamonkey: true
, version: '2.7'
, x: true
}
}
, iPhone: {
'Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': {
'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a': {
ios: true
, version: '5.0'
, osversion: '7.0.4'
, iphone: true
, ipad: false
, ipod: false
, mobile: true
, webkit: true
, x: true
, a: true
}
, 'Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': {
ios: true
, osversion: '4.3.2'
, version: '5.0'
, iphone: true
, mobile: true
, webkit: true
, c: true
}
, 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3': {
ios: true
, version: '3.0'
, iphone: true
, ipad: false
, ipod: false
, mobile: true
, webkit: true
, x: true
}
, 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B5097d Safari/6531.22.7': {
ios: true
, osversion: '4.1'
, version: '4.0'
, iphone: true
, ipad: false
, ipod: false
, mobile: true
, webkit: true
, x: true
, c: true
}
, 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_2; en-gb) AppleWebKit/526+ (KHTML, like Gecko) Version/3.1 iPhone': {
ios: true
, version: '3.1'
, iphone: true
, ipad: false
, ipod: false
, mobile: true
, webkit: true
, x: true
@ -360,52 +468,148 @@ module.exports.useragents = {
, iPad: {
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25': {
ios: true
, osversion: '6.0'
, name: 'iPad'
, version: '6.0'
, iphone: false
, ipad: true
, ipod: false
, mobile: false
, mobile: true
, webkit: true
, x: true
, a: true
}
, 'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3': {
ios: true
, osversion: '5.1'
, name: 'iPad'
, version: '5.1'
, iphone: false
, ipad: true
, ipod: false
, mobile: false
, mobile: true
, webkit: true
, x: true
, c: true
}
, 'Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': {
ios: true
, osversion: '4.3.2'
, name: 'iPad'
, version: '5.0'
, iphone: false
, ipad: true
, ipod: false
, mobile: false
, mobile: true
, webkit: true
, x: true
, c: true
}
, 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; es-es) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B360 Safari/531.21.10': {
ios: true
, osversion: '3.2'
, name: 'iPad'
, version: '4.0'
, iphone: false
, ipad: true
, ipod: false
, mobile: false
, mobile: true
, webkit: true
, c: true
}
}
, iPod: {
'Mozilla/5.0 (iPod; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3': {
ios: true
, osversion: '5.1'
, version: '5.1'
, ipod: true
, mobile: true
, webkit: true
, c: true
}
, 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5': {
ios: true
, osversion: '4.3.3'
, version: '5.0'
, ipod: true
, mobile: true
, webkit: true
, c: true
}
, 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3': {
ios: true
, version: '3.0'
, ipod: true
, mobile: true
, webkit: true
, x: true
}
}
, BlackBerry: {
'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+': {
blackberry: true
, version: '7.1'
, webkit: true
, mobile: true
, x: true
}
, 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.450 Mobile Safari/534.8+': {
blackberry: true
, version: '6.0'
, webkit: true
, mobile: true
, x: true
}
, 'BlackBerry9800/5.0.0.862 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/331 UNTRUSTED/1.0 3gpp-gba': {
blackberry: true
, version: '5.0'
, mobile: true
, x: true
}
, 'BlackBerry8320/4.5.0.52 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179': {
blackberry: true
, version: '4.5'
, mobile: true
, x: true
}
}
, 'Windows Phone': {
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920; Vodafone)': {
windowsphone: true
, osversion: '8.0'
, msie: true
, version: '10.0'
, mobile: true
, a: true
}
, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)': {
windowsphone: true
, osversion: '8.0'
, msie: true
, version: '10.0'
, mobile: true
, a: true
}
, 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)': {
windowsphone: true
, osversion: '7.5'
, msie: true
, version: '9.0'
, mobile: true
, a: true
}
, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; Nokia;N70)': {
windowsphone: true
, osversion: '7.0'
, msie: true
, version: '7.0'
, mobile: true
, c: true
}
}
, WebOS: {
'Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0': {
webos: true
, webkit: true
, version: '1.0'
, mobile: true
, x: true
}
}
, Android: {
'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1': {
android: true
, osversion: '2.3.4'
, webkit: true
, version: 4.0
, mobile: true
@ -413,6 +617,7 @@ module.exports.useragents = {
}
, 'Mozilla/5.0 (Linux; U; Android 1.6; ar-us; SonyEricssonX10i Build/R2BA026) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1': {
android: true
, osversion: '1.6'
, webkit: true
, version: 3.1
, mobile: true