From 8148486edff783460e0ddf344bac4b6244bd46ad Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sat, 7 May 2016 16:10:02 +0300 Subject: [PATCH 01/16] fix ignoring idea and node_modules dirs --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f95e122..188100f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -node_modules -.idea +node_modules/ +.idea/ /bowser.js /bowser.min.js From 197c203e1165f5740fe93dea38a287bfb1a461c9 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sat, 7 May 2016 18:55:19 +0300 Subject: [PATCH 02/16] fix Safari browser name on iOS --- src/bowser.js | 24 ++-- src/useragents.js | 293 ++++++++++++++++++++++++---------------------- 2 files changed, 164 insertions(+), 153 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index 0a40659..99da71c 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -117,15 +117,6 @@ , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i) } } - else if (iosdevice) { - result = { - name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod' - } - // WTF: version is not part of user agent in web apps - if (versionIdentifier) { - result.version = versionIdentifier - } - } else if (sailfish) { result = { name: 'Sailfish' @@ -206,11 +197,22 @@ , version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier } } - else if (/safari/i.test(ua)) { + else if (/safari|applewebkit/i.test(ua)) { result = { name: 'Safari' , safari: t - , version: versionIdentifier + } + if (versionIdentifier) { + result.version = versionIdentifier + } + } + else if (iosdevice) { + result = { + name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod' + } + // WTF: version is not part of user agent in web apps + if (versionIdentifier) { + result.version = versionIdentifier } } else if(/googlebot/i.test(ua)) { diff --git a/src/useragents.js b/src/useragents.js index 884b52f..fd8d782 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -349,7 +349,158 @@ module.exports.useragents = { , webkit: true , c: true } + , '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 + , osversion: '7.0.4' + , iphone: true + , mobile: true + , webkit: true + , safari: 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 + , safari: 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 + , mobile: true + , webkit: true + , safari: true + , c: 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 + , mobile: true + , webkit: true + , safari: 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 + , mobile: true + , webkit: true + , safari: true + , c: true + } + , 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_0 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A344 Safari/601.1': { + ios: true + , osversion: '9.0' + , version: '9.0' + , iphone: true + , mobile: true + , webkit: true + , safari: true + , a: true + } + , 'Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53': { + ios: true + , osversion: '7.0.4' + , name: 'Safari' + , version: '7.0' + , ipad: true + , tablet: true + , webkit: true + , safari: true + , a: true + } + , '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: 'Safari' + , version: '6.0' + , ipad: true + , tablet: true + , webkit: true + , safari: 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: 'Safari' + , version: '5.1' + , ipad: true + , tablet: true + , webkit: true + , safari: 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: 'Safari' + , version: '5.0' + , ipad: true + , tablet: true + , webkit: true + , safari: 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: 'Safari' + , version: '4.0' + , ipad: true + , tablet: true + , webkit: true + , safari: true + , c: true + } + , 'Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53': { + ios: true + , osversion: '7.0.3' + , version: '7.0' + , ipod: true + , mobile: true + , webkit: true + , safari: true + , a: true + } + , 'Mozilla/5.0 (iPod; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3': { + ios: true + , osversion: '5.1' + , version: '5.1' + , ipod: true + , mobile: true + , webkit: true + , safari: true + , c: true + } + , 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5': { + ios: true + , osversion: '4.3.3' + , version: '5.0' + , ipod: true + , mobile: true + , webkit: true + , safari: true + , c: true + } + , 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3': { + ios: true + , version: '3.0' + , ipod: true + , mobile: true + , webkit: true + , safari: true + , c: true + } + } , 'Internet Explorer': { 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; MAARJS; rv:11.0) like Gecko': { msie: true @@ -588,148 +739,6 @@ module.exports.useragents = { , x: true } } - , iPhone: { - '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 - , osversion: '7.0.4' - , iphone: true - , mobile: true - , webkit: 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 - , 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 - , mobile: true - , webkit: 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 - , mobile: true - , webkit: true - , x: true - } - , 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_0 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A344 Safari/601.1': { - ios: true - , osversion: '9.0' - , version: '9.0' - , iphone: true - , mobile: true - , webkit: true - , a: true - } - } - , iPad: { - 'Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53': { - ios: true - , osversion: '7.0.4' - , name: 'iPad' - , version: '7.0' - , ipad: true - , tablet: true - , webkit: true - , a: true - } - , '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' - , ipad: true - , tablet: true - , webkit: 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' - , ipad: true - , tablet: true - , webkit: 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' - , ipad: true - , tablet: true - , webkit: 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' - , ipad: true - , tablet: true - , webkit: true - , c: true - } - } - , iPod: { - 'Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53': { - ios: true - , osversion: '7.0.3' - , version: '7.0' - , ipod: true - , mobile: true - , webkit: true - , a: true - } - , 'Mozilla/5.0 (iPod; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3': { - ios: true - , osversion: '5.1' - , version: '5.1' - , ipod: true - , mobile: true - , webkit: true - , c: true - } - , 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5': { - ios: true - , osversion: '4.3.3' - , version: '5.0' - , ipod: true - , mobile: true - , webkit: true - , c: true - } - , 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3': { - ios: true - , version: '3.0' - , ipod: true - , mobile: true - , webkit: true - , x: true - } - } , BlackBerry: { 'Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.1.0.4633 Mobile Safari/537.10+': { blackberry: true From 62745525dfd824ea7b15641360276a6379ec9711 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 8 May 2016 14:24:36 +0300 Subject: [PATCH 03/16] add support firefox for iOS --- src/bowser.js | 6 +++--- src/useragents.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index 99da71c..c0e0825 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -47,7 +47,7 @@ , mobile = !tablet && /[^-]mobi/i.test(ua) , result - if (/opera|opr/i.test(ua)) { + if (/opera|opr|opios/i.test(ua)) { result = { name: 'Opera' , opera: t @@ -131,11 +131,11 @@ , version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i) } } - else if (/firefox|iceweasel/i.test(ua)) { + else if (/firefox|iceweasel|fxios/i.test(ua)) { result = { name: 'Firefox' , firefox: t - , version: getFirstMatch(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i) + , version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i) } if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) { result.firefoxos = t diff --git a/src/useragents.js b/src/useragents.js index fd8d782..77049f5 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -715,7 +715,17 @@ module.exports.useragents = { , linux: true , c: true } + , 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) FxiOS/3.0 Mobile/13E238 Safari/601.1.46': { + firefox: true + , version: '3.0' + , osversion: '9.3.1' + , ios: true + , iphone: true + , mobile: true + , a: true + , webkit: true } + } , SeaMonkey: { 'Mozilla/5.0 (Windows NT 5.2; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 SeaMonkey/2.7.1': { gecko: true From 35f635b845c678af7ef46c8070bfb3a77e5c9ed1 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 8 May 2016 14:27:24 +0300 Subject: [PATCH 04/16] add iOS Safari and Chrome to the tests --- src/useragents.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/useragents.js b/src/useragents.js index 77049f5..49f42cf 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -131,6 +131,16 @@ module.exports.useragents = { , webkit: true , c: true } + , 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/50.0.2661.95 Mobile/13E238 Safari/601.1.46': { + chrome: true + , version: '50.0' + , osversion: '9.3.1' + , webkit: true + , ios: true + , iphone: true + , mobile: true + , a: true + } } , 'Amazon Silk': { 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true': { @@ -500,6 +510,16 @@ module.exports.useragents = { , safari: true , c: true } + , 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E238 Safari/601.1': { + ios: true + , iphone: true + , safari: true + , version: '9.0' + , mobile: true + , osversion: '9.3.1' + , a: true + , webkit: true + } } , 'Internet Explorer': { 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; MAARJS; rv:11.0) like Gecko': { From e55dd78792e482b241b3b5ee51155cf89047894b Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 8 May 2016 14:37:10 +0300 Subject: [PATCH 05/16] add support of Maxthon browser on iOS --- src/bowser.js | 9 ++++++++- src/useragents.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/bowser.js b/src/bowser.js index c0e0825..fb8f3eb 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -68,6 +68,13 @@ , version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i) } } + else if (/mxios/i.test(ua)) { + result = { + name: 'Maxthon' + , maxthon: t + , version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i) + } + } else if (windowsphone) { result = { name: 'Windows Phone' @@ -291,7 +298,7 @@ if (result.msedge || (result.msie && result.version >= 10) || (result.yandexbrowser && result.version >= 15) || - (result.vivaldi && result.version >= 1.0) || + (result.vivaldi && result.version >= 1.0) || (result.chrome && result.version >= 20) || (result.firefox && result.version >= 20.0) || (result.safari && result.version >= 6) || diff --git a/src/useragents.js b/src/useragents.js index 49f42cf..ec27910 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -1145,4 +1145,16 @@ module.exports.useragents = { x: true } } + , 'Maxthon': { + 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E238 Safari/601.1 MXiOS/4.8.6.59': { + mobile: true + , ios: true + , iphone: true + , version: '4.8.6.59' + , osversion: '9.3.1' + , webkit: true + , maxthon: true + , a: true + } + } } From 0b120a860ceed0226d6c014a8dca6354cd4bae7c Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 8 May 2016 14:41:55 +0300 Subject: [PATCH 06/16] add tests for UC Browser on iOS --- src/useragents.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/useragents.js b/src/useragents.js index ec27910..d373dba 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -1128,6 +1128,16 @@ module.exports.useragents = { webkit: true, x: true } + , 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X; en-US) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/13E238 UCBrowser/10.7.0.782 Mobile': { + iphone: true + , ios: true + , mobile: true + , osversion: '9.3.1' + , version: '10.7.0.782' + , webkit: true + , a: true + , ucbrowser: true + } } , "QupZilla": { 'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) QupZilla/1.8.2 Safari/538.1': { From 4ac5b4e14d409d26deb5af6e0c63e25c2350643e Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 8 May 2016 14:58:18 +0300 Subject: [PATCH 07/16] add Opera Coast detection fix #133 --- src/bowser.js | 9 ++++++++- src/useragents.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/bowser.js b/src/bowser.js index fb8f3eb..37a0cd8 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -51,7 +51,14 @@ result = { name: 'Opera' , opera: t - , version: versionIdentifier || getFirstMatch(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i) + , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i) + } + } + else if (/coast/i.test(ua)) { + result = { + name: 'Opera Coast' + , coast: t + , version: versionIdentifier || getFirstMatch(/(?:coast)[\s\/](\d+(\.\d+)?)/i) } } else if (/yabrowser/i.test(ua)) { diff --git a/src/useragents.js b/src/useragents.js index d373dba..d90f722 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -290,7 +290,19 @@ module.exports.useragents = { , linux: true , c: true } + } + , 'Opera Coast': { + 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Coast/5.02.99991 Mobile/13E238 Safari/7534.48.3': { + coast: true + , version: '5.02' + , osversion: '9.3.1' + , iphone: true + , ios: true + , mobile: true + , a: true + , webkit: true } + } , 'Yandex Browser': { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 YaBrowser/15.4.2272.3420 (beta) Yowser/2.0 Safari/537.36': { yandexbrowser: true From d6fb6d53589720f2c1282507cbf81a64f31cd0b9 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 8 May 2016 15:08:19 +0300 Subject: [PATCH 08/16] fix order: Chrome should be almost lowest, but before Safari --- src/bowser.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index 37a0cd8..b2bbe8c 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -117,18 +117,11 @@ , version: edgeVersion } } - else if (/vivaldi/i.test(ua)) { - result = { - name: 'Vivaldi' - , vivaldi: t - , version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier - } - } - else if (/chrome|crios|crmo/i.test(ua)) { + else if (/vivaldi/i.test(ua)) { result = { - name: 'Chrome' - , chrome: t - , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i) + name: 'Vivaldi' + , vivaldi: t + , version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier } } else if (sailfish) { @@ -162,12 +155,6 @@ , version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i) } } - else if (android) { - result = { - name: 'Android' - , version: versionIdentifier - } - } else if (/phantom/i.test(ua)) { result = { name: 'PhantomJS' @@ -211,6 +198,19 @@ , version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier } } + else if (/chrome|crios|crmo/i.test(ua)) { + result = { + name: 'Chrome' + , chrome: t + , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i) + } + } + else if (android) { + result = { + name: 'Android' + , version: versionIdentifier + } + } else if (/safari|applewebkit/i.test(ua)) { result = { name: 'Safari' From 40fc55f393c03663605c0632e472bdb58ce53144 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 09:05:59 +0300 Subject: [PATCH 09/16] add `blink` flag when we can suppose it fix #134 --- src/bowser.js | 9 ++++++-- src/useragents.js | 58 +++++++++++++++++++++++------------------------ 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index b2bbe8c..eb0c5a6 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -245,8 +245,13 @@ // set webkit or gecko flag for browsers based on these engines if (!result.msedge && /(apple)?webkit/i.test(ua)) { - result.name = result.name || "Webkit" - result.webkit = t + if (/(apple)?webkit\/537\.36/i.test(ua)) { + result.name = result.name || "Blink" + result.blink = t + } else { + result.name = result.name || "Webkit" + result.webkit = t + } if (!result.version && versionIdentifier) { result.version = versionIdentifier } diff --git a/src/useragents.js b/src/useragents.js index d90f722..26eb0b9 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -13,7 +13,7 @@ module.exports.useragents = { , osversion: '5.1.1' , tablet: true , version: '47.0' - , webkit: true + , blink: true , a: true } , 'Mozilla/5.0 (Linux; Android 4.4.2; Nexus 7 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Safari/537.36': { @@ -22,7 +22,7 @@ module.exports.useragents = { , osversion: '4.4.2' , tablet: true , version: '32.0' - , webkit: true + , blink: true , a: true } , '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': { @@ -31,7 +31,7 @@ module.exports.useragents = { , osversion: '4.3' , mobile: true , version: '32.0' - , webkit: true + , blink: 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': { @@ -85,14 +85,14 @@ module.exports.useragents = { chrome: true , version: '30.0' , windows: true - , webkit: true + , blink: 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 , version: '29.0' , windows: true - , webkit: true + , blink: 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': { @@ -100,21 +100,21 @@ module.exports.useragents = { , chromeBook: true , version: '29.0' , chromeos: true - , webkit: true + , blink: 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 , version: '29.0' , windows: true - , webkit: true + , blink: 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 , version: '28.0' , windows: true - , webkit: true + , blink: 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': { @@ -185,7 +185,7 @@ module.exports.useragents = { , Opera: { 'Mozilla/5.0 (Linux; Android 4.4.2; Nexus 7 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.72 Safari/537.36 OPR/19.0.1340.69721': { opera: true - , webkit: true + , blink: true , android: true , osversion: '4.4.2' , tablet: true @@ -194,7 +194,7 @@ module.exports.useragents = { } , '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 + , blink: true , android: true , osversion: '4.3' , mobile: true @@ -204,7 +204,7 @@ module.exports.useragents = { , '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 , windows: true - , webkit: true + , blink: true , version: '15.0' , a: true } @@ -304,22 +304,22 @@ module.exports.useragents = { } } , 'Yandex Browser': { - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 YaBrowser/15.4.2272.3420 (beta) Yowser/2.0 Safari/537.36': { - yandexbrowser: true - , webkit: true - , version: '15.4' - , mac: true - , a: true - }, - 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 YaBrowser/15.4.2272.3608.00 Mobile Safari/537.36': { - yandexbrowser: true - , android: true - , osversion: '5.1.1' - , mobile: true - , version: '15.4' - , webkit: true - , a: true - } + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 YaBrowser/15.4.2272.3420 (beta) Yowser/2.0 Safari/537.36': { + yandexbrowser: true + , blink: true + , version: '15.4' + , mac: true + , a: true + }, + 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 YaBrowser/15.4.2272.3608.00 Mobile Safari/537.36': { + yandexbrowser: true + , android: true + , osversion: '5.1.1' + , mobile: true + , version: '15.4' + , blink: true + , a: true + } } , Safari: { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2': { @@ -1095,14 +1095,14 @@ module.exports.useragents = { vivaldi: true , version: '1.0' , mac: true - , webkit: true + , blink: true , a: true }, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36 Vivaldi/1.0.303.52': { vivaldi: true , version: '1.0' , windows: true - , webkit: true + , blink: true , a: true } } From b9edb72e2f64bf4c08fedc8072f90e87414ee12a Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 09:17:46 +0300 Subject: [PATCH 10/16] add Epiphany browser fix #130 --- src/bowser.js | 7 +++++++ src/useragents.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/bowser.js b/src/bowser.js index eb0c5a6..2911fe3 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -82,6 +82,13 @@ , version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i) } } + else if (/epiphany/i.test(ua)) { + result = { + name: 'Epiphany' + , epiphany: t + , version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i) + } + } else if (windowsphone) { result = { name: 'Windows Phone' diff --git a/src/useragents.js b/src/useragents.js index 26eb0b9..9b56e38 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -1179,4 +1179,13 @@ module.exports.useragents = { , a: true } } + , 'Epiphany': { + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) Version/8.0 Safari/602.1 Debian/buildd-unstable (3.18.5-1) Epiphany/3.18.5': { + epiphany: true + , x: true + , webkit: true + , version: '3.18.5' + , linux: true + } + } } From 78ee04fa376578048a13694d4af04bd0cf39bdd0 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 09:44:04 +0300 Subject: [PATCH 11/16] fix Android tablet detection fix #136 --- src/bowser.js | 19 +++++++++++++++++-- src/useragents.js | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index 2911fe3..50ed7ce 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -306,9 +306,24 @@ // device type extraction var osMajorVersion = osVersion.split('.')[0]; - if (tablet || nexusTablet || iosdevice == 'ipad' || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || result.silk) { + if ( + tablet + || nexusTablet + || iosdevice == 'ipad' + || (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile))) + || result.silk + ) { result.tablet = t - } else if (mobile || iosdevice == 'iphone' || iosdevice == 'ipod' || android || nexusMobile || result.blackberry || result.webos || result.bada) { + } else if ( + mobile + || iosdevice == 'iphone' + || iosdevice == 'ipod' + || android + || nexusMobile + || result.blackberry + || result.webos + || result.bada + ) { result.mobile = t } diff --git a/src/useragents.js b/src/useragents.js index 9b56e38..bc119af 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -141,6 +141,24 @@ module.exports.useragents = { , mobile: true , a: true } + , 'Mozilla/5.0 (Linux; Android 5.0.2; SM-T705 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.105 Safari/537.36': { + chrome: true + , android: true + , version: '49.0' + , osversion: '5.0.2' + , blink: true + , a: true + , tablet: true + } + , 'Mozilla/5.0 (Linux; Android 6.0.99; Build/NPC91K) AppleWebKit/537.36(KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36': { + chrome: true + , android: true + , tablet: true + , osversion: '6.0.99' + , version: '50.0' + , blink: true + , a: true + } } , 'Amazon Silk': { 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true': { From 891f98100f1b0ab7fed15596f6c404c7671ca846 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 10:02:04 +0300 Subject: [PATCH 12/16] add Puffin detection fix #68 --- src/bowser.js | 7 +++++++ src/useragents.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/bowser.js b/src/bowser.js index 50ed7ce..985dd14 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -89,6 +89,13 @@ , version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i) } } + else if (/puffin/i.test(ua)) { + result = { + name: 'Puffin' + , puffin: t + , version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i) + } + } else if (windowsphone) { result = { name: 'Windows Phone' diff --git a/src/useragents.js b/src/useragents.js index bc119af..f1832c9 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -1206,4 +1206,13 @@ module.exports.useragents = { , linux: true } } + , 'Puffin': { + 'Mozilla/5.0 (X11; U; Linux x86_64; zh-TW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.114 Safari/537.36 Puffin/3.7.0IT': { + linux: true + , blink: true + , puffin: true + , version: '3.7' + , x: true + } + } } From 277202172b8821e4e9c3cee731de94b90f55c627 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 10:18:11 +0300 Subject: [PATCH 13/16] add some browsers from #73 fix #73 --- README.md | 2 ++ src/bowser.js | 14 ++++++++++++++ src/useragents.js | 17 +++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/README.md b/README.md index 7eaf30b..29defe8 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ If detected, one of these flags may be set to true. The rendering engine flag i * `ucbrowser` — [`webkit`] * `qupzilla` — [`webkit`] * `vivaldi` — [`webkit`] + * `sleipnir` — [`blink`] + * `kMeleon` — [`gecko`] For all detected browsers the browser version is set in the `version` field. diff --git a/src/bowser.js b/src/bowser.js index 985dd14..08d9a86 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -96,6 +96,20 @@ , version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i) } } + else if (/sleipnir/i.test(ua)) { + result = { + name: 'Sleipnir' + , sleipnir: t + , version: getFirstMatch(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i) + } + } + else if (/k-meleon/i.test(ua)) { + result = { + name: 'K-Meleon' + , kMeleon: t + , version: getFirstMatch(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i) + } + } else if (windowsphone) { result = { name: 'Windows Phone' diff --git a/src/useragents.js b/src/useragents.js index f1832c9..1d39f2b 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -1214,5 +1214,22 @@ module.exports.useragents = { , version: '3.7' , x: true } + }, 'Sleipnir': { + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 Sleipnir/6.1.4': { + sleipnir: true + , blink: true + , windows: true + , x: true + , version: '6.1.4' + } + } + , 'K-Meleon': { + 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20140105 Firefox/24.0 K-Meleon/74.0': { + windows: true + , kMeleon: true + , version: '74.0' + , gecko: true + , x: true + } } } From 5321a33cbe1e4db11b016f1e3c02d1f441710552 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 10:24:55 +0300 Subject: [PATCH 14/16] add blink to Readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 29defe8..ba35d58 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ For unknown browsers, Bowser makes a best guess from the UA string. So, these m ### Rendering engine flags If detected, one of these flags may be set to true: - * `webkit` - Chrome, Android, iOs, BB, etc. + * `webkit` - Chrome 0-27, Android <4.4, iOs, BB, etc. + * `blink` - Chrome >=28, Android >=4.4, Opera, etc. * `gecko` - Firefox, etc. * `msie` - IE <= 11 * `msedge` - IE > 11 @@ -59,14 +60,14 @@ If detected, one of these flags may be set to true: ### Browser flags If detected, one of these flags may be set to true. The rendering engine flag is shown in []'s: - * `chrome` - [`webkit`] + * `chrome` - [`webkit`|`blink`] * `firefox` - [`gecko`] * `msie` * `msedge` * `safari` - [`webkit`] - * `android` - native browser - [`webkit`] + * `android` - native browser - [`webkit`|`blink`] * `ios` - native browser - [`webkit`] - * `opera` - [`webkit` if >12] + * `opera` - [`blink` if >=15] * `phantom` - [`webkit`] * `blackberry` - native browser - [`webkit`] * `webos` - native browser - [`webkit`] @@ -77,7 +78,7 @@ If detected, one of these flags may be set to true. The rendering engine flag i * `sailfish` - [`gecko`] * `ucbrowser` — [`webkit`] * `qupzilla` — [`webkit`] - * `vivaldi` — [`webkit`] + * `vivaldi` — [`blink`] * `sleipnir` — [`blink`] * `kMeleon` — [`gecko`] From 542277ceb74fd55a31f6fc3c32aaf3bac476a864 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 10:40:47 +0300 Subject: [PATCH 15/16] add Xbox detection #fix 139 --- src/bowser.js | 7 +++++-- src/useragents.js | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index 08d9a86..be555e0 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -45,6 +45,7 @@ , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i) , tablet = /tablet/i.test(ua) , mobile = !tablet && /[^-]mobi/i.test(ua) + , xbox = /xbox/i.test(ua) , result if (/opera|opr|opios/i.test(ua)) { @@ -295,10 +296,12 @@ } else if (iosdevice) { result[iosdevice] = t result.ios = t - } else if (windows) { - result.windows = t } else if (mac) { result.mac = t + } else if (xbox) { + result.xbox = t + } else if (windows) { + result.windows = t } else if (linux) { result.linux = t } diff --git a/src/useragents.js b/src/useragents.js index 1d39f2b..3d16b84 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -624,6 +624,12 @@ module.exports.useragents = { , windows: true , c: true } + , 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Xbox; Xbox One)': { + xbox: true + , msie: true + , version: '10.0' + , a: true + } } , 'Microsoft Edge': { 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0': { From 92b7c4577aea6c985b8d6499e1edfbf4e9d9b155 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 9 May 2016 10:52:58 +0300 Subject: [PATCH 16/16] version bump --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 3cecbb0..870f0da 100644 --- a/bower.json +++ b/bower.json @@ -7,7 +7,7 @@ "sniff", "detection" ], - "version": "1.1.1", + "version": "1.2.0", "homepage": "https://github.com/ded/bowser", "scripts": [ "src/bowser.js" diff --git a/package.json b/package.json index 79e595d..5b2d61e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "sniff", "detection" ], - "version": "1.1.1", + "version": "1.2.0", "homepage": "https://github.com/ded/bowser", "author": "Dustin Diaz (http://dustindiaz.com)", "main": "./src/bowser.js",