From 8668678f8a226c4d3c457570c4a0ef99f93158cd Mon Sep 17 00:00:00 2001 From: Hannes Diercks Date: Mon, 16 Dec 2013 06:52:33 +0100 Subject: [PATCH 01/10] Add support for ipod, windowsphone, webos and blackberry. --- README.md | 14 ++++++-- src/bowser.js | 38 +++++++++++++++++++-- src/useragents.js | 87 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 82f79d1..37effa3 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,21 @@ if (bowser.msie && bowser.version <= 6) { Detected Browsers ----- - * msie - * safari[webkit] + * android + * blackberry * chrome[webkit] * firefox[gecko] + * ipad + * iphone + * ipod + * msie * opera + * phantomjs + * safari[webkit] + * seamonkey + * touchpad + * webos + * windows phone Notes ---- diff --git a/src/bowser.js b/src/bowser.js index 5ab09c2..2df391d 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -18,17 +18,27 @@ , safari = /safari/i.test(ua) && !chrome && !phantom , iphone = /iphone/i.test(ua) , ipad = /ipad/i.test(ua) + , ipod = /ipod/i.test(ua) , touchpad = /touchpad/i.test(ua) , android = /android/i.test(ua) , opera = /opera/i.test(ua) || /opr/i.test(ua) , 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 , o = {} - if (opera) { + if (windowsphone) o = { + name: 'Windows Phone' + , windowsphone: t + , mobile: t + , version: ua.match(/iemobile\/(\d+(\.\d+)?)/i)[1] + } + else 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] @@ -61,20 +71,42 @@ , touchpad: t , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] } - else if (iphone || ipad) { + else if (iphone || ipad || ipod) { + if (ipod) iphone = false o = { - name : iphone ? 'iPhone' : 'iPad' + name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod' , webkit: t , mobile: t , ios: t , iphone: iphone , ipad: ipad + , ipod: ipod } // WTF: version is not part of user agent in web apps if (webkitVersion.test(ua)) { o.version = ua.match(webkitVersion)[1] } } + else if (blackberry) { + o = { + name: 'BlackBerry' + , blackberry: t + , mobile: t + } + if ((v = ua.match(webkitVersion))) { + o.version = v[1] + o.webkit = t + } else { + o.version = ua.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1] + } + } + else if (webos) o = { + name: 'WebOS' + , mobile: t + , webkit: t + , webos: t + , version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1] + } else if (android) o = { name: 'Android' , webkit: t diff --git a/src/useragents.js b/src/useragents.js index ba66622..dfbb2b6 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -283,6 +283,7 @@ module.exports.useragents = { , version: '5.0' , iphone: true , ipad: false + , ipod: false , mobile: true , webkit: true , x: true @@ -292,6 +293,7 @@ module.exports.useragents = { , version: '3.0' , iphone: true , ipad: false + , ipod: false , mobile: true , webkit: true , x: true @@ -301,6 +303,7 @@ module.exports.useragents = { , version: '4.0' , iphone: true , ipad: false + , ipod: false , mobile: true , webkit: true , x: true @@ -310,6 +313,7 @@ module.exports.useragents = { , version: '3.1' , iphone: true , ipad: false + , ipod: false , mobile: true , webkit: true , x: true @@ -321,6 +325,7 @@ module.exports.useragents = { , version: '6.0' , iphone: false , ipad: true + , ipod: false , mobile: true , webkit: true , x: true @@ -330,6 +335,7 @@ module.exports.useragents = { , version: '5.1' , iphone: false , ipad: true + , ipod: false , mobile: true , webkit: true , x: true @@ -339,6 +345,7 @@ module.exports.useragents = { , version: '5.0' , iphone: false , ipad: true + , ipod: false , mobile: true , webkit: true , x: true @@ -348,11 +355,91 @@ module.exports.useragents = { , version: '4.0' , iphone: false , ipad: true + , ipod: false , mobile: true , webkit: true , x: true } } + , iPod: { + '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 + , version: '5.0' + , iphone: false + , ipad: false + , ipod: true + , mobile: true + , webkit: true + , x: 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' + , iphone: false + , ipad: false + , 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)': { + windowsphone: true + , version: '10.0' + , mobile: true + , x: true + } + , 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)': { + windowsphone: true + , version: '9.0' + , mobile: true + , x: true + } + , 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; Nokia;N70)': { + windowsphone: true + , version: '7.0' + , mobile: true + , x: 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 From 5d246add74b988c0e13638fd17f78043f7f75f98 Mon Sep 17 00:00:00 2001 From: BendingBender Date: Thu, 20 Feb 2014 22:52:01 +0100 Subject: [PATCH 02/10] added detection for newer opera + opera mobile (new/legacy) --- src/bowser.js | 7 +++++++ src/useragents.js | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/bowser.js b/src/bowser.js index aaf2ec4..9f4d499 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -42,6 +42,13 @@ , opera: t , version: v } + if (android) { + o.android = true + o.mobile = true + } + if (chrome) { + o.webkit = true + } } else if (ie) o = { name: 'Internet Explorer' , msie: t diff --git a/src/useragents.js b/src/useragents.js index 08080ea..f635bd8 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -89,7 +89,28 @@ 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 + , 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 + , 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 From 4fdd74d05a39e666ee98ca8210ab688ad0673b2d Mon Sep 17 00:00:00 2001 From: BendingBender Date: Thu, 20 Feb 2014 23:17:59 +0100 Subject: [PATCH 03/10] fixed indentation --- bowser.js | 202 +++++++++++++++++++++++++++++--------------------- bowser.min.js | 2 +- src/bowser.js | 2 +- 3 files changed, 121 insertions(+), 85 deletions(-) diff --git a/bowser.js b/bowser.js index 4760640..c3e217a 100644 --- a/bowser.js +++ b/bowser.js @@ -5,61 +5,70 @@ */ !function (name, definition) { - if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() - else if (typeof define == 'function') define(definition) + if (typeof define == 'function') define(definition) + else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() else this[name] = definition() }('bowser', function () { /** - * navigator.userAgent => - * Chrome: "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" - * Opera: "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.7; U; en) Presto/2.7.62 Version/11.01" - * Safari: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1" - * IE: "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)" - * IE>=11: "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" - * Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0" - * 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" - * iPad: "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", - * iPod: "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5" - * 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" - * Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0" - * PhantomJS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34" - * Amazon Silk: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.22.153_10033210) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" + * See useragents.js for examples of navigator.userAgent */ - var ua = navigator.userAgent - , t = true - , ie = /(msie|trident)/i.test(ua) - , chrome = /chrome|crios/i.test(ua) - , phantom = /phantom/i.test(ua) - , iphone = /iphone/i.test(ua) - , ipad = /ipad/i.test(ua) - , ipod = /ipod/i.test(ua) - , touchpad = /touchpad/i.test(ua) - , silk = /silk/i.test(ua) - , safari = /safari/i.test(ua) && !chrome && !phantom && !silk - , android = /android/i.test(ua) - , opera = /opera/i.test(ua) || /opr/i.test(ua) - , firefox = /firefox/i.test(ua) - , gecko = /gecko\//i.test(ua) - , seamonkey = /seamonkey\//i.test(ua) - , webkitVersion = /version\/(\d+(\.\d+)?)/i - , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i - , mobile = /mobile/i.test(ua) - , o + var t = true, + v /* temporary placeholder for versions. */ - function detect() { + function detect(ua) { - if (ie) return { + var ie = /(msie|trident)/i.test(ua) + , chrome = /chrome|crios/i.test(ua) + , phantom = /phantom/i.test(ua) + , iphone = /iphone/i.test(ua) + , ipad = /ipad/i.test(ua) + , ipod = /ipod/i.test(ua) + , touchpad = /touchpad/i.test(ua) + , silk = /silk/i.test(ua) + , safari = /safari/i.test(ua) && !chrome && !phantom && !silk + , android = /android/i.test(ua) + , opera = /opera/i.test(ua) || /opr/i.test(ua) + , 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 + , mobile = /mobile/i.test(ua) + , o = {} + + if (windowsphone) o = { + name: 'Windows Phone' + , windowsphone: t + , mobile: t + , version: ua.match(/iemobile\/(\d+(\.\d+)?)/i)[1] + } + else 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 + o = { + name: 'Opera' + , opera: t + , version: v + } + if (android) { + o.android = true + o.mobile = true + } + if (chrome) { + o.webkit = true + } + } else if (ie) o = { name: 'Internet Explorer' , msie: t , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] } - if (opera) return { - name: 'Opera' - , opera: t - , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)[1] - } - if (chrome) return { + else if (chrome) o = { name: 'Chrome' , webkit: t , chrome: t @@ -69,31 +78,31 @@ , ios: !!ua.match(/crios/i) , mobile: mobile } - if (phantom) return { + else if (phantom) o = { name: 'PhantomJS' , webkit: t , phantom: t - , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] + , version: ua.match(/phantomjs\/(\d+(\.\d+)?)/i)[1] } - if (touchpad) return { + else if (touchpad) o = { name: 'TouchPad' , webkit: t , touchpad: t , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] } - - if (silk) return { - name: 'Amazon Silk' - , webkit: t - , android: t - , mobile: t - , version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1] - } - if (iphone || ipad || ipod) { + else if (silk) o = { + name: 'Amazon Silk' + , webkit: t + , android: t + , mobile: t + , version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1] + } + else if (iphone || ipad || ipod) { + if (ipod) iphone = false o = { name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod' , webkit: t - , mobile: iphone + , mobile: t , ios: t , iphone: iphone , ipad: ipad @@ -103,61 +112,88 @@ if (webkitVersion.test(ua)) { o.version = ua.match(webkitVersion)[1] } - return o } - if (android) return { + else if (blackberry) { + o = { + name: 'BlackBerry' + , blackberry: t + , mobile: t + } + if ((v = ua.match(webkitVersion))) { + o.version = v[1] + o.webkit = t + } else { + o.version = ua.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1] + } + } + else if (webos) o = { + name: 'WebOS' + , mobile: t + , webkit: t + , webos: t + , version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1] + } + else if (android) o = { name: 'Android' , webkit: t , android: t , mobile: t , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] } - if (safari) return { + else if (safari) o = { name: 'Safari' , webkit: t , safari: t - , version: ua.match(webkitVersion)[1] + , version: ((v = ua.match(webkitVersion)) ? v[1] : 0) } - if (gecko) { + else if (gecko) { o = { name: 'Gecko' , gecko: t , mozilla: t - , version: ua.match(firefoxVersion)[1] + , version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0) } if (firefox) { o.name = 'Firefox'; o.firefox = t; } - return o } - if (seamonkey) return { + else if (seamonkey) o = { name: 'SeaMonkey' , seamonkey: t , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] } - return {} + + // Graded Browser Support + // http://developer.yahoo.com/yui/articles/gbs + if ((o.msie && o.version >= 9) || + (o.chrome && o.version >= 20) || + (o.firefox && o.version >= 10.0) || + (o.safari && o.version >= 5) || + (o.opera && o.version >= 10.0)) { + o.a = t; + } + + else if ((o.msie && o.version < 9) || + (o.chrome && o.version < 20) || + (o.firefox && o.version < 10.0) || + (o.safari && o.version < 5) || + (o.opera && o.version < 10.0)) { + o.c = t + } else o.x = t + + return o } - var bowser = detect() + var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '') - // Graded Browser Support - // http://developer.yahoo.com/yui/articles/gbs - if ((bowser.msie && bowser.version >= 9) || - (bowser.chrome && bowser.version >= 20) || - (bowser.firefox && bowser.version >= 10.0) || - (bowser.safari && bowser.version >= 5) || - (bowser.opera && bowser.version >= 10.0)) { - bowser.a = t; - } - else if ((bowser.msie && bowser.version < 9) || - (bowser.chrome && bowser.version < 20) || - (bowser.firefox && bowser.version < 10.0) || - (bowser.safari && bowser.version < 5) || - (bowser.opera && bowser.version < 10.0)) { - bowser.c = t - } else bowser.x = t + /* + * Set our detect method to the main bowser object so we can + * reuse it to test other user agents. + * This is needed to implement future tests. + */ + bowser._detect = detect; return bowser }); diff --git a/bowser.min.js b/bowser.min.js index 1dc92af..bf7674e 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2013 */ -!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function w(){return n?{name:"Internet Explorer",msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:h?{name:"Opera",opera:t,version:e.match(m)?e.match(m)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)[1]}:r?{name:"Chrome",webkit:t,chrome:t,version:e.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:o,iphone:s,ios:!!e.match(/crios/i),mobile:y}:i?{name:"PhantomJS",webkit:t,phantom:t,version:e.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]}:a?{name:"TouchPad",webkit:t,touchpad:t,version:e.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:f?{name:"Amazon Silk",webkit:t,android:t,mobile:t,version:e.match(/silk\/(\d+(\.\d+)?)/i)[1]}:s||o||u?(b={name:s?"iPhone":o?"iPad":"iPod",webkit:t,mobile:s,ios:t,iphone:s,ipad:o,ipod:u},m.test(e)&&(b.version=e.match(m)[1]),b):c?{name:"Android",webkit:t,android:t,mobile:t,version:(e.match(m)||e.match(g))[1]}:l?{name:"Safari",webkit:t,safari:t,version:e.match(m)[1]}:d?(b={name:"Gecko",gecko:t,mozilla:t,version:e.match(g)[1]},p&&(b.name="Firefox",b.firefox=t),b):v?{name:"SeaMonkey",seamonkey:t,version:e.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}:{}}var e=navigator.userAgent,t=!0,n=/(msie|trident)/i.test(e),r=/chrome|crios/i.test(e),i=/phantom/i.test(e),s=/iphone/i.test(e),o=/ipad/i.test(e),u=/ipod/i.test(e),a=/touchpad/i.test(e),f=/silk/i.test(e),l=/safari/i.test(e)&&!r&&!i&&!f,c=/android/i.test(e),h=/opera/i.test(e)||/opr/i.test(e),p=/firefox/i.test(e),d=/gecko\//i.test(e),v=/seamonkey\//i.test(e),m=/version\/(\d+(\.\d+)?)/i,g=/firefox\/(\d+(\.\d+)?)/i,y=/mobile/i.test(e),b,E=w();return 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=t: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=t:E.x=t,E}) \ No newline at end of file +!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/webos/i.test(n),b=/windows phone/i.test(n),w=/blackberry/i.test(n),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x=/mobile/i.test(n),T={};return b?T={name:"Windows Phone",windowsphone:e,mobile:e,version:n.match(/iemobile\/(\d+(\.\d+)?)/i)[1]}:p?((t=n.match(E))&&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,T={name:"Opera",opera:e,version:t},h&&(T.android=!0,T.mobile=!0),i&&(T.webkit=!0)):r?T={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?T={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:x}:s?T={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?T={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(a&&(o=!1),T={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:o,ipad:u,ipod:a},E.test(n)&&(T.version=n.match(E)[1])):w?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n.match(E))?(T.version=t[1],T.webkit=e):T.version=n.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]):y?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:(n.match(E)||n.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]}:h?T={name:"Android",webkit:e,android:e,mobile:e,version:(n.match(E)||n.match(S))[1]}:c?T={name:"Safari",webkit:e,safari:e,version:(t=n.match(E))?t[1]:0}:m?(T={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(S))&&t?t[1]:0},d&&(T.name="Firefox",T.firefox=e)):g&&(T={name:"SeaMonkey",seamonkey:e,version:n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}),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.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.c=e:T.x=e,T}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index 3345467..591faac 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -126,7 +126,7 @@ , webkit: t , webos: t , version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1] - } + } else if (android) o = { name: 'Android' , webkit: t From 4acca40a99c7e41aee28564fd3d4b793bae8f1e9 Mon Sep 17 00:00:00 2001 From: BendingBender Date: Fri, 21 Feb 2014 00:02:13 +0100 Subject: [PATCH 04/10] added tests and detection for mobile firefox and mobile chrome --- bowser.js | 43 +++++++++++++---------- bowser.min.js | 2 +- src/bowser.js | 43 +++++++++++++---------- src/useragents.js | 89 ++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 136 insertions(+), 41 deletions(-) diff --git a/bowser.js b/bowser.js index c3e217a..f556f78 100644 --- a/bowser.js +++ b/bowser.js @@ -40,6 +40,8 @@ , mobile = /mobile/i.test(ua) , o = {} + if (ipod) iphone = false + if (windowsphone) o = { name: 'Windows Phone' , windowsphone: t @@ -57,11 +59,11 @@ , version: v } if (android) { - o.android = true - o.mobile = true + o.android = t + o.mobile = t } if (chrome) { - o.webkit = true + o.webkit = t } } else if (ie) o = { name: 'Internet Explorer' @@ -75,7 +77,9 @@ , version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1] , ipad: ipad , iphone: iphone - , ios: !!ua.match(/crios/i) + , ipod: ipod + , ios: iphone || ipad || ipod + , android: android , mobile: mobile } else if (phantom) o = { @@ -98,7 +102,6 @@ , version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1] } else if (iphone || ipad || ipod) { - if (ipod) iphone = false o = { name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod' , webkit: t @@ -133,19 +136,6 @@ , webos: t , version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1] } - else if (android) o = { - name: 'Android' - , webkit: t - , android: t - , mobile: t - , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] - } - else if (safari) o = { - name: 'Safari' - , webkit: t - , safari: t - , version: ((v = ua.match(webkitVersion)) ? v[1] : 0) - } else if (gecko) { o = { name: 'Gecko' @@ -157,7 +147,24 @@ o.name = 'Firefox'; o.firefox = t; } + if (android) { + o.android = t + o.mobile = t + } } + else if (android) o = { + name: 'Android' + , webkit: t + , android: t + , mobile: t + , version: ua.match(webkitVersion)[1] + } + else if (safari) o = { + name: 'Safari' + , webkit: t + , safari: t + , version: ((v = ua.match(webkitVersion)) ? v[1] : 0) + } else if (seamonkey) o = { name: 'SeaMonkey' , seamonkey: t diff --git a/bowser.min.js b/bowser.min.js index bf7674e..6f71c85 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2013 */ -!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/webos/i.test(n),b=/windows phone/i.test(n),w=/blackberry/i.test(n),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x=/mobile/i.test(n),T={};return b?T={name:"Windows Phone",windowsphone:e,mobile:e,version:n.match(/iemobile\/(\d+(\.\d+)?)/i)[1]}:p?((t=n.match(E))&&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,T={name:"Opera",opera:e,version:t},h&&(T.android=!0,T.mobile=!0),i&&(T.webkit=!0)):r?T={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?T={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:x}:s?T={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?T={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(a&&(o=!1),T={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:o,ipad:u,ipod:a},E.test(n)&&(T.version=n.match(E)[1])):w?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n.match(E))?(T.version=t[1],T.webkit=e):T.version=n.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]):y?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:(n.match(E)||n.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]}:h?T={name:"Android",webkit:e,android:e,mobile:e,version:(n.match(E)||n.match(S))[1]}:c?T={name:"Safari",webkit:e,safari:e,version:(t=n.match(E))?t[1]:0}:m?(T={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(S))&&t?t[1]:0},d&&(T.name="Firefox",T.firefox=e)):g&&(T={name:"SeaMonkey",seamonkey:e,version:n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}),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.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.c=e:T.x=e,T}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r}) \ No newline at end of file +!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/webos/i.test(n),b=/windows phone/i.test(n),w=/blackberry/i.test(n),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x=/mobile/i.test(n),T={};return a&&(o=!1),b?T={name:"Windows Phone",windowsphone:e,mobile:e,version:n.match(/iemobile\/(\d+(\.\d+)?)/i)[1]}:p?((t=n.match(E))&&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,T={name:"Opera",opera:e,version:t},h&&(T.android=e,T.mobile=e),i&&(T.webkit=e)):r?T={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?T={name:"Chrome",webkit:e,chrome:e,version:n.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:u,iphone:o,ipod:a,ios:o||u||a,android:h,mobile:x}:s?T={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?T={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(T={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:o,ipad:u,ipod:a},E.test(n)&&(T.version=n.match(E)[1])):w?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n.match(E))?(T.version=t[1],T.webkit=e):T.version=n.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]):y?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:(n.match(E)||n.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]}:m?(T={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(S))&&t?t[1]:0},d&&(T.name="Firefox",T.firefox=e),h&&(T.android=e,T.mobile=e)):h?T={name:"Android",webkit:e,android:e,mobile:e,version:n.match(E)[1]}:c?T={name:"Safari",webkit:e,safari:e,version:(t=n.match(E))?t[1]:0}:g&&(T={name:"SeaMonkey",seamonkey:e,version:n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}),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.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.c=e:T.x=e,T}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index 591faac..cca3328 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -34,6 +34,8 @@ , mobile = /mobile/i.test(ua) , o = {} + if (ipod) iphone = false + if (windowsphone) o = { name: 'Windows Phone' , windowsphone: t @@ -51,11 +53,11 @@ , version: v } if (android) { - o.android = true - o.mobile = true + o.android = t + o.mobile = t } if (chrome) { - o.webkit = true + o.webkit = t } } else if (ie) o = { name: 'Internet Explorer' @@ -69,7 +71,9 @@ , version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1] , ipad: ipad , iphone: iphone - , ios: !!ua.match(/crios/i) + , ipod: ipod + , ios: iphone || ipad || ipod + , android: android , mobile: mobile } else if (phantom) o = { @@ -92,7 +96,6 @@ , version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1] } else if (iphone || ipad || ipod) { - if (ipod) iphone = false o = { name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod' , webkit: t @@ -127,19 +130,6 @@ , webos: t , version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1] } - else if (android) o = { - name: 'Android' - , webkit: t - , android: t - , mobile: t - , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] - } - else if (safari) o = { - name: 'Safari' - , webkit: t - , safari: t - , version: ((v = ua.match(webkitVersion)) ? v[1] : 0) - } else if (gecko) { o = { name: 'Gecko' @@ -151,7 +141,24 @@ o.name = 'Firefox'; o.firefox = t; } + if (android) { + o.android = t + o.mobile = t + } } + else if (android) o = { + name: 'Android' + , webkit: t + , android: t + , mobile: t + , version: ua.match(webkitVersion)[1] + } + else if (safari) o = { + name: 'Safari' + , webkit: t + , safari: t + , version: ((v = ua.match(webkitVersion)) ? v[1] : 0) + } else if (seamonkey) o = { name: 'SeaMonkey' , seamonkey: t diff --git a/src/useragents.js b/src/useragents.js index faf692e..c41c492 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -7,21 +7,73 @@ */ 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 , ipad: false , iphone: false + , ipod: false , ios: false + , android: true + , 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 + , ipad: false + , iphone: false + , ipod: false + , ios: false + , android: true + , 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 + , ipad: false + , iphone: true + , ipod: false + , ios: true + , android: false + , 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 + , iphone: false + , ipod: false + , ios: true + , android: false + , 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 + , ipod: false + , ios: false + , android: 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 + , ipod: false , ios: false + , android: false , mobile: false , version: '29.0' , webkit: true @@ -31,7 +83,9 @@ module.exports.useragents = { chrome: true , ipad: false , iphone: false + , ipod: false , ios: false + , android: false , mobile: false , version: '29.0' , webkit: true @@ -41,7 +95,9 @@ module.exports.useragents = { chrome: true , ipad: false , iphone: false + , ipod: false , ios: false + , android: false , mobile: false , version: '29.0' , webkit: true @@ -51,7 +107,9 @@ module.exports.useragents = { chrome: true , ipad: false , iphone: false + , ipod: false , ios: false + , android: false , mobile: false , version: '28.0' , webkit: true @@ -61,7 +119,9 @@ module.exports.useragents = { chrome: true , ipad: false , iphone: false + , ipod: false , ios: false + , android: false , mobile: false , version: '11.0' , webkit: true @@ -71,7 +131,9 @@ module.exports.useragents = { chrome: true , ipad: false , iphone: false + , ipod: false , ios: false + , android: false , mobile: false , version: '6.0' , webkit: true @@ -258,7 +320,16 @@ module.exports.useragents = { } } , Firefox: { - 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0': { + '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 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0': { mozilla: true , gecko: true , firefox: true @@ -425,7 +496,17 @@ module.exports.useragents = { } } , iPod: { - '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': { + '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 + , version: '5.1' + , iphone: false + , ipad: false + , ipod: true + , mobile: true + , webkit: true + , x: 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 , version: '5.0' , iphone: false From 1a22035c5b0d967afb3f336cab8589b7840629a7 Mon Sep 17 00:00:00 2001 From: BendingBender Date: Fri, 21 Feb 2014 00:30:09 +0100 Subject: [PATCH 05/10] added tests for seamonkey and fixed detection --- bowser.js | 16 ++++++++-------- bowser.min.js | 2 +- src/bowser.js | 16 ++++++++-------- src/useragents.js | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/bowser.js b/bowser.js index f556f78..c925330 100644 --- a/bowser.js +++ b/bowser.js @@ -143,14 +143,19 @@ , mozilla: t , version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0) } - if (firefox) { - o.name = 'Firefox'; - o.firefox = t; + if (seamonkey) { + o.name = 'SeaMonkey' + o.seamonkey = t + o.version = ua.match(/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) o = { name: 'Android' @@ -165,11 +170,6 @@ , safari: t , version: ((v = ua.match(webkitVersion)) ? v[1] : 0) } - 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 diff --git a/bowser.min.js b/bowser.min.js index 6f71c85..e36836c 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2013 */ -!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/webos/i.test(n),b=/windows phone/i.test(n),w=/blackberry/i.test(n),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x=/mobile/i.test(n),T={};return a&&(o=!1),b?T={name:"Windows Phone",windowsphone:e,mobile:e,version:n.match(/iemobile\/(\d+(\.\d+)?)/i)[1]}:p?((t=n.match(E))&&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,T={name:"Opera",opera:e,version:t},h&&(T.android=e,T.mobile=e),i&&(T.webkit=e)):r?T={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?T={name:"Chrome",webkit:e,chrome:e,version:n.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:u,iphone:o,ipod:a,ios:o||u||a,android:h,mobile:x}:s?T={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?T={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(T={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:o,ipad:u,ipod:a},E.test(n)&&(T.version=n.match(E)[1])):w?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n.match(E))?(T.version=t[1],T.webkit=e):T.version=n.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]):y?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:(n.match(E)||n.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]}:m?(T={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(S))&&t?t[1]:0},d&&(T.name="Firefox",T.firefox=e),h&&(T.android=e,T.mobile=e)):h?T={name:"Android",webkit:e,android:e,mobile:e,version:n.match(E)[1]}:c?T={name:"Safari",webkit:e,safari:e,version:(t=n.match(E))?t[1]:0}:g&&(T={name:"SeaMonkey",seamonkey:e,version:n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}),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.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.c=e:T.x=e,T}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r}) \ No newline at end of file +!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/webos/i.test(n),b=/windows phone/i.test(n),w=/blackberry/i.test(n),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x=/mobile/i.test(n),T={};return a&&(o=!1),b?T={name:"Windows Phone",windowsphone:e,mobile:e,version:n.match(/iemobile\/(\d+(\.\d+)?)/i)[1]}:p?((t=n.match(E))&&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,T={name:"Opera",opera:e,version:t},h&&(T.android=e,T.mobile=e),i&&(T.webkit=e)):r?T={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?T={name:"Chrome",webkit:e,chrome:e,version:n.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:u,iphone:o,ipod:a,ios:o||u||a,android:h,mobile:x}:s?T={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?T={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(T={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:o,ipad:u,ipod:a},E.test(n)&&(T.version=n.match(E)[1])):w?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n.match(E))?(T.version=t[1],T.webkit=e):T.version=n.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]):y?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:(n.match(E)||n.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]}:m?(T={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(S))&&t?t[1]:0},g?(T.name="SeaMonkey",T.seamonkey=e,T.version=n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]):d&&(T.name="Firefox",T.firefox=e),h&&(T.android=e,T.mobile=e)):h?T={name:"Android",webkit:e,android:e,mobile:e,version:n.match(E)[1]}:c&&(T={name:"Safari",webkit:e,safari:e,version:(t=n.match(E))?t[1]:0}),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.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.c=e:T.x=e,T}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index cca3328..dbd9de1 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -137,14 +137,19 @@ , mozilla: t , version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0) } - if (firefox) { - o.name = 'Firefox'; - o.firefox = t; + if (seamonkey) { + o.name = 'SeaMonkey' + o.seamonkey = t + o.version = ua.match(/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) o = { name: 'Android' @@ -159,11 +164,6 @@ , safari: t , version: ((v = ua.match(webkitVersion)) ? v[1] : 0) } - 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 diff --git a/src/useragents.js b/src/useragents.js index c41c492..fbe0cf6 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -329,6 +329,15 @@ module.exports.useragents = { , 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 @@ -407,6 +416,29 @@ 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': { ios: true From 24dd55d9b41b8be19966208873cd81e26c80d44b Mon Sep 17 00:00:00 2001 From: BendingBender Date: Fri, 21 Feb 2014 00:54:32 +0100 Subject: [PATCH 06/10] added detection and tests for firefox on firefox os --- src/bowser.js | 4 +++- src/useragents.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index dbd9de1..cf5022a 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -148,8 +148,10 @@ 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 = { name: 'Android' diff --git a/src/useragents.js b/src/useragents.js index fbe0cf6..dc908cf 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -320,7 +320,34 @@ module.exports.useragents = { } } , Firefox: { - 'Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.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 From 0da898f90694e901b9faa1a3e3db73a028b21df9 Mon Sep 17 00:00:00 2001 From: BendingBender Date: Fri, 21 Feb 2014 01:23:58 +0100 Subject: [PATCH 07/10] made version extraction less error-prone/more future-proof, will now always check if result of regex match is truthy and array bounds are correct before actually accessing the version number --- bowser.js | 49 ++++++++++++++++++++++++++++--------------------- bowser.min.js | 2 +- src/bowser.js | 45 +++++++++++++++++++++++++-------------------- 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/bowser.js b/bowser.js index c925330..29054de 100644 --- a/bowser.js +++ b/bowser.js @@ -16,6 +16,11 @@ 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) @@ -46,13 +51,12 @@ name: 'Windows Phone' , windowsphone: t , mobile: t - , version: ua.match(/iemobile\/(\d+(\.\d+)?)/i)[1] + , version: getVersion(ua, /iemobile\/(\d+(\.\d+)?)/i, 1) } else 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 + v = getVersion(ua, webkitVersion, 1) || + getVersion(ua, /opr\/(\d+(\.\d+)?)/i, 1) || + getVersion(ua, /opera[ \/](\d+(\.\d+)?)/i, 1); o = { name: 'Opera' , opera: t @@ -65,16 +69,17 @@ if (chrome) { o.webkit = t } - } else if (ie) o = { + } + 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 = { name: 'Chrome' , webkit: t , chrome: t - , version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1] + , version: getVersion(ua, /(?:chrome|crios)\/(\d+(\.\d+)?)/i, 1) , ipad: ipad , iphone: iphone , ipod: ipod @@ -86,20 +91,20 @@ 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 = { @@ -113,7 +118,7 @@ } // 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) { @@ -122,11 +127,11 @@ , blackberry: t , mobile: t } - if ((v = ua.match(webkitVersion))) { - o.version = v[1] + if ((v = getVersion(ua, webkitVersion, 1))) { + o.version = v o.webkit = t } else { - o.version = ua.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1] + o.version = getVersion(ua, /blackberry[\d]+\/(\d+(\.\d+)?)/i, 1) } } else if (webos) o = { @@ -134,19 +139,19 @@ , mobile: t , webkit: t , webos: t - , version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1] + , version: (getVersion(ua, webkitVersion, 1) || getVersion(ua, /wosbrowser\/(\d+(\.\d+)?)/i, 1)) } else if (gecko) { o = { name: 'Gecko' , gecko: t , mozilla: t - , version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0) + , version: getVersion(ua, firefoxVersion, 1) } if (seamonkey) { o.name = 'SeaMonkey' o.seamonkey = t - o.version = ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] + o.version = getVersion(ua, /seamonkey\/(\d+(\.\d+)?)/i, 1) } else if (firefox) { o.name = 'Firefox' o.firefox = t @@ -154,21 +159,23 @@ 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 = { name: 'Android' , webkit: t , android: t , mobile: t - , version: ua.match(webkitVersion)[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) } // Graded Browser Support diff --git a/bowser.min.js b/bowser.min.js index e36836c..16a74c5 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2013 */ -!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/webos/i.test(n),b=/windows phone/i.test(n),w=/blackberry/i.test(n),E=/version\/(\d+(\.\d+)?)/i,S=/firefox[ \/](\d+(\.\d+)?)/i,x=/mobile/i.test(n),T={};return a&&(o=!1),b?T={name:"Windows Phone",windowsphone:e,mobile:e,version:n.match(/iemobile\/(\d+(\.\d+)?)/i)[1]}:p?((t=n.match(E))&&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,T={name:"Opera",opera:e,version:t},h&&(T.android=e,T.mobile=e),i&&(T.webkit=e)):r?T={name:"Internet Explorer",msie:e,version:n.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:i?T={name:"Chrome",webkit:e,chrome:e,version:n.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:u,iphone:o,ipod:a,ios:o||u||a,android:h,mobile:x}:s?T={name:"PhantomJS",webkit:e,phantom:e,version:n.match(/phantomjs\/(\d+(\.\d+)?)/i)[1]}:f?T={name:"TouchPad",webkit:e,touchpad:e,version:n.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:l?T={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n.match(/silk\/(\d+(\.\d+)?)/i)[1]}:o||u||a?(T={name:o?"iPhone":u?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:o,ipad:u,ipod:a},E.test(n)&&(T.version=n.match(E)[1])):w?(T={name:"BlackBerry",blackberry:e,mobile:e},(t=n.match(E))?(T.version=t[1],T.webkit=e):T.version=n.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1]):y?T={name:"WebOS",mobile:e,webkit:e,webos:e,version:(n.match(E)||n.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1]}:m?(T={name:"Gecko",gecko:e,mozilla:e,version:(t=n.match(S))&&t?t[1]:0},g?(T.name="SeaMonkey",T.seamonkey=e,T.version=n.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]):d&&(T.name="Firefox",T.firefox=e),h&&(T.android=e,T.mobile=e)):h?T={name:"Android",webkit:e,android:e,mobile:e,version:n.match(E)[1]}:c&&(T={name:"Safari",webkit:e,safari:e,version:(t=n.match(E))?t[1]:0}),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.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.c=e:T.x=e,T}var e=!0,t,r=n(typeof navigator!="undefined"?navigator.userAgent:"");return r._detect=n,r}) \ No newline at end of file +!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/mobile/i.test(r),N={};return f&&(u=!1),w?N={name:"Windows Phone",windowsphone:e,mobile:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)}:d?(t=n(r,S,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),N={name:"Opera",opera:e,version:t},p&&(N.android=e,N.mobile=e),s&&(N.webkit=e)):i?N={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)}:s?N={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios)\/(\d+(\.\d+)?)/i,1),ipad:a,iphone:u,ipod:f,ios:u||a||f,android:p,mobile:T}:o?N={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?N={name:"TouchPad",webkit:e,touchpad:e,version:n(r,/touchpad\/(\d+(\.\d+)?)/i,1)}:c?N={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(N={name:u?"iPhone":a?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:u,ipad:a,ipod:f},S.test(r)&&(N.version=n(r,S,1))):E?(N={name:"BlackBerry",blackberry:e,mobile:e},(t=n(r,S,1))?(N.version=t,N.webkit=e):N.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):b?N={name:"WebOS",mobile:e,webkit:e,webos:e,version:n(r,S,1)||n(r,/wosbrowser\/(\d+(\.\d+)?)/i,1)}:g?(N={name:"Gecko",gecko:e,mozilla:e,version:n(r,x,1)},y?(N.name="SeaMonkey",N.seamonkey=e,N.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):m&&(N.name="Firefox",N.firefox=e),p?(N.android=e,N.mobile=e):!p&&m&&/\((mobile|tablet);.*rv:[\d\.]+\)/i.test(r)&&(N.firefoxos=e,N.mobile=e)):p?N={name:"Android",webkit:e,android:e,mobile:e,version:n(r,S,1)}:h&&(N={name:"Safari",webkit:e,safari:e,version:n(r,S,1)}),N.msie&&N.version>=9||N.chrome&&N.version>=20||N.firefox&&N.version>=10||N.safari&&N.version>=5||N.opera&&N.version>=10?N.a=e:N.msie&&N.version<9||N.chrome&&N.version<20||N.firefox&&N.version<10||N.safari&&N.version<5||N.opera&&N.version<10?N.c=e:N.x=e,N}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index cf5022a..f641b7f 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -10,6 +10,11 @@ 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) @@ -40,13 +45,12 @@ name: 'Windows Phone' , windowsphone: t , mobile: t - , version: ua.match(/iemobile\/(\d+(\.\d+)?)/i)[1] + , version: getVersion(ua, /iemobile\/(\d+(\.\d+)?)/i, 1) } else 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 + v = getVersion(ua, webkitVersion, 1) || + getVersion(ua, /opr\/(\d+(\.\d+)?)/i, 1) || + getVersion(ua, /opera[ \/](\d+(\.\d+)?)/i, 1); o = { name: 'Opera' , opera: t @@ -59,16 +63,17 @@ if (chrome) { o.webkit = t } - } else if (ie) o = { + } + 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 = { name: 'Chrome' , webkit: t , chrome: t - , version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1] + , version: getVersion(ua, /(?:chrome|crios)\/(\d+(\.\d+)?)/i, 1) , ipad: ipad , iphone: iphone , ipod: ipod @@ -80,20 +85,20 @@ 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 = { @@ -107,7 +112,7 @@ } // 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) { @@ -116,11 +121,11 @@ , blackberry: t , mobile: t } - if ((v = ua.match(webkitVersion))) { - o.version = v[1] + if ((v = getVersion(ua, webkitVersion, 1))) { + o.version = v o.webkit = t } else { - o.version = ua.match(/blackberry[\d]+\/(\d+(\.\d+)?)/i)[1] + o.version = getVersion(ua, /blackberry[\d]+\/(\d+(\.\d+)?)/i, 1) } } else if (webos) o = { @@ -128,19 +133,19 @@ , mobile: t , webkit: t , webos: t - , version: (ua.match(webkitVersion) || ua.match(/wosbrowser\/(\d+(\.\d+)?)/i))[1] + , version: (getVersion(ua, webkitVersion, 1) || getVersion(ua, /wosbrowser\/(\d+(\.\d+)?)/i, 1)) } else if (gecko) { o = { name: 'Gecko' , gecko: t , mozilla: t - , version: ((v = ua.match(firefoxVersion)) && v? v[1] : 0) + , version: getVersion(ua, firefoxVersion, 1) } if (seamonkey) { o.name = 'SeaMonkey' o.seamonkey = t - o.version = ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] + o.version = getVersion(ua, /seamonkey\/(\d+(\.\d+)?)/i, 1) } else if (firefox) { o.name = 'Firefox' o.firefox = t @@ -158,13 +163,13 @@ , webkit: t , android: t , mobile: t - , version: ua.match(webkitVersion)[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) } // Graded Browser Support From ede3ff49cd561579f226d392cf8ec288c857d1da Mon Sep 17 00:00:00 2001 From: BendingBender Date: Fri, 21 Feb 2014 13:56:57 +0100 Subject: [PATCH 08/10] removed falsy flags from results, added osversion for ios/android/winphone, added msie flag for winphone, made ios safari a-grade down to v6 --- bowser.js | 48 +++++++++++---- bowser.min.js | 2 +- src/bowser.js | 48 +++++++++++---- src/useragents.js | 151 ++++++++++++++++++---------------------------- 4 files changed, 129 insertions(+), 120 deletions(-) diff --git a/bowser.js b/bowser.js index 29054de..2bd172f 100644 --- a/bowser.js +++ b/bowser.js @@ -42,7 +42,6 @@ , blackberry = /blackberry/i.test(ua) , webkitVersion = /version\/(\d+(\.\d+)?)/i , firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i - , mobile = /mobile/i.test(ua) , o = {} if (ipod) iphone = false @@ -50,6 +49,7 @@ if (windowsphone) o = { name: 'Windows Phone' , windowsphone: t + , msie: t , mobile: t , version: getVersion(ua, /iemobile\/(\d+(\.\d+)?)/i, 1) } @@ -75,18 +75,20 @@ , msie: t , version: getVersion(ua, /(msie |rv:)(\d+(\.\d+)?)/i, 2) } - else if (chrome) o = { + else if (chrome) { + o = { name: 'Chrome' , webkit: t , chrome: t , version: getVersion(ua, /(?:chrome|crios)\/(\d+(\.\d+)?)/i, 1) - , ipad: ipad - , iphone: iphone - , ipod: ipod - , ios: iphone || ipad || ipod - , android: android - , mobile: mobile } + 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 @@ -112,10 +114,8 @@ , webkit: t , 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 = getVersion(ua, webkitVersion, 1) @@ -178,13 +178,33 @@ , version: getVersion(ua, webkitVersion, 1) } + var osVersion; + if (android) { + osVersion = getVersion(ua, /android[ \/](\d+(\.\d+)*)/i, 1); + if (osVersion) { + o.osversion = osVersion; + } + } 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; + } + } + // Graded Browser Support // http://developer.yahoo.com/yui/articles/gbs if ((o.msie && o.version >= 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; } @@ -192,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 diff --git a/bowser.min.js b/bowser.min.js index 16a74c5..ff8f7ff 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2013 */ -!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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=/mobile/i.test(r),N={};return f&&(u=!1),w?N={name:"Windows Phone",windowsphone:e,mobile:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)}:d?(t=n(r,S,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),N={name:"Opera",opera:e,version:t},p&&(N.android=e,N.mobile=e),s&&(N.webkit=e)):i?N={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)}:s?N={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios)\/(\d+(\.\d+)?)/i,1),ipad:a,iphone:u,ipod:f,ios:u||a||f,android:p,mobile:T}:o?N={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?N={name:"TouchPad",webkit:e,touchpad:e,version:n(r,/touchpad\/(\d+(\.\d+)?)/i,1)}:c?N={name:"Amazon Silk",webkit:e,android:e,mobile:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(N={name:u?"iPhone":a?"iPad":"iPod",webkit:e,mobile:e,ios:e,iphone:u,ipad:a,ipod:f},S.test(r)&&(N.version=n(r,S,1))):E?(N={name:"BlackBerry",blackberry:e,mobile:e},(t=n(r,S,1))?(N.version=t,N.webkit=e):N.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):b?N={name:"WebOS",mobile:e,webkit:e,webos:e,version:n(r,S,1)||n(r,/wosbrowser\/(\d+(\.\d+)?)/i,1)}:g?(N={name:"Gecko",gecko:e,mozilla:e,version:n(r,x,1)},y?(N.name="SeaMonkey",N.seamonkey=e,N.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):m&&(N.name="Firefox",N.firefox=e),p?(N.android=e,N.mobile=e):!p&&m&&/\((mobile|tablet);.*rv:[\d\.]+\)/i.test(r)&&(N.firefoxos=e,N.mobile=e)):p?N={name:"Android",webkit:e,android:e,mobile:e,version:n(r,S,1)}:h&&(N={name:"Safari",webkit:e,safari:e,version:n(r,S,1)}),N.msie&&N.version>=9||N.chrome&&N.version>=20||N.firefox&&N.version>=10||N.safari&&N.version>=5||N.opera&&N.version>=10?N.a=e:N.msie&&N.version<9||N.chrome&&N.version<20||N.firefox&&N.version<10||N.safari&&N.version<5||N.opera&&N.version<10?N.c=e:N.x=e,N}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) \ No newline at end of file +!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=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}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index f641b7f..a7ac6c4 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -36,7 +36,6 @@ , blackberry = /blackberry/i.test(ua) , webkitVersion = /version\/(\d+(\.\d+)?)/i , firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i - , mobile = /mobile/i.test(ua) , o = {} if (ipod) iphone = false @@ -44,6 +43,7 @@ if (windowsphone) o = { name: 'Windows Phone' , windowsphone: t + , msie: t , mobile: t , version: getVersion(ua, /iemobile\/(\d+(\.\d+)?)/i, 1) } @@ -69,18 +69,20 @@ , msie: t , version: getVersion(ua, /(msie |rv:)(\d+(\.\d+)?)/i, 2) } - else if (chrome) o = { + else if (chrome) { + o = { name: 'Chrome' , webkit: t , chrome: t , version: getVersion(ua, /(?:chrome|crios)\/(\d+(\.\d+)?)/i, 1) - , ipad: ipad - , iphone: iphone - , ipod: ipod - , ios: iphone || ipad || ipod - , android: android - , mobile: mobile } + 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 @@ -106,10 +108,8 @@ , webkit: t , 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 = getVersion(ua, webkitVersion, 1) @@ -172,13 +172,33 @@ , version: getVersion(ua, webkitVersion, 1) } + var osVersion; + if (android) { + osVersion = getVersion(ua, /android[ \/](\d+(\.\d+)*)/i, 1); + if (osVersion) { + o.osversion = osVersion; + } + } 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; + } + } + // Graded Browser Support // http://developer.yahoo.com/yui/articles/gbs if ((o.msie && o.version >= 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; } @@ -186,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 diff --git a/src/useragents.js b/src/useragents.js index dc908cf..414758b 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -9,11 +9,8 @@ module.exports.useragents = { Chrome: { '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 - , ipad: false - , iphone: false - , ipod: false - , ios: false , android: true + , osversion: '4.3' , mobile: true , version: '32.0' , webkit: true @@ -21,11 +18,8 @@ module.exports.useragents = { } , '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 - , ipad: false - , iphone: false - , ipod: false - , ios: false , android: true + , osversion: '4.1' , mobile: true , version: '18.0' , webkit: true @@ -33,11 +27,9 @@ module.exports.useragents = { } , '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 - , ipad: false , iphone: true - , ipod: false , ios: true - , android: false + , osversion: '5.1.1' , mobile: true , version: '19.0' , webkit: true @@ -46,10 +38,8 @@ module.exports.useragents = { , '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 - , iphone: false - , ipod: false , ios: true - , android: false + , osversion: '5.1.1' , mobile: true , version: '19.0' , webkit: true @@ -57,84 +47,42 @@ module.exports.useragents = { } , '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 - , ipod: false - , ios: false - , android: 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 - , ipod: false - , ios: false - , android: 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 - , ipod: false - , ios: false - , android: 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 - , ipod: false - , ios: false - , android: 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 - , ipod: false - , ios: false - , android: 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 - , ipod: false - , ios: false - , android: 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 - , ipod: false - , ios: false - , android: false - , mobile: false , version: '6.0' , webkit: true , c: true @@ -155,6 +103,7 @@ module.exports.useragents = { opera: true , webkit: true , android: true + , osversion: '4.3' , mobile: true , version: '19.0' , a: true @@ -169,6 +118,7 @@ module.exports.useragents = { opera: true , version: '12.10' , android: true + , osversion: '4.3' , mobile: true , a: true } @@ -273,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 @@ -467,42 +422,44 @@ module.exports.useragents = { } } , 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 @@ -511,75 +468,67 @@ 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: 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: 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: 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: true , webkit: true - , x: 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' - , iphone: false - , ipad: false , ipod: true , mobile: true , webkit: true - , x: 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' - , iphone: false - , ipad: false , ipod: true , mobile: true , webkit: true - , x: 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' - , iphone: false - , ipad: false , ipod: true , mobile: true , webkit: true @@ -615,23 +564,37 @@ module.exports.useragents = { } } , 'Windows Phone': { - 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)': { + '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 - , x: 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 - , x: 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 - , x: true + , c: true } } , WebOS: { @@ -646,6 +609,7 @@ module.exports.useragents = { , 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 @@ -653,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 From 5aeeb687461583e17ab37cb6adff4a5fee8c9fcd Mon Sep 17 00:00:00 2001 From: BendingBender Date: Fri, 21 Feb 2014 15:09:58 +0100 Subject: [PATCH 09/10] updated readme --- README.md | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1cf4620..4087054 100644 --- a/README.md +++ b/README.md @@ -10,28 +10,35 @@ if (bowser.msie && bowser.version <= 6) { } ``` -Detected Browsers +Detected Browsers[Engines] +----- + + * chrome[webkit] + * firefox[gecko] + * msie + * opera[webkit if >12] + * phantomjs[webkit] + * safari[webkit] + * seamonkey[gecko] + * touchpad[webkit] + +Detected mobile operating systems ----- * android - * blackberry - * chrome[webkit] - * firefox[gecko] - * ipad - * iphone - * ipod - * msie - * opera - * phantomjs - * safari[webkit] - * seamonkey - * touchpad - * webos * 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) { From ffd340c62b6ea000209dc3eb00fd1b0f39da597f Mon Sep 17 00:00:00 2001 From: BendingBender Date: Sat, 22 Feb 2014 00:48:51 +0100 Subject: [PATCH 10/10] marginally improved regex to detect firefoxos --- bowser.js | 2 +- bowser.min.js | 2 +- src/bowser.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bowser.js b/bowser.js index 3baf3aa..3a5a4ee 100644 --- a/bowser.js +++ b/bowser.js @@ -159,7 +159,7 @@ if (android) { o.android = t o.mobile = t - } else if (!android && firefox && /\((mobile|tablet);.*rv:[\d\.]+\)/i.test(ua)) { + } else if (!android && firefox && /\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) { o.firefoxos = t o.mobile = t } diff --git a/bowser.min.js b/bowser.min.js index f457e5f..82c2627 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -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(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}) \ No newline at end of file +!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}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index 382605c..8ec22dc 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -153,7 +153,7 @@ if (android) { o.android = t o.mobile = t - } else if (!android && firefox && /\((mobile|tablet);.*rv:[\d\.]+\)/i.test(ua)) { + } else if (!android && firefox && /\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) { o.firefoxos = t o.mobile = t }