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

added tests and detection for mobile firefox and mobile chrome

This commit is contained in:
BendingBender 2014-02-21 00:02:13 +01:00
parent 4fdd74d05a
commit 4acca40a99
4 changed files with 136 additions and 41 deletions

View File

@ -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

2
bowser.min.js vendored
View File

@ -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})
!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})

View File

@ -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

View File

@ -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