mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge branch 'release/1.1.0'
This commit is contained in:
commit
32c86b878e
17
.editorconfig
Normal file
17
.editorconfig
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[{*.js,*.md}]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[{package.json,.travis.yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
.idea
|
||||||
|
/bowser.js
|
||||||
|
/bowser.min.js
|
||||||
|
3
.npmignore
Normal file
3
.npmignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
make
|
||||||
|
src/useragents.js
|
||||||
|
Makefile
|
136
README.md
136
README.md
@ -11,52 +11,38 @@ if (bowser.msie && bowser.version <= 6) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 1.1.0 breaking changes
|
||||||
|
We don't save built script in the repo anymore. The main file (`src/bowser.js`) is available through NPM or Bower.
|
||||||
|
Also you can download minified file from [the release page](https://github.com/ded/bowser/releases).
|
||||||
|
|
||||||
## 1.0.0 breaking changes
|
## 1.0.0 breaking changes
|
||||||
`browser = require('bowser').browser;` becomes `browser = require('bowser');`
|
`browser = require('bowser').browser;` becomes `browser = require('bowser');`
|
||||||
|
|
||||||
## Flags set for detected Browsers[Engines]
|
## Bowser Flags
|
||||||
|
Your mileage may vary, but these flags should be set. See Contributing below.
|
||||||
|
|
||||||
* `chrome`[`webkit`]
|
``` js
|
||||||
* `firefox`[`gecko`]
|
alert('Hello ' + bowser.name + ' ' + bowser.version);
|
||||||
* `msie`
|
```
|
||||||
* `msedge`
|
|
||||||
* Android native browser as `android`[`webkit`]
|
|
||||||
* iOS native browser as `ios`[`webkit`]
|
|
||||||
* `opera`[`webkit` if >12]
|
|
||||||
* `phantom`[`webkit`]
|
|
||||||
* `safari`[`webkit`]
|
|
||||||
* `seamonkey`[`gecko`]
|
|
||||||
* BlackBerry native browser as `blackberry`[`webkit`]
|
|
||||||
* WebOS native browser as `webos`[`webkit`]
|
|
||||||
* Amazon Kindle browser as `silk`[`webkit`]
|
|
||||||
* Bada browser as `bada`[`webkit`]
|
|
||||||
* Tizen browser as `tizen`[`webkit`]
|
|
||||||
* Sailfish browser as `sailfish`[`gecko`]
|
|
||||||
|
|
||||||
For all detected browsers the browser version is set in the `version` field.
|
### All detected browsers
|
||||||
|
These flags are set for all detected browsers:
|
||||||
|
|
||||||
## Flags set for detected Operating Systems
|
* `name` - A human readable name for this browser. E.g. 'Chrome', ''
|
||||||
|
* `version` - Version number for the browser. E.g. '32.0'
|
||||||
|
|
||||||
* `mac`
|
For unknown browsers, Bowser makes a best guess from the UA string. So, these may not be set.
|
||||||
* Windows other than Windows Phone as `windows`
|
|
||||||
* Windows Phone as `windowsphone`
|
|
||||||
* `linux` for Linux other than `android`, `chromeos`, `webos`, `tizen`, and `sailfish`
|
|
||||||
* `chromeos`
|
|
||||||
* `android`
|
|
||||||
* `ios` (`iphone`/`ipad`/`ipod`)
|
|
||||||
* `blackberry`
|
|
||||||
* `firefoxos`
|
|
||||||
* `webos` (`touchpad`)
|
|
||||||
* `bada`
|
|
||||||
* `tizen`
|
|
||||||
* `sailfish`
|
|
||||||
|
|
||||||
Android, iOS, Windows Phone, WebOS, Bada, and Tizen 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. If WebOS device is an HP TouchPad the flag `touchpad` is additionally set.
|
### Rendering engine flags
|
||||||
|
If detected, one of these flags may be set to true:
|
||||||
|
|
||||||
All detected mobile OSes are additionally flagged `mobile`, **if they are not powering a tablet device**. If a tablet device is detected, the flag `tablet` is set instead.
|
* `webkit` - Chrome, Android, iOs, BB, etc.
|
||||||
|
* `gecko` - Firefox, etc.
|
||||||
|
* `msie` - IE <= 11
|
||||||
|
* `msedge` - IE > 11
|
||||||
|
|
||||||
### Notes
|
Safari, Chrome and some other minor browsers will report that they have `webkit` 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.
|
Firefox and Seamonkey will report that they have `gecko` engines.
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
if (bowser.webkit) {
|
if (bowser.webkit) {
|
||||||
@ -64,6 +50,70 @@ if (bowser.webkit) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Device flags
|
||||||
|
If detected, one of these flags may be set to true:
|
||||||
|
|
||||||
|
* `mobile` - All detected mobile OSes are additionally flagged `mobile`, **unless it's a tablet**
|
||||||
|
* `tablet` - If a tablet device is detected, the flag `tablet` is **set instead of `mobile`**.
|
||||||
|
|
||||||
|
### Browser flags
|
||||||
|
If detected, one of these flags may be set to true. The rendering engine flag is shown in []'s:
|
||||||
|
|
||||||
|
* `chrome` - [`webkit`]
|
||||||
|
* `firefox` - [`gecko`]
|
||||||
|
* `msie`
|
||||||
|
* `msedge`
|
||||||
|
* `safari` - [`webkit`]
|
||||||
|
* `android` - native browser - [`webkit`]
|
||||||
|
* `ios` - native browser - [`webkit`]
|
||||||
|
* `opera` - [`webkit` if >12]
|
||||||
|
* `phantom` - [`webkit`]
|
||||||
|
* `blackberry` - native browser - [`webkit`]
|
||||||
|
* `webos` - native browser - [`webkit`]
|
||||||
|
* `silk` - Amazon Kindle browser - [`webkit`]
|
||||||
|
* `bada` - [`webkit`]
|
||||||
|
* `tizen` - [`webkit`]
|
||||||
|
* `seamonkey` - [`gecko`]
|
||||||
|
* `sailfish` - [`gecko`]
|
||||||
|
* `ucbrowser` — [`webkit`]
|
||||||
|
* `qupzilla` — [`webkit`]
|
||||||
|
* `vivaldi` — [`webkit`]
|
||||||
|
|
||||||
|
For all detected browsers the browser version is set in the `version` field.
|
||||||
|
|
||||||
|
### OS Flags
|
||||||
|
If detected, one of these flags may be set to true:
|
||||||
|
|
||||||
|
* `mac`
|
||||||
|
* `windows` - other than Windows Phone
|
||||||
|
* `windowsphone`
|
||||||
|
* `linux` - other than `android`, `chromeos`, `webos`, `tizen`, and `sailfish`
|
||||||
|
* `chromeos`
|
||||||
|
* `android`
|
||||||
|
* `ios` - also sets one of `iphone`/`ipad`/`ipod`
|
||||||
|
* `blackberry`
|
||||||
|
* `firefoxos`
|
||||||
|
* `webos` - may also set `touchpad`
|
||||||
|
* `bada`
|
||||||
|
* `tizen`
|
||||||
|
* `sailfish`
|
||||||
|
|
||||||
|
`osversion` may also be set:
|
||||||
|
|
||||||
|
* `osversion` - for Android, iOS, Windows Phone, WebOS, Bada, and Tizen. If included in UA string.
|
||||||
|
|
||||||
|
iOS is always reported as `ios` and additionally as `iphone`/`ipad`/`ipod`, whichever one matches best.
|
||||||
|
If WebOS device is an HP TouchPad the flag `touchpad` is additionally set.
|
||||||
|
|
||||||
|
### Browser capability grading
|
||||||
|
One of these flags may be set:
|
||||||
|
|
||||||
|
* `a` - This browser has full capabilities
|
||||||
|
* `c` - This browser has degraded capabilities. Serve simpler version
|
||||||
|
* `x` - This browser has minimal capabilities and is probably not well detected.
|
||||||
|
|
||||||
|
There is no `b`. For unknown browsers, none of these flags may be set.
|
||||||
|
|
||||||
### Ender Support
|
### Ender Support
|
||||||
|
|
||||||
`package.json`
|
`package.json`
|
||||||
@ -80,20 +130,6 @@ if (require('bowser').chrome) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Graded Browser Support
|
|
||||||
|
|
||||||
``` js
|
|
||||||
if (bowser.a) {
|
|
||||||
// support full feature set
|
|
||||||
}
|
|
||||||
else if (bowser.c) {
|
|
||||||
// serve degraded version
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// unsupported (bowser.x)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Contributing
|
### Contributing
|
||||||
If you'd like to contribute a change to bowser, modify the files in `src/`, then run the following (you'll need node + npm installed):
|
If you'd like to contribute a change to bowser, modify the files in `src/`, then run the following (you'll need node + npm installed):
|
||||||
|
|
||||||
|
28
bower.json
Normal file
28
bower.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "bowser",
|
||||||
|
"description": "a browser detector",
|
||||||
|
"keywords": [
|
||||||
|
"ender",
|
||||||
|
"browser",
|
||||||
|
"sniff",
|
||||||
|
"detection"
|
||||||
|
],
|
||||||
|
"version": "1.1.0",
|
||||||
|
"homepage": "https://github.com/ded/bowser",
|
||||||
|
"scripts": [
|
||||||
|
"src/bowser.js"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
"Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)"
|
||||||
|
],
|
||||||
|
"moduleType": [],
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "src/bowser.js",
|
||||||
|
"ignore": [
|
||||||
|
"node_modules",
|
||||||
|
"test",
|
||||||
|
"make",
|
||||||
|
"**/.*",
|
||||||
|
"Makefile"
|
||||||
|
]
|
||||||
|
}
|
291
bowser.js
291
bowser.js
@ -1,291 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Bowser - a browser detector
|
|
||||||
* https://github.com/ded/bowser
|
|
||||||
* MIT License | (c) Dustin Diaz 2015
|
|
||||||
*/
|
|
||||||
|
|
||||||
!function (name, definition) {
|
|
||||||
if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
|
||||||
else if (typeof define == 'function' && define.amd) define(definition)
|
|
||||||
else this[name] = definition()
|
|
||||||
}('bowser', function () {
|
|
||||||
/**
|
|
||||||
* See useragents.js for examples of navigator.userAgent
|
|
||||||
*/
|
|
||||||
|
|
||||||
var t = true
|
|
||||||
|
|
||||||
function detect(ua) {
|
|
||||||
|
|
||||||
function getFirstMatch(regex) {
|
|
||||||
var match = ua.match(regex);
|
|
||||||
return (match && match.length > 1 && match[1]) || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSecondMatch(regex) {
|
|
||||||
var match = ua.match(regex);
|
|
||||||
return (match && match.length > 1 && match[2]) || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
|
||||||
, likeAndroid = /like android/i.test(ua)
|
|
||||||
, android = !likeAndroid && /android/i.test(ua)
|
|
||||||
, chromeBook = /CrOS/.test(ua)
|
|
||||||
, edgeVersion = getFirstMatch(/edge\/(\d+(\.\d+)?)/i)
|
|
||||||
, versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
|
|
||||||
, tablet = /tablet/i.test(ua)
|
|
||||||
, mobile = !tablet && /[^-]mobi/i.test(ua)
|
|
||||||
, result
|
|
||||||
|
|
||||||
if (/opera|opr/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Opera'
|
|
||||||
, opera: t
|
|
||||||
, version: versionIdentifier || getFirstMatch(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/yabrowser/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Yandex Browser'
|
|
||||||
, yandexbrowser: t
|
|
||||||
, version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/windows phone/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Windows Phone'
|
|
||||||
, windowsphone: t
|
|
||||||
}
|
|
||||||
if (edgeVersion) {
|
|
||||||
result.msedge = t
|
|
||||||
result.version = edgeVersion
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result.msie = t
|
|
||||||
result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/msie|trident/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Internet Explorer'
|
|
||||||
, msie: t
|
|
||||||
, version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
} else if (chromeBook) {
|
|
||||||
result = {
|
|
||||||
name: 'Chrome'
|
|
||||||
, chromeBook: t
|
|
||||||
, chrome: t
|
|
||||||
, version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
} else if (/chrome.+? edge/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Microsoft Edge'
|
|
||||||
, msedge: t
|
|
||||||
, version: edgeVersion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/chrome|crios|crmo/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Chrome'
|
|
||||||
, chrome: t
|
|
||||||
, 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/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Sailfish'
|
|
||||||
, sailfish: t
|
|
||||||
, version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/seamonkey\//i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'SeaMonkey'
|
|
||||||
, seamonkey: t
|
|
||||||
, version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/firefox|iceweasel/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Firefox'
|
|
||||||
, firefox: t
|
|
||||||
, version: getFirstMatch(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
|
|
||||||
result.firefoxos = t
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/silk/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Amazon Silk'
|
|
||||||
, silk: t
|
|
||||||
, version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (android) {
|
|
||||||
result = {
|
|
||||||
name: 'Android'
|
|
||||||
, version: versionIdentifier
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/phantom/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'PhantomJS'
|
|
||||||
, phantom: t
|
|
||||||
, version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'BlackBerry'
|
|
||||||
, blackberry: t
|
|
||||||
, version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (/(web|hpw)os/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'WebOS'
|
|
||||||
, webos: t
|
|
||||||
, version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)
|
|
||||||
};
|
|
||||||
/touchpad\//i.test(ua) && (result.touchpad = t)
|
|
||||||
}
|
|
||||||
else if (/bada/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Bada'
|
|
||||||
, bada: t
|
|
||||||
, version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (/tizen/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Tizen'
|
|
||||||
, tizen: t
|
|
||||||
, version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (/safari/i.test(ua)) {
|
|
||||||
result = {
|
|
||||||
name: 'Safari'
|
|
||||||
, safari: t
|
|
||||||
, version: versionIdentifier
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = {
|
|
||||||
name: getFirstMatch(/^(.*)\/(.*) /),
|
|
||||||
version: getSecondMatch(/^(.*)\/(.*) /)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 (!result.version && versionIdentifier) {
|
|
||||||
result.version = versionIdentifier
|
|
||||||
}
|
|
||||||
} else if (!result.opera && /gecko\//i.test(ua)) {
|
|
||||||
result.name = result.name || "Gecko"
|
|
||||||
result.gecko = t
|
|
||||||
result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i)
|
|
||||||
}
|
|
||||||
|
|
||||||
// set OS flags for platforms that have multiple browsers
|
|
||||||
if (!result.msedge && (android || result.silk)) {
|
|
||||||
result.android = t
|
|
||||||
} else if (iosdevice) {
|
|
||||||
result[iosdevice] = t
|
|
||||||
result.ios = t
|
|
||||||
}
|
|
||||||
|
|
||||||
// OS version extraction
|
|
||||||
var osVersion = '';
|
|
||||||
if (result.windowsphone) {
|
|
||||||
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
|
|
||||||
} else if (iosdevice) {
|
|
||||||
osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
|
|
||||||
osVersion = osVersion.replace(/[_\s]/g, '.');
|
|
||||||
} else if (android) {
|
|
||||||
osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
|
|
||||||
} else if (result.webos) {
|
|
||||||
osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
|
|
||||||
} else if (result.blackberry) {
|
|
||||||
osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i);
|
|
||||||
} else if (result.bada) {
|
|
||||||
osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i);
|
|
||||||
} else if (result.tizen) {
|
|
||||||
osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i);
|
|
||||||
}
|
|
||||||
if (osVersion) {
|
|
||||||
result.osversion = osVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
// device type extraction
|
|
||||||
var osMajorVersion = osVersion.split('.')[0];
|
|
||||||
if (tablet || iosdevice == 'ipad' || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || result.silk) {
|
|
||||||
result.tablet = t
|
|
||||||
} else if (mobile || iosdevice == 'iphone' || iosdevice == 'ipod' || android || result.blackberry || result.webos || result.bada) {
|
|
||||||
result.mobile = t
|
|
||||||
}
|
|
||||||
|
|
||||||
// Graded Browser Support
|
|
||||||
// http://developer.yahoo.com/yui/articles/gbs
|
|
||||||
if (result.msedge ||
|
|
||||||
(result.msie && result.version >= 10) ||
|
|
||||||
(result.yandexbrowser && result.version >= 15) ||
|
|
||||||
(result.chrome && result.version >= 20) ||
|
|
||||||
(result.firefox && result.version >= 20.0) ||
|
|
||||||
(result.safari && result.version >= 6) ||
|
|
||||||
(result.opera && result.version >= 10.0) ||
|
|
||||||
(result.ios && result.osversion && result.osversion.split(".")[0] >= 6) ||
|
|
||||||
(result.blackberry && result.version >= 10.1)
|
|
||||||
) {
|
|
||||||
result.a = t;
|
|
||||||
}
|
|
||||||
else if ((result.msie && result.version < 10) ||
|
|
||||||
(result.chrome && result.version < 20) ||
|
|
||||||
(result.firefox && result.version < 20.0) ||
|
|
||||||
(result.safari && result.version < 6) ||
|
|
||||||
(result.opera && result.version < 10.0) ||
|
|
||||||
(result.ios && result.osversion && result.osversion.split(".")[0] < 6)
|
|
||||||
) {
|
|
||||||
result.c = t
|
|
||||||
} else result.x = t
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '')
|
|
||||||
|
|
||||||
bowser.test = function (browserList) {
|
|
||||||
for (var i = 0; i < browserList.length; ++i) {
|
|
||||||
var browserItem = browserList[i];
|
|
||||||
if (typeof browserItem=== 'string') {
|
|
||||||
if (browserItem in bowser) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
});
|
|
6
bowser.min.js
vendored
6
bowser.min.js
vendored
@ -1,6 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Bowser - a browser detector
|
|
||||||
* https://github.com/ded/bowser
|
|
||||||
* MIT License | (c) Dustin Diaz 2015
|
|
||||||
*/
|
|
||||||
!function(e,t){typeof module!="undefined"&&module.exports?module.exports=t():typeof define=="function"&&define.amd?define(t):this[e]=t()}("bowser",function(){function t(t){function n(e){var n=t.match(e);return n&&n.length>1&&n[1]||""}function r(e){var n=t.match(e);return n&&n.length>1&&n[2]||""}var i=n(/(ipod|iphone|ipad)/i).toLowerCase(),s=/like android/i.test(t),o=!s&&/android/i.test(t),u=/CrOS/.test(t),a=n(/edge\/(\d+(\.\d+)?)/i),f=n(/version\/(\d+(\.\d+)?)/i),l=/tablet/i.test(t),c=!l&&/[^-]mobi/i.test(t),h;/opera|opr/i.test(t)?h={name:"Opera",opera:e,version:f||n(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(t)?h={name:"Yandex Browser",yandexbrowser:e,version:f||n(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(t)?(h={name:"Windows Phone",windowsphone:e},a?(h.msedge=e,h.version=a):(h.msie=e,h.version=n(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?h={name:"Internet Explorer",msie:e,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:u?h={name:"Chrome",chromeBook:e,chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?h={name:"Microsoft Edge",msedge:e,version:a}:/chrome|crios|crmo/i.test(t)?h={name:"Chrome",chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:i?(h={name:i=="iphone"?"iPhone":i=="ipad"?"iPad":"iPod"},f&&(h.version=f)):/sailfish/i.test(t)?h={name:"Sailfish",sailfish:e,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?h={name:"SeaMonkey",seamonkey:e,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(t)?(h={name:"Firefox",firefox:e,version:n(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(h.firefoxos=e)):/silk/i.test(t)?h={name:"Amazon Silk",silk:e,version:n(/silk\/(\d+(\.\d+)?)/i)}:o?h={name:"Android",version:f}:/phantom/i.test(t)?h={name:"PhantomJS",phantom:e,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?h={name:"BlackBerry",blackberry:e,version:f||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(t)?(h={name:"WebOS",webos:e,version:f||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(h.touchpad=e)):/bada/i.test(t)?h={name:"Bada",bada:e,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(t)?h={name:"Tizen",tizen:e,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||f}:/safari/i.test(t)?h={name:"Safari",safari:e,version:f}:h={name:n(/^(.*)\/(.*) /),version:r(/^(.*)\/(.*) /)},!h.msedge&&/(apple)?webkit/i.test(t)?(h.name=h.name||"Webkit",h.webkit=e,!h.version&&f&&(h.version=f)):!h.opera&&/gecko\//i.test(t)&&(h.name=h.name||"Gecko",h.gecko=e,h.version=h.version||n(/gecko\/(\d+(\.\d+)?)/i)),!h.msedge&&(o||h.silk)?h.android=e:i&&(h[i]=e,h.ios=e);var p="";h.windowsphone?p=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):i?(p=n(/os (\d+([_\s]\d+)*) like mac os x/i),p=p.replace(/[_\s]/g,".")):o?p=n(/android[ \/-](\d+(\.\d+)*)/i):h.webos?p=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):h.blackberry?p=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):h.bada?p=n(/bada\/(\d+(\.\d+)*)/i):h.tizen&&(p=n(/tizen[\/\s](\d+(\.\d+)*)/i)),p&&(h.osversion=p);var d=p.split(".")[0];if(l||i=="ipad"||o&&(d==3||d==4&&!c)||h.silk)h.tablet=e;else if(c||i=="iphone"||i=="ipod"||o||h.blackberry||h.webos||h.bada)h.mobile=e;return h.msedge||h.msie&&h.version>=10||h.yandexbrowser&&h.version>=15||h.chrome&&h.version>=20||h.firefox&&h.version>=20||h.safari&&h.version>=6||h.opera&&h.version>=10||h.ios&&h.osversion&&h.osversion.split(".")[0]>=6||h.blackberry&&h.version>=10.1?h.a=e:h.msie&&h.version<10||h.chrome&&h.version<20||h.firefox&&h.version<20||h.safari&&h.version<6||h.opera&&h.version<10||h.ios&&h.osversion&&h.osversion.split(".")[0]<6?h.c=e:h.x=e,h}var e=!0,n=t(typeof navigator!="undefined"?navigator.userAgent:"");return n.test=function(e){for(var t=0;t<e.length;++t){var r=e[t];if(typeof r=="string"&&r in n)return!0}return!1},n._detect=t,n})
|
|
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "bowser",
|
|
||||||
"description": "a browser detector",
|
|
||||||
"keywords": [
|
|
||||||
"ender",
|
|
||||||
"browser",
|
|
||||||
"sniff",
|
|
||||||
"detection"
|
|
||||||
],
|
|
||||||
"version": "0.7.2",
|
|
||||||
"homepage": "https://github.com/ded/bowser",
|
|
||||||
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
|
|
||||||
"main": "bowser.js",
|
|
||||||
"scripts": [
|
|
||||||
"bowser.js"
|
|
||||||
]
|
|
||||||
}
|
|
@ -2,8 +2,7 @@ require('smoosh').config({
|
|||||||
"JAVASCRIPT": {
|
"JAVASCRIPT": {
|
||||||
"DIST_DIR": "./"
|
"DIST_DIR": "./"
|
||||||
, "bowser": [
|
, "bowser": [
|
||||||
"./src/copyright.js"
|
"./src/bowser.js"
|
||||||
, "./src/bowser.js"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
, "JSHINT_OPTS": {
|
, "JSHINT_OPTS": {
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
"sniff",
|
"sniff",
|
||||||
"detection"
|
"detection"
|
||||||
],
|
],
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"homepage": "https://github.com/ded/bowser",
|
"homepage": "https://github.com/ded/bowser",
|
||||||
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
|
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
|
||||||
"main": "./bowser.js",
|
"main": "./src/bowser.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/ded/bowser.git"
|
"url": "git+https://github.com/ded/bowser.git"
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/*!
|
||||||
|
* Bowser - a browser detector
|
||||||
|
* https://github.com/ded/bowser
|
||||||
|
* MIT License | (c) Dustin Diaz 2015
|
||||||
|
*/
|
||||||
|
|
||||||
!function (name, definition) {
|
!function (name, definition) {
|
||||||
if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
||||||
else if (typeof define == 'function' && define.amd) define(definition)
|
else if (typeof define == 'function' && define.amd) define(definition)
|
||||||
@ -24,6 +30,8 @@
|
|||||||
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
||||||
, likeAndroid = /like android/i.test(ua)
|
, likeAndroid = /like android/i.test(ua)
|
||||||
, android = !likeAndroid && /android/i.test(ua)
|
, android = !likeAndroid && /android/i.test(ua)
|
||||||
|
, nexusMobile = /nexus\s*[0-6]\s*/i.test(ua)
|
||||||
|
, nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
|
||||||
, chromeos = /CrOS/.test(ua)
|
, chromeos = /CrOS/.test(ua)
|
||||||
, silk = /silk/i.test(ua)
|
, silk = /silk/i.test(ua)
|
||||||
, sailfish = /sailfish/i.test(ua)
|
, sailfish = /sailfish/i.test(ua)
|
||||||
@ -53,6 +61,13 @@
|
|||||||
, version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
|
, version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (/ucbrowser/i.test(ua)) {
|
||||||
|
result = {
|
||||||
|
name: 'UC Browser'
|
||||||
|
, ucbrowser: t
|
||||||
|
, version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (windowsphone) {
|
else if (windowsphone) {
|
||||||
result = {
|
result = {
|
||||||
name: 'Windows Phone'
|
name: 'Windows Phone'
|
||||||
@ -88,6 +103,13 @@
|
|||||||
, version: edgeVersion
|
, 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 (/chrome|crios|crmo/i.test(ua)) {
|
||||||
result = {
|
result = {
|
||||||
name: 'Chrome'
|
name: 'Chrome'
|
||||||
@ -177,6 +199,13 @@
|
|||||||
, version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
|
, version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else if (/qupzilla/i.test(ua)) {
|
||||||
|
result = {
|
||||||
|
name: 'QupZilla'
|
||||||
|
, qupzilla: t
|
||||||
|
, version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (/safari/i.test(ua)) {
|
else if (/safari/i.test(ua)) {
|
||||||
result = {
|
result = {
|
||||||
name: 'Safari'
|
name: 'Safari'
|
||||||
@ -184,6 +213,13 @@
|
|||||||
, version: versionIdentifier
|
, version: versionIdentifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(/googlebot/i.test(ua)) {
|
||||||
|
result = {
|
||||||
|
name: 'Googlebot'
|
||||||
|
, googlebot: t
|
||||||
|
, version: getFirstMatch(/googlebot\/(\d+(\.\d+))/i) || versionIdentifier
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
result = {
|
result = {
|
||||||
name: getFirstMatch(/^(.*)\/(.*) /),
|
name: getFirstMatch(/^(.*)\/(.*) /),
|
||||||
@ -242,9 +278,9 @@
|
|||||||
|
|
||||||
// device type extraction
|
// device type extraction
|
||||||
var osMajorVersion = osVersion.split('.')[0];
|
var osMajorVersion = osVersion.split('.')[0];
|
||||||
if (tablet || 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
|
result.tablet = t
|
||||||
} else if (mobile || iosdevice == 'iphone' || iosdevice == 'ipod' || android || result.blackberry || result.webos || result.bada) {
|
} else if (mobile || iosdevice == 'iphone' || iosdevice == 'ipod' || android || nexusMobile || result.blackberry || result.webos || result.bada) {
|
||||||
result.mobile = t
|
result.mobile = t
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +289,7 @@
|
|||||||
if (result.msedge ||
|
if (result.msedge ||
|
||||||
(result.msie && result.version >= 10) ||
|
(result.msie && result.version >= 10) ||
|
||||||
(result.yandexbrowser && result.version >= 15) ||
|
(result.yandexbrowser && result.version >= 15) ||
|
||||||
|
(result.vivaldi && result.version >= 1.0) ||
|
||||||
(result.chrome && result.version >= 20) ||
|
(result.chrome && result.version >= 20) ||
|
||||||
(result.firefox && result.version >= 20.0) ||
|
(result.firefox && result.version >= 20.0) ||
|
||||||
(result.safari && result.version >= 6) ||
|
(result.safari && result.version >= 6) ||
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Bowser - a browser detector
|
|
||||||
* https://github.com/ded/bowser
|
|
||||||
* MIT License | (c) Dustin Diaz 2015
|
|
||||||
*/
|
|
@ -7,7 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
module.exports.useragents = {
|
module.exports.useragents = {
|
||||||
Chrome: {
|
Chrome: {
|
||||||
'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': {
|
'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 9 Build/LMY48T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Safari/537.36': {
|
||||||
|
chrome: true
|
||||||
|
, android: true
|
||||||
|
, osversion: '5.1.1'
|
||||||
|
, tablet: true
|
||||||
|
, version: '47.0'
|
||||||
|
, webkit: 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': {
|
||||||
chrome: true
|
chrome: true
|
||||||
, android: true
|
, android: true
|
||||||
, osversion: '4.4.2'
|
, osversion: '4.4.2'
|
||||||
@ -884,7 +893,7 @@ module.exports.useragents = {
|
|||||||
, osversion: '4.4.2'
|
, osversion: '4.4.2'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, version: 4.0
|
, version: 4.0
|
||||||
, mobile: true
|
, tablet: true
|
||||||
, x: true
|
, x: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (Linux; U; Android 4.3; de-de; Galaxy Nexus Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30': {
|
, 'Mozilla/5.0 (Linux; U; Android 4.3; de-de; Galaxy Nexus Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30': {
|
||||||
@ -1021,6 +1030,22 @@ module.exports.useragents = {
|
|||||||
, x: true
|
, x: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
, Vivaldi: {
|
||||||
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36 Vivaldi/1.0.303.52' : {
|
||||||
|
vivaldi: true
|
||||||
|
, version: '1.0'
|
||||||
|
, mac: true
|
||||||
|
, webkit: 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
|
||||||
|
, a: true
|
||||||
|
}
|
||||||
|
}
|
||||||
, Generic: {
|
, Generic: {
|
||||||
'Generic/2.15 libww': {
|
'Generic/2.15 libww': {
|
||||||
name: 'Generic'
|
name: 'Generic'
|
||||||
@ -1028,4 +1053,48 @@ module.exports.useragents = {
|
|||||||
, x: true
|
, x: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
, Googlebot: {
|
||||||
|
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)': {
|
||||||
|
googlebot: true
|
||||||
|
, version: '2.1'
|
||||||
|
, x: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, "UC Browser": {
|
||||||
|
'Mozilla/5.0 (iPad; U; CPU OS 9 like Mac OS X; en-us; iPad4,4) AppleWebKit/534.46 (KHTML, like Gecko) UCBrowser/2.4.0.367 U3/1 Safari/7543.48.3': {
|
||||||
|
ucbrowser: true,
|
||||||
|
version: '2.4.0.367',
|
||||||
|
webkit: true,
|
||||||
|
ipad: true,
|
||||||
|
ios: true,
|
||||||
|
osversion: 9,
|
||||||
|
tablet: true,
|
||||||
|
a: true
|
||||||
|
},
|
||||||
|
'Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; SM-T210R Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30 UCBrowser/2.3.2.300': {
|
||||||
|
android: true,
|
||||||
|
osversion: '4.1.2',
|
||||||
|
tablet: true,
|
||||||
|
ucbrowser: true,
|
||||||
|
version: '2.3.2.300',
|
||||||
|
webkit: true,
|
||||||
|
x: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, "QupZilla": {
|
||||||
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) QupZilla/1.8.2 Safari/538.1': {
|
||||||
|
mac: true,
|
||||||
|
qupzilla: true,
|
||||||
|
version: '1.8.2',
|
||||||
|
webkit: true,
|
||||||
|
x: true
|
||||||
|
},
|
||||||
|
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) QupZilla/1.8.6 Safari/537.21': {
|
||||||
|
windows: true,
|
||||||
|
qupzilla: true,
|
||||||
|
version: '1.8.6',
|
||||||
|
webkit: true,
|
||||||
|
x: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user