mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-17 23:37:43 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc47b6a1e9 |
22
.gitignore
vendored
22
.gitignore
vendored
@@ -1,24 +1,2 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
### vim ###
|
|
||||||
.*.s[a-w][a-z]
|
|
||||||
*.un~
|
|
||||||
Session.vim
|
|
||||||
.netrwhist
|
|
||||||
*~
|
|
||||||
.versions
|
|
||||||
|
|
||||||
### OSX ###
|
|
||||||
.DS_Store
|
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
Icon
|
|
||||||
|
|
||||||
|
|
||||||
# Thumbnails
|
|
||||||
._*
|
|
||||||
|
|
||||||
# Files that might appear on external disk
|
|
||||||
.Spotlight-V100
|
|
||||||
.Trashes
|
|
||||||
.idea
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
- 0.8
|
||||||
|
- 0.6
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|||||||
43
bower.json
43
bower.json
@@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ua-parser-js",
|
|
||||||
"version": "0.7.9",
|
|
||||||
"authors": [
|
|
||||||
"Faisal Salman <fyzlman@gmail.com>"
|
|
||||||
],
|
|
||||||
"private": false,
|
|
||||||
"main": "src/ua-parser.js",
|
|
||||||
"ignore": [
|
|
||||||
"build",
|
|
||||||
"node_modules",
|
|
||||||
"bower_components",
|
|
||||||
"test",
|
|
||||||
"tests"
|
|
||||||
],
|
|
||||||
"contributors": [
|
|
||||||
"Faisal Salman <fyzlman@gmail.com>",
|
|
||||||
"Benjamin Bertrand <bertrand.design@gmail.com>",
|
|
||||||
"Carl C Von Lewin <carlchristianlewin@gmail.com>",
|
|
||||||
"Christopher De Cairos <chris.decairos@gmail.com>",
|
|
||||||
"Davit Barbakadze <jayarjo@gmail.com>",
|
|
||||||
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
|
||||||
"Douglas Li <doug@knotch.it>",
|
|
||||||
"Dumitru Uzun <duzun@mail.ru>",
|
|
||||||
"Erik Hesselink <hesselink@gmail.com>",
|
|
||||||
"Fabian Becker <halfdan@xnorfz.de>",
|
|
||||||
"Hendrik Helwich <h.helwich@iplabs.de>",
|
|
||||||
"Jackpoll <jackpoll123456@gmail.com>",
|
|
||||||
"Jake Mc <startswithaj@users.noreply.github.com>",
|
|
||||||
"John Tantalo <john.tantalo@gmail.com>",
|
|
||||||
"John Yanarella <jmy@codecatalyst.com>",
|
|
||||||
"Jon Buckley <jon@jbuckley.ca>",
|
|
||||||
"Kendall Buchanan <kendall@kendagriff.com>",
|
|
||||||
"Lee Treveil <leetreveil@gmail.com>",
|
|
||||||
"Leonardo <leofiore@libero.it>",
|
|
||||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
|
||||||
"Michael Hess <mhess@connectify.me>",
|
|
||||||
"OtakuSiD <otakusid@gmail.com>",
|
|
||||||
"Ross Noble <rosshnoble@gmail.com>",
|
|
||||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>"
|
|
||||||
],
|
|
||||||
"dependencies": {}
|
|
||||||
}
|
|
||||||
37
build/build.sh
Executable file
37
build/build.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
JSHINT_DIR="node_modules/jshint/bin/jshint"
|
||||||
|
MOCHA_DIR="node_modules/mocha/bin/mocha"
|
||||||
|
UGLIFY_DIR="node_modules/uglify-js/bin/uglifyjs"
|
||||||
|
|
||||||
|
# check module directory & install if not found
|
||||||
|
function check_module {
|
||||||
|
if ! type $2 &> /dev/null
|
||||||
|
then
|
||||||
|
echo "$2 is not found"
|
||||||
|
if ! type "npm" &> /dev/null
|
||||||
|
then
|
||||||
|
echo "npm is not installed"
|
||||||
|
echo "Exiting"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Installing $1..."
|
||||||
|
npm install $1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_module "jshint" $JSHINT_DIR
|
||||||
|
check_module "mocha" $MOCHA_DIR
|
||||||
|
check_module "uglify-js" $UGLIFY_DIR
|
||||||
|
|
||||||
|
echo "Verifiying code..."
|
||||||
|
$JSHINT_DIR src/ua-parser.js
|
||||||
|
|
||||||
|
echo "Running test..."
|
||||||
|
$MOCHA_DIR -R nyan test/test.js
|
||||||
|
|
||||||
|
echo "Minifying script..."
|
||||||
|
$UGLIFY_DIR src/ua-parser.js > src/ua-parser.min.js
|
||||||
|
echo "OK"
|
||||||
@@ -1,19 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.9",
|
"version": "0.5.27",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device"],
|
||||||
"user-agent",
|
"scripts": ["src/ua-parser.js"],
|
||||||
"parser",
|
|
||||||
"browser",
|
|
||||||
"engine",
|
|
||||||
"os",
|
|
||||||
"device",
|
|
||||||
"cpu"
|
|
||||||
],
|
|
||||||
"scripts": [
|
|
||||||
"src/ua-parser.js"
|
|
||||||
],
|
|
||||||
"main": "src/ua-parser.js",
|
"main": "src/ua-parser.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"development": {
|
"development": {
|
||||||
|
|||||||
9
dist/ua-parser.min.js
vendored
9
dist/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
9
dist/ua-parser.pack.js
vendored
9
dist/ua-parser.pack.js
vendored
File diff suppressed because one or more lines are too long
12
package.js
12
package.js
@@ -1,12 +0,0 @@
|
|||||||
Package.describe({
|
|
||||||
name: 'faisalman:ua-parser-js',
|
|
||||||
version: '0.7.9',
|
|
||||||
summary: 'Lightweight JavaScript-based user-agent string parser',
|
|
||||||
git: 'https://github.com/faisalman/ua-parser-js.git',
|
|
||||||
documentation: 'readme.md'
|
|
||||||
});
|
|
||||||
|
|
||||||
Package.on_use(function (api) {
|
|
||||||
api.export("UAParser");
|
|
||||||
api.addFiles("src/ua-parser.js");
|
|
||||||
});
|
|
||||||
69
package.json
69
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.9",
|
"version": "0.5.27",
|
||||||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -10,63 +10,33 @@
|
|||||||
"browser",
|
"browser",
|
||||||
"engine",
|
"engine",
|
||||||
"os",
|
"os",
|
||||||
"device",
|
"device"
|
||||||
"cpu"
|
|
||||||
],
|
],
|
||||||
"homepage": "http://github.com/faisalman/ua-parser-js",
|
"homepage": "http://github.com/faisalman/ua-parser-js",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Faisal Salman <fyzlman@gmail.com>",
|
"Faisal Salman <fyzlman@gmail.com>",
|
||||||
"Benjamin Bertrand <bertrand.design@gmail.com>",
|
|
||||||
"Carl C Von Lewin <carlchristianlewin@gmail.com>",
|
|
||||||
"Christopher De Cairos <chris.decairos@gmail.com>",
|
"Christopher De Cairos <chris.decairos@gmail.com>",
|
||||||
"Davit Barbakadze <jayarjo@gmail.com>",
|
|
||||||
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
|
||||||
"Douglas Li <doug@knotch.it>",
|
|
||||||
"Dumitru Uzun <contact@duzun.me>",
|
|
||||||
"Erik Hesselink <hesselink@gmail.com>",
|
|
||||||
"Fabian Becker <halfdan@xnorfz.de>",
|
|
||||||
"Hendrik Helwich <h.helwich@iplabs.de>",
|
|
||||||
"Jackpoll <jackpoll123456@gmail.com>",
|
|
||||||
"Jake Mc <startswithaj@users.noreply.github.com>",
|
|
||||||
"John Tantalo <john.tantalo@gmail.com>",
|
"John Tantalo <john.tantalo@gmail.com>",
|
||||||
"John Yanarella <jmy@codecatalyst.com>",
|
|
||||||
"Jon Buckley <jon@jbuckley.ca>",
|
"Jon Buckley <jon@jbuckley.ca>",
|
||||||
"Kendall Buchanan <kendall@kendagriff.com>",
|
"Lee Treveil <leetreveil@gmail.com>"
|
||||||
"Lee Treveil <leetreveil@gmail.com>",
|
|
||||||
"Leonardo <leofiore@libero.it>",
|
|
||||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
|
||||||
"Michael Hess <mhess@connectify.me>",
|
|
||||||
"OtakuSiD <otakusid@gmail.com>",
|
|
||||||
"Ross Noble <rosshnoble@gmail.com>",
|
|
||||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>"
|
|
||||||
],
|
],
|
||||||
"main": "src/ua-parser.js",
|
"main": "src/ua-parser.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "uglifyjs src/ua-parser.js > dist/ua-parser.min.js --comments '/UAParser\\.js/' && uglifyjs src/ua-parser.js > dist/ua-parser.pack.js --comments '/UAParser\\.js/' --compress --mangle",
|
"test": "./build/build.sh"
|
||||||
"test": "jshint src/ua-parser.js && mocha -R nyan test/test.js",
|
|
||||||
"verup": "node ./node_modules/verup",
|
|
||||||
"version": "node ./node_modules/verup 0"
|
|
||||||
},
|
|
||||||
"verup": {
|
|
||||||
"files": [
|
|
||||||
"ua-parser-js.jquery.json",
|
|
||||||
"component.json",
|
|
||||||
"bower.json",
|
|
||||||
"package.js",
|
|
||||||
"src/ua-parser.js"
|
|
||||||
],
|
|
||||||
"regs": [
|
|
||||||
"^((?:\\$|(\\s*\\*\\s*@)|(\\s*(?:var|,)?\\s+))(?:LIBVERSION|version)[\\s\\:='\"]+)([0-9]+(?:\\.[0-9]+){2,2})",
|
|
||||||
"^(\\s?\\*.*v)([0-9]+(?:\\.[0-9]+){2,2})"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jshint": "~1.1.0",
|
"jshint": ">= 1.1.0",
|
||||||
"mocha": "~1.8.0",
|
"mocha": ">= 1.7.1",
|
||||||
"uglify-js": "~1.3.4",
|
"uglify-js": ">= 1.3.4"
|
||||||
"verup": "^1.3.x"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repository" :
|
||||||
|
{
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/faisalman/ua-parser-js.git"
|
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||||
},
|
},
|
||||||
@@ -84,8 +54,11 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"dist": "dist",
|
"lib": "src",
|
||||||
"src": "src",
|
|
||||||
"test": "test"
|
"test": "test"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"repository": "git://github.com/faisalman/ua-parser-js.git"
|
||||||
}
|
}
|
||||||
|
|||||||
155
readme.md
155
readme.md
@@ -1,37 +1,35 @@
|
|||||||
# UAParser.js
|
# UAParser.js
|
||||||
|
|
||||||
Lightweight JavaScript-based User-Agent string parser. Supports browser & node.js environment. Also available as jQuery/Zepto plugin, Component/Bower/Meteor package, & RequireJS/AMD module
|
Lightweight JavaScript-based User-Agent string parser. Supports browser & node.js environment. Also available as Component package, Bower package, jQuery.ua, & AMD module
|
||||||
|
|
||||||
[](https://travis-ci.org/faisalman/ua-parser-js)
|
[](https://travis-ci.org/faisalman/ua-parser-js)
|
||||||
[](http://flattr.com/thing/3867907/faisalmanua-parser-js-on-GitHub)
|
|
||||||
|
|
||||||
* Author : Faisal Salman <<fyzlman@gmail.com>>
|
* Author : Faisalman <<fyzlman@gmail.com>>
|
||||||
* Demo : http://faisalman.github.io/ua-parser-js
|
* Demo : http://faisalman.github.com/ua-parser-js
|
||||||
* Source : https://github.com/faisalman/ua-parser-js
|
* Source : https://github.com/faisalman/ua-parser-js
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
Extract detailed type of web browser, layout engine, operating system, cpu architecture, and device type/model purely from user-agent string with relatively lightweight footprint (~11KB minified / ~4KB gzipped). Written in vanilla js, which means it doesn't depends on any other library.
|
Extract detailed type of web browser, layout engine, operating system, and device purely from user-agent string with relatively lightweight footprint (~7KB minified / ~3KB gzipped). Written in vanilla js, which means it doesn't depends on any other library.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
* `getBrowser()`
|
* `getBrowser()`
|
||||||
* returns `{ name: '', version: '' }`
|
* returns `{ name: '', major: '', version: '' }`
|
||||||
|
|
||||||
```
|
```
|
||||||
# Possible 'browser.name':
|
# Possible 'browser.name':
|
||||||
Amaya, Android Browser, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome,
|
Amaya, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome, Chromium,
|
||||||
Chromium, Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Edge, Epiphany, Fennec,
|
Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Epiphany, Fennec, Firebird,
|
||||||
Firebird, Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, IceDragon,
|
Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, Iceweasel,
|
||||||
Iceweasel, IE [Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle, Links,
|
IE [Mobile], Jasmine, K-Meleon, Konqueror, Kindle, Links, Lunascape, Lynx, Maemo,
|
||||||
Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, MIUI Browser, [Mobile] Safari,
|
Maxthon, Midori, Minimo, [Mobile] Safari, Mosaic, Mozilla, Netfront, Netscape,
|
||||||
Mosaic, Mozilla, Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet],
|
NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet], Phoenix, Polaris, RockMelt,
|
||||||
Phoenix, Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox,
|
Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox, Tizen, UCBrowser, w3m, Yandex
|
||||||
Tizen, UCBrowser, Vivaldi, w3m, Yandex
|
|
||||||
|
|
||||||
# 'browser.version' determined dynamically
|
# 'browser.version' & 'browser.major' determined dynamically
|
||||||
```
|
```
|
||||||
|
|
||||||
* `getDevice()`
|
* `getDevice()`
|
||||||
@@ -39,13 +37,12 @@ Tizen, UCBrowser, Vivaldi, w3m, Yandex
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Possible 'device.type':
|
# Possible 'device.type':
|
||||||
console, mobile, tablet, smarttv, wearable, embedded
|
console, mobile, tablet
|
||||||
|
|
||||||
# Possible 'device.vendor':
|
# Possible 'device.vendor':
|
||||||
Acer, Alcatel, Amazon, Apple, Archos, Asus, BenQ, BlackBerry, Dell, GeeksPhone,
|
Acer, Alcatel, Apple, Asus, BenQ, BlackBerry, Dell, GeeksPhone, HP, HTC, Huawei,
|
||||||
Google, HP, HTC, Huawei, Jolla, Lenovo, LG, Meizu, Microsoft, Motorola, Nexian,
|
Lenovo, LG, Meizu, Motorola, Nexian, Nintendo, Nokia, Palm, Panasonic,
|
||||||
Nintendo, Nokia, Nvidia, Ouya, Palm, Panasonic, Polytron, RIM, Samsung, Sharp,
|
RIM, Samsung, Siemens, Sony-Ericsson, Sprint, ZTE
|
||||||
Siemens, Sony-Ericsson, Sprint, Xbox, ZTE
|
|
||||||
|
|
||||||
# 'device.model' determined dynamically
|
# 'device.model' determined dynamically
|
||||||
```
|
```
|
||||||
@@ -55,8 +52,8 @@ Siemens, Sony-Ericsson, Sprint, Xbox, ZTE
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Possible 'engine.name'
|
# Possible 'engine.name'
|
||||||
Amaya, EdgeHTML, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto,
|
Amaya, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto, Tasman,
|
||||||
Tasman, Trident, w3m, WebKit
|
Trident, w3m, WebKit
|
||||||
|
|
||||||
# 'engine.version' determined dynamically
|
# 'engine.version' determined dynamically
|
||||||
```
|
```
|
||||||
@@ -66,31 +63,20 @@ Tasman, Trident, w3m, WebKit
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Possible 'os.name'
|
# Possible 'os.name'
|
||||||
AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS, Contiki,
|
AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
|
||||||
Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Gentoo, GNU, Haiku, Hurd, iOS,
|
Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Gentoo, GNU, Haiku, Hurd, iOS,
|
||||||
Joli, Linpus, Linux, Mac OS, Mageia, Mandriva, MeeGo, Minix, Mint, Morph OS, NetBSD,
|
Joli, Linux, Mac OS, Mandriva, MeeGo, Minix, Mint, Morph OS, NetBSD, Nintendo,
|
||||||
Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PCLinuxOS, Plan9, Playstation, QNX, RedHat,
|
OpenBSD, OS/2, Palm, PCLinuxOS, Plan9, Playstation, QNX, RedHat, RIM Tablet OS,
|
||||||
RIM Tablet OS, RISC OS, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen,
|
RISC OS, Slackware, Solaris, SUSE, Symbian, Tizen, Ubuntu, UNIX, WebOS,
|
||||||
Ubuntu, UNIX, VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk
|
Windows [Phone/Mobile], Zenwalk
|
||||||
|
|
||||||
# 'os.version' determined dynamically
|
# 'os.version' determined dynamically
|
||||||
```
|
```
|
||||||
|
|
||||||
* `getCPU()`
|
|
||||||
* returns `{ architecture: '' }`
|
|
||||||
|
|
||||||
```
|
|
||||||
# Possible 'cpu.architecture'
|
|
||||||
68k, amd64, arm, arm64, avr, ia32, ia64, irix, irix64, mips, mips64, pa-risc,
|
|
||||||
ppc, sparc, sparc64
|
|
||||||
```
|
|
||||||
|
|
||||||
* `getResult()`
|
* `getResult()`
|
||||||
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
* returns `{ browser: {}, device: {}, engine: {}, os: {} }`
|
||||||
|
|
||||||
* `getUA()`
|
* `getUA()`
|
||||||
* returns UA string of current instance
|
* returns UA string of current instance
|
||||||
|
|
||||||
* `setUA(uastring)`
|
* `setUA(uastring)`
|
||||||
* set & parse UA string
|
* set & parse UA string
|
||||||
|
|
||||||
@@ -110,10 +96,10 @@ ppc, sparc, sparc64
|
|||||||
/*
|
/*
|
||||||
/// this will print an object structured like this:
|
/// this will print an object structured like this:
|
||||||
{
|
{
|
||||||
ua: "",
|
|
||||||
browser: {
|
browser: {
|
||||||
name: "",
|
name: "",
|
||||||
version: ""
|
version: "",
|
||||||
|
major: ""
|
||||||
},
|
},
|
||||||
engine: {
|
engine: {
|
||||||
name: "",
|
name: "",
|
||||||
@@ -127,9 +113,6 @@ ppc, sparc, sparc64
|
|||||||
model: "",
|
model: "",
|
||||||
type: "",
|
type: "",
|
||||||
vendor: ""
|
vendor: ""
|
||||||
},
|
|
||||||
cpu: {
|
|
||||||
architecture: ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -142,12 +125,11 @@ ppc, sparc, sparc64
|
|||||||
// this will also produce the same result (without instantiation):
|
// this will also produce the same result (without instantiation):
|
||||||
// var result = UAParser(uastring);
|
// var result = UAParser(uastring);
|
||||||
|
|
||||||
console.log(result.browser); // {name: "Chromium", version: "15.0.874.106"}
|
console.log(result.browser); // {name: "Chromium", major: "15", version: "15.0.874.106"}
|
||||||
console.log(result.device); // {model: undefined, type: undefined, vendor: undefined}
|
console.log(result.device); // {model: undefined, type: undefined, vendor: undefined}
|
||||||
console.log(result.os); // {name: "Ubuntu", version: "11.10"}
|
console.log(result.os); // {name: "Ubuntu", version: "11.10"}
|
||||||
console.log(result.os.version); // "11.10"
|
console.log(result.os.version); // "11.10"
|
||||||
console.log(result.engine.name); // "WebKit"
|
console.log(result.engine.name); // "WebKit"
|
||||||
console.log(result.cpu.architecture); // "amd64"
|
|
||||||
|
|
||||||
// do some other tests
|
// do some other tests
|
||||||
var uastring2 = "Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)";
|
var uastring2 = "Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)";
|
||||||
@@ -167,27 +149,6 @@ ppc, sparc, sparc64
|
|||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using node.js
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ npm install ua-parser-js
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
var http = require('http');
|
|
||||||
var parser = require('ua-parser-js');
|
|
||||||
|
|
||||||
http.createServer(function (req, res) {
|
|
||||||
// get user-agent header
|
|
||||||
var ua = parser(req.headers['user-agent']);
|
|
||||||
// write the result as response
|
|
||||||
res.end(JSON.stringify(ua, null, ' '));
|
|
||||||
})
|
|
||||||
.listen(1337, '127.0.0.1');
|
|
||||||
|
|
||||||
console.log('Server running at http://127.0.0.1:1337/');
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using requirejs
|
### Using requirejs
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -197,27 +158,39 @@ require(['ua-parser'], function(UAParser) {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using node.js
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install ua-parser-js
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
var UAParser = require('ua-parser-js');
|
||||||
|
var parser = new UAParser();
|
||||||
|
console.log(parser.getResult());
|
||||||
|
```
|
||||||
|
|
||||||
### Using component
|
### Using component
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ component install faisalman/ua-parser-js
|
$ component install faisalman/ua-parser-js
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
var UAParser = require('ua-parser-js');
|
||||||
|
var parser = new UAParser();
|
||||||
|
console.log(parser.getResult());
|
||||||
|
```
|
||||||
|
|
||||||
### Using bower
|
### Using bower
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ bower install ua-parser-js
|
$ bower install ua-parser-js
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using meteor
|
### Using jQuery.ua
|
||||||
|
|
||||||
```sh
|
Although written in vanilla js (which means it doesn't depends on jQuery), if you're using jQuery, this library will automatically detect and create `$.ua` object based on browser's user-agent (although in case you need, `window.UAParser` constructor is still present). To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
|
||||||
$ meteor add faisalman:ua-parser-js
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using jQuery/Zepto ($.ua)
|
|
||||||
|
|
||||||
Although written in vanilla js (which means it doesn't depends on jQuery), this library will automatically detect if jQuery/Zepto is present and create `$.ua` object based on browser's user-agent (although in case you need, `window.UAParser` constructor is still present). To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// In browser with default user-agent: 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0':
|
// In browser with default user-agent: 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0':
|
||||||
@@ -238,37 +211,27 @@ console.log($.ua.device); // {vendor: "Motorola", model: "Xoom", type:
|
|||||||
console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
|
console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
|
||||||
```
|
```
|
||||||
|
|
||||||
### Extending regex patterns
|
|
||||||
|
|
||||||
* `UAParser(uastring[, extensions])`
|
|
||||||
|
|
||||||
Pass your own regexes to extend the limited matching rules.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Example:
|
|
||||||
var uaString = 'ownbrowser/1.3';
|
|
||||||
var ownBrowser = [[/(ownbrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]];
|
|
||||||
var parser = new UAParser(uaString, {browser: ownBrowser});
|
|
||||||
console.log(parser.getBrowser()); // {name: "ownbrowser", version: "1.3"}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
Install dependencies
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install jshint
|
||||||
|
$ npm install mocha
|
||||||
|
$ npm install uglify-js
|
||||||
|
```
|
||||||
|
|
||||||
Verify, test, & minify script
|
Verify, test, & minify script
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ npm run test
|
$ ./build/build.sh
|
||||||
$ npm run build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then submit a pull request to https://github.com/faisalman/ua-parser-js under `develop` branch.
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Dual licensed under GPLv2 & MIT
|
Dual licensed under GPLv2 & MIT
|
||||||
|
|
||||||
Copyright © 2012-2015 Faisal Salman <<fyzlman@gmail.com>>
|
Copyright © 2012-2013 Faisalman <<fyzlman@gmail.com>>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|||||||
655
src/ua-parser.js
655
src/ua-parser.js
@@ -1,11 +1,9 @@
|
|||||||
/**
|
// UAParser.js v0.5.27
|
||||||
* UAParser.js v0.7.9
|
// Lightweight JavaScript-based User-Agent string parser
|
||||||
* Lightweight JavaScript-based User-Agent string parser
|
// https://github.com/faisalman/ua-parser-js
|
||||||
* https://github.com/faisalman/ua-parser-js
|
//
|
||||||
*
|
// Copyright © 2012-2013 Faisalman <fyzlman@gmail.com>
|
||||||
* Copyright © 2012-2015 Faisal Salman <fyzlman@gmail.com>
|
// Dual licensed under GPLv2 & MIT
|
||||||
* Dual licensed under GPLv2 & MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function (window, undefined) {
|
(function (window, undefined) {
|
||||||
|
|
||||||
@@ -16,26 +14,20 @@
|
|||||||
/////////////
|
/////////////
|
||||||
|
|
||||||
|
|
||||||
var LIBVERSION = '0.7.9',
|
var EMPTY = '',
|
||||||
EMPTY = '',
|
|
||||||
UNKNOWN = '?',
|
UNKNOWN = '?',
|
||||||
FUNC_TYPE = 'function',
|
FUNC_TYPE = 'function',
|
||||||
UNDEF_TYPE = 'undefined',
|
UNDEF_TYPE = 'undefined',
|
||||||
OBJ_TYPE = 'object',
|
OBJ_TYPE = 'object',
|
||||||
STR_TYPE = 'string',
|
MAJOR = 'major',
|
||||||
MAJOR = 'major', // deprecated
|
|
||||||
MODEL = 'model',
|
MODEL = 'model',
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
TYPE = 'type',
|
TYPE = 'type',
|
||||||
VENDOR = 'vendor',
|
VENDOR = 'vendor',
|
||||||
VERSION = 'version',
|
VERSION = 'version',
|
||||||
ARCHITECTURE= 'architecture',
|
|
||||||
CONSOLE = 'console',
|
CONSOLE = 'console',
|
||||||
MOBILE = 'mobile',
|
MOBILE = 'mobile',
|
||||||
TABLET = 'tablet',
|
TABLET = 'tablet';
|
||||||
SMARTTV = 'smarttv',
|
|
||||||
WEARABLE = 'wearable',
|
|
||||||
EMBEDDED = 'embedded';
|
|
||||||
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
@@ -44,26 +36,8 @@
|
|||||||
|
|
||||||
|
|
||||||
var util = {
|
var util = {
|
||||||
extend : function (regexes, extensions) {
|
|
||||||
for (var i in extensions) {
|
|
||||||
if ("browser cpu device engine os".indexOf(i) !== -1 && extensions[i].length % 2 === 0) {
|
|
||||||
regexes[i] = extensions[i].concat(regexes[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return regexes;
|
|
||||||
},
|
|
||||||
has : function (str1, str2) {
|
has : function (str1, str2) {
|
||||||
if (typeof str1 === "string") {
|
|
||||||
return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
|
return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
lowerize : function (str) {
|
|
||||||
return str.toLowerCase();
|
|
||||||
},
|
|
||||||
major : function (version) {
|
|
||||||
return typeof(version) === STR_TYPE ? version.split(".")[0] : undefined;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,20 +51,18 @@
|
|||||||
|
|
||||||
rgx : function () {
|
rgx : function () {
|
||||||
|
|
||||||
var result, i = 0, j, k, p, q, matches, match, args = arguments;
|
|
||||||
|
|
||||||
// loop through all regexes maps
|
// loop through all regexes maps
|
||||||
while (i < args.length && !matches) {
|
for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) {
|
||||||
|
|
||||||
var regex = args[i], // even sequence (0,2,4,..)
|
var regex = args[i], // even sequence (0,2,4,..)
|
||||||
props = args[i + 1]; // odd sequence (1,3,5,..)
|
props = args[i + 1]; // odd sequence (1,3,5,..)
|
||||||
|
|
||||||
// construct object barebones
|
// construct object barebones
|
||||||
if (typeof result === UNDEF_TYPE) {
|
if (typeof(result) === UNDEF_TYPE) {
|
||||||
result = {};
|
result = {};
|
||||||
for (p in props) {
|
for (p in props) {
|
||||||
q = props[p];
|
q = props[p];
|
||||||
if (typeof q === OBJ_TYPE) {
|
if (typeof(q) === OBJ_TYPE) {
|
||||||
result[q[0]] = undefined;
|
result[q[0]] = undefined;
|
||||||
} else {
|
} else {
|
||||||
result[q] = undefined;
|
result[q] = undefined;
|
||||||
@@ -99,42 +71,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try matching uastring with regexes
|
// try matching uastring with regexes
|
||||||
j = k = 0;
|
for (j = k = 0; j < regex.length; j++) {
|
||||||
while (j < regex.length && !matches) {
|
matches = regex[j].exec(this.getUA());
|
||||||
matches = regex[j++].exec(this.getUA());
|
|
||||||
if (!!matches) {
|
if (!!matches) {
|
||||||
for (p = 0; p < props.length; p++) {
|
for (p in props) {
|
||||||
match = matches[++k];
|
match = matches[++k];
|
||||||
q = props[p];
|
q = props[p];
|
||||||
// check if given property is actually array
|
// check if given property is actually array
|
||||||
if (typeof q === OBJ_TYPE && q.length > 0) {
|
if (typeof(q) === OBJ_TYPE && q.length > 0) {
|
||||||
if (q.length == 2) {
|
if (q.length == 2) {
|
||||||
if (typeof q[1] == FUNC_TYPE) {
|
// assign given value, ignore regex match
|
||||||
// assign modified match
|
result[q[0]] = q[1];
|
||||||
result[q[0]] = q[1].call(this, match);
|
|
||||||
} else {
|
|
||||||
// assign given value, ignore regex match
|
|
||||||
result[q[0]] = q[1];
|
|
||||||
}
|
|
||||||
} else if (q.length == 3) {
|
} else if (q.length == 3) {
|
||||||
// check whether function or regex
|
// check whether function or regex
|
||||||
if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
|
if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) {
|
||||||
// call function (usually string mapper)
|
// call function (usually string mapper)
|
||||||
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
|
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
|
||||||
} else {
|
} else {
|
||||||
// sanitize match using given regex
|
// sanitize match using given regex
|
||||||
result[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
|
result[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
|
||||||
}
|
}
|
||||||
} else if (q.length == 4) {
|
|
||||||
result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result[q] = match ? match : undefined;
|
result[q] = match ? match : undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i += 2;
|
|
||||||
|
if(!!matches) break; // break the loop immediately if match found
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@@ -143,8 +109,8 @@
|
|||||||
|
|
||||||
for (var i in map) {
|
for (var i in map) {
|
||||||
// check if array
|
// check if array
|
||||||
if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
|
if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) {
|
||||||
for (var j = 0; j < map[i].length; j++) {
|
for (var j in map[i]) {
|
||||||
if (util.has(map[i][j], str)) {
|
if (util.has(map[i][j], str)) {
|
||||||
return (i === UNKNOWN) ? undefined : i;
|
return (i === UNKNOWN) ? undefined : i;
|
||||||
}
|
}
|
||||||
@@ -167,6 +133,11 @@
|
|||||||
|
|
||||||
browser : {
|
browser : {
|
||||||
oldsafari : {
|
oldsafari : {
|
||||||
|
major : {
|
||||||
|
'1' : ['/8', '/1', '/3'],
|
||||||
|
'2' : '/4',
|
||||||
|
'?' : '/'
|
||||||
|
},
|
||||||
version : {
|
version : {
|
||||||
'1.0' : '/8',
|
'1.0' : '/8',
|
||||||
'1.2' : '/1',
|
'1.2' : '/1',
|
||||||
@@ -181,11 +152,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
device : {
|
device : {
|
||||||
amazon : {
|
|
||||||
model : {
|
|
||||||
'Fire Phone' : ['SD', 'KF']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sprint : {
|
sprint : {
|
||||||
model : {
|
model : {
|
||||||
'Evo Shift 4G' : '7373KT'
|
'Evo Shift 4G' : '7373KT'
|
||||||
@@ -208,8 +174,6 @@
|
|||||||
'Vista' : 'NT 6.0',
|
'Vista' : 'NT 6.0',
|
||||||
'7' : 'NT 6.1',
|
'7' : 'NT 6.1',
|
||||||
'8' : 'NT 6.2',
|
'8' : 'NT 6.2',
|
||||||
'8.1' : 'NT 6.3',
|
|
||||||
'10' : ['NT 6.4', 'NT 10.0'],
|
|
||||||
'RT' : 'ARM'
|
'RT' : 'ARM'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,235 +191,79 @@
|
|||||||
browser : [[
|
browser : [[
|
||||||
|
|
||||||
// Presto based
|
// Presto based
|
||||||
/(opera\smini)\/([\w\.-]+)/i, // Opera Mini
|
/(opera\smini)\/((\d+)?[\w\.-]+)/i, // Opera Mini
|
||||||
/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
|
/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i, // Opera Mobi/Tablet
|
||||||
/(opera).+version\/([\w\.]+)/i, // Opera > 9.80
|
/(opera).+version\/((\d+)?[\w\.]+)/i, // Opera > 9.80
|
||||||
/(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
|
/(opera)[\/\s]+((\d+)?[\w\.]+)/i // Opera < 9.80
|
||||||
|
|
||||||
], [NAME, VERSION], [
|
], [NAME, VERSION, MAJOR], [
|
||||||
|
|
||||||
/\s(opr)\/([\w\.]+)/i // Opera Webkit
|
/\s(opr)\/((\d+)?[\w\.]+)/i // Opera Webkit
|
||||||
], [[NAME, 'Opera'], VERSION], [
|
], [[NAME, 'Opera'], VERSION, MAJOR], [
|
||||||
|
|
||||||
// Mixed
|
// Mixed
|
||||||
/(kindle)\/([\w\.]+)/i, // Kindle
|
/(kindle)\/((\d+)?[\w\.]+)/i, // Kindle
|
||||||
/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]+)*/i,
|
/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,
|
||||||
// Lunascape/Maxthon/Netfront/Jasmine/Blazer
|
// Lunascape/Maxthon/Netfront/Jasmine/Blazer
|
||||||
|
|
||||||
// Trident based
|
// Trident based
|
||||||
/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i,
|
/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i,
|
||||||
// Avant/IEMobile/SlimBrowser/Baidu
|
// Avant/IEMobile/SlimBrowser/Baidu
|
||||||
/(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer
|
/((?:ms|\()ie)\s((\d+)?[\w\.]+)/i, // Internet Explorer
|
||||||
|
|
||||||
// Webkit/KHTML based
|
// Webkit/KHTML based
|
||||||
/(rekonq)\/([\w\.]+)*/i, // Rekonq
|
/(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq
|
||||||
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium)\/([\w\.-]+)/i
|
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i
|
||||||
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium
|
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt
|
||||||
], [NAME, VERSION], [
|
], [NAME, VERSION, MAJOR], [
|
||||||
|
|
||||||
/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
|
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
|
||||||
], [[NAME, 'IE'], VERSION], [
|
], [[NAME, 'Yandex'], VERSION, MAJOR], [
|
||||||
|
|
||||||
/(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge
|
/(comodo_dragon)\/((\d+)?[\w\.]+)/i // Comodo Dragon
|
||||||
], [NAME, VERSION], [
|
], [[NAME, /_/g, ' '], VERSION, MAJOR], [
|
||||||
|
|
||||||
/(yabrowser)\/([\w\.]+)/i // Yandex
|
/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i
|
||||||
], [[NAME, 'Yandex'], VERSION], [
|
|
||||||
|
|
||||||
/(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
|
|
||||||
], [[NAME, /_/g, ' '], VERSION], [
|
|
||||||
|
|
||||||
/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i,
|
|
||||||
// Chrome/OmniWeb/Arora/Tizen/Nokia
|
// Chrome/OmniWeb/Arora/Tizen/Nokia
|
||||||
/(uc\s?browser|qqbrowser)[\/\s]?([\w\.]+)/i
|
], [NAME, VERSION, MAJOR], [
|
||||||
// UCBrowser/QQBrowser
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(dolfin)\/([\w\.]+)/i // Dolphin
|
/(dolfin)\/((\d+)?[\w\.]+)/i // Dolphin
|
||||||
], [[NAME, 'Dolphin'], VERSION], [
|
], [[NAME, 'Dolphin'], VERSION, MAJOR], [
|
||||||
|
|
||||||
/((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
|
/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i // Chrome for Android/iOS
|
||||||
], [[NAME, 'Chrome'], VERSION], [
|
], [[NAME, 'Chrome'], VERSION, MAJOR], [
|
||||||
|
|
||||||
/XiaoMi\/MiuiBrowser\/([\w\.]+)/i // MIUI Browser
|
/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
|
||||||
], [VERSION, [NAME, 'MIUI Browser']], [
|
], [VERSION, MAJOR, [NAME, 'Mobile Safari']], [
|
||||||
|
|
||||||
/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)/i // Android Browser
|
/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
|
||||||
], [VERSION, [NAME, 'Android Browser']], [
|
], [VERSION, MAJOR, NAME], [
|
||||||
|
|
||||||
/FBAV\/([\w\.]+);/i // Facebook App for iOS
|
/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i // Safari < 3.0
|
||||||
], [VERSION, [NAME, 'Facebook']], [
|
], [NAME, [MAJOR, mapper.str, maps.browser.oldsafari.major], [VERSION, mapper.str, maps.browser.oldsafari.version]], [
|
||||||
|
|
||||||
/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
|
/(konqueror)\/((\d+)?[\w\.]+)/i, // Konqueror
|
||||||
], [VERSION, [NAME, 'Mobile Safari']], [
|
/(webkit|khtml)\/((\d+)?[\w\.]+)/i
|
||||||
|
], [NAME, VERSION, MAJOR], [
|
||||||
/version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
|
|
||||||
], [VERSION, NAME], [
|
|
||||||
|
|
||||||
/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
|
|
||||||
], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [
|
|
||||||
|
|
||||||
/(konqueror)\/([\w\.]+)/i, // Konqueror
|
|
||||||
/(webkit|khtml)\/([\w\.]+)/i
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
// Gecko based
|
// Gecko based
|
||||||
/(navigator|netscape)\/([\w\.-]+)/i // Netscape
|
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
|
||||||
], [[NAME, 'Netscape'], VERSION], [
|
], [[NAME, 'Netscape'], VERSION, MAJOR], [
|
||||||
/fxios\/([\w\.-]+)/i // Firefox for iOS
|
|
||||||
], [VERSION, [NAME, 'Firefox']], [
|
|
||||||
/(swiftfox)/i, // Swiftfox
|
/(swiftfox)/i, // Swiftfox
|
||||||
/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,
|
/(iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,
|
||||||
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
|
// Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
|
||||||
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/([\w\.-]+)/i,
|
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,
|
||||||
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
|
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
|
||||||
/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
|
/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?([\w\.]+)/i,
|
/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?((\d+)?[\w\.]+)/i,
|
||||||
// Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf
|
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf
|
||||||
/(links)\s\(([\w\.]+)/i, // Links
|
/(links)\s\(((\d+)?[\w\.]+)/i, // Links
|
||||||
/(gobrowser)\/?([\w\.]+)*/i, // GoBrowser
|
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
|
||||||
/(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser
|
/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser
|
||||||
/(mosaic)[\/\s]([\w\.]+)/i // Mosaic
|
/(mosaic)[\/\s]((\d+)?[\w\.]+)/i // Mosaic
|
||||||
], [NAME, VERSION]
|
], [NAME, VERSION, MAJOR]
|
||||||
|
|
||||||
/* /////////////////////
|
|
||||||
// Media players BEGIN
|
|
||||||
////////////////////////
|
|
||||||
|
|
||||||
, [
|
|
||||||
|
|
||||||
/(apple(?:coremedia|))\/((\d+)[\w\._]+)/i, // Generic Apple CoreMedia
|
|
||||||
/(coremedia) v((\d+)[\w\._]+)/i
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(aqualung|lyssna|bsplayer)\/((\d+)?[\w\.-]+)/i // Aqualung/Lyssna/BSPlayer
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(ares|ossproxy)\s((\d+)[\w\.-]+)/i // Ares/OSSProxy
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(audacious|audimusicstream|amarok|bass|core|dalvik|gnomemplayer|music on console|nsplayer|psp-internetradioplayer|videos)\/((\d+)[\w\.-]+)/i,
|
|
||||||
// Audacious/AudiMusicStream/Amarok/BASS/OpenCORE/Dalvik/GnomeMplayer/MoC
|
|
||||||
// NSPlayer/PSP-InternetRadioPlayer/Videos
|
|
||||||
/(clementine|music player daemon)\s((\d+)[\w\.-]+)/i, // Clementine/MPD
|
|
||||||
/(lg player|nexplayer)\s((\d+)[\d\.]+)/i,
|
|
||||||
/player\/(nexplayer|lg player)\s((\d+)[\w\.-]+)/i // NexPlayer/LG Player
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
/(nexplayer)\s((\d+)[\w\.-]+)/i // Nexplayer
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(flrp)\/((\d+)[\w\.-]+)/i // Flip Player
|
|
||||||
], [[NAME, 'Flip Player'], VERSION], [
|
|
||||||
|
|
||||||
/(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i
|
|
||||||
// FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit
|
|
||||||
], [NAME], [
|
|
||||||
|
|
||||||
/(gstreamer) souphttpsrc (?:\([^\)]+\)){0,1} libsoup\/((\d+)[\w\.-]+)/i
|
|
||||||
// Gstreamer
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(htc streaming player)\s[\w_]+\s\/\s((\d+)[\d\.]+)/i, // HTC Streaming Player
|
|
||||||
/(java|python-urllib|python-requests|wget|libcurl)\/((\d+)[\w\.-_]+)/i,
|
|
||||||
// Java/urllib/requests/wget/cURL
|
|
||||||
/(lavf)((\d+)[\d\.]+)/i // Lavf (FFMPEG)
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(htc_one_s)\/((\d+)[\d\.]+)/i // HTC One S
|
|
||||||
], [[NAME, /_/g, ' '], VERSION], [
|
|
||||||
|
|
||||||
/(mplayer)(?:\s|\/)(?:(?:sherpya-){0,1}svn)(?:-|\s)(r\d+(?:-\d+[\w\.-]+){0,1})/i
|
|
||||||
// MPlayer SVN
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(mplayer)(?:\s|\/|[unkow-]+)((\d+)[\w\.-]+)/i // MPlayer
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(mplayer)/i, // MPlayer (no other info)
|
|
||||||
/(yourmuze)/i, // YourMuze
|
|
||||||
/(media player classic|nero showtime)/i // Media Player Classic/Nero ShowTime
|
|
||||||
], [NAME], [
|
|
||||||
|
|
||||||
/(nero (?:home|scout))\/((\d+)[\w\.-]+)/i // Nero Home/Nero Scout
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(nokia\d+)\/((\d+)[\w\.-]+)/i // Nokia
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/\s(songbird)\/((\d+)[\w\.-]+)/i // Songbird/Philips-Songbird
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(winamp)3 version ((\d+)[\w\.-]+)/i, // Winamp
|
|
||||||
/(winamp)\s((\d+)[\w\.-]+)/i,
|
|
||||||
/(winamp)mpeg\/((\d+)[\w\.-]+)/i
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(ocms-bot|tapinradio|tunein radio|unknown|winamp|inlight radio)/i // OCMS-bot/tap in radio/tunein/unknown/winamp (no other info)
|
|
||||||
// inlight radio
|
|
||||||
], [NAME], [
|
|
||||||
|
|
||||||
/(quicktime|rma|radioapp|radioclientapplication|soundtap|totem|stagefright|streamium)\/((\d+)[\w\.-]+)/i
|
|
||||||
// QuickTime/RealMedia/RadioApp/RadioClientApplication/
|
|
||||||
// SoundTap/Totem/Stagefright/Streamium
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(smp)((\d+)[\d\.]+)/i // SMP
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(vlc) media player - version ((\d+)[\w\.]+)/i, // VLC Videolan
|
|
||||||
/(vlc)\/((\d+)[\w\.-]+)/i,
|
|
||||||
/(xbmc|gvfs|xine|xmms|irapp)\/((\d+)[\w\.-]+)/i, // XBMC/gvfs/Xine/XMMS/irapp
|
|
||||||
/(foobar2000)\/((\d+)[\d\.]+)/i, // Foobar2000
|
|
||||||
/(itunes)\/((\d+)[\d\.]+)/i // iTunes
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(wmplayer)\/((\d+)[\w\.-]+)/i, // Windows Media Player
|
|
||||||
/(windows-media-player)\/((\d+)[\w\.-]+)/i
|
|
||||||
], [[NAME, /-/g, ' '], VERSION], [
|
|
||||||
|
|
||||||
/windows\/((\d+)[\w\.-]+) upnp\/[\d\.]+ dlnadoc\/[\d\.]+ (home media server)/i
|
|
||||||
// Windows Media Server
|
|
||||||
], [VERSION, [NAME, 'Windows']], [
|
|
||||||
|
|
||||||
/(com\.riseupradioalarm)\/((\d+)[\d\.]*)/i // RiseUP Radio Alarm
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
|
|
||||||
/(rad.io)\s((\d+)[\d\.]+)/i, // Rad.io
|
|
||||||
/(radio.(?:de|at|fr))\s((\d+)[\d\.]+)/i
|
|
||||||
], [[NAME, 'rad.io'], VERSION]
|
|
||||||
|
|
||||||
//////////////////////
|
|
||||||
// Media players END
|
|
||||||
////////////////////*/
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
cpu : [[
|
|
||||||
|
|
||||||
/(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i // AMD64
|
|
||||||
], [[ARCHITECTURE, 'amd64']], [
|
|
||||||
|
|
||||||
/(ia32(?=;))/i // IA32 (quicktime)
|
|
||||||
], [[ARCHITECTURE, util.lowerize]], [
|
|
||||||
|
|
||||||
/((?:i[346]|x)86)[;\)]/i // IA32
|
|
||||||
], [[ARCHITECTURE, 'ia32']], [
|
|
||||||
|
|
||||||
// PocketPC mistakenly identified as PowerPC
|
|
||||||
/windows\s(ce|mobile);\sppc;/i
|
|
||||||
], [[ARCHITECTURE, 'arm']], [
|
|
||||||
|
|
||||||
/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
|
|
||||||
], [[ARCHITECTURE, /ower/, '', util.lowerize]], [
|
|
||||||
|
|
||||||
/(sun4\w)[;\)]/i // SPARC
|
|
||||||
], [[ARCHITECTURE, 'sparc']], [
|
|
||||||
|
|
||||||
/((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+;))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i
|
|
||||||
// IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
|
|
||||||
], [[ARCHITECTURE, util.lowerize]]
|
|
||||||
],
|
],
|
||||||
|
|
||||||
device : [[
|
device : [[
|
||||||
@@ -463,203 +271,79 @@
|
|||||||
/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i // iPad/PlayBook
|
/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i // iPad/PlayBook
|
||||||
], [MODEL, VENDOR, [TYPE, TABLET]], [
|
], [MODEL, VENDOR, [TYPE, TABLET]], [
|
||||||
|
|
||||||
/applecoremedia\/[\w\.]+ \((ipad)/ // iPad
|
|
||||||
], [MODEL, [VENDOR, 'Apple'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/(apple\s{0,1}tv)/i // Apple TV
|
|
||||||
], [[MODEL, 'Apple TV'], [VENDOR, 'Apple']], [
|
|
||||||
|
|
||||||
/(archos)\s(gamepad2?)/i, // Archos
|
|
||||||
/(hp).+(touchpad)/i, // HP TouchPad
|
/(hp).+(touchpad)/i, // HP TouchPad
|
||||||
/(kindle)\/([\w\.]+)/i, // Kindle
|
/(kindle)\/([\w\.]+)/i, // Kindle
|
||||||
/\s(nook)[\w\s]+build\/(\w+)/i, // Nook
|
/\s(nook)[\w\s]+build\/(\w+)/i, // Nook
|
||||||
/(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak
|
/(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak
|
||||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
||||||
|
|
||||||
/(kf[A-z]+)\sbuild\/[\w\.]+.*silk\//i // Kindle Fire HD
|
/\((ip[honed]+);.+(apple)/i // iPod/iPhone
|
||||||
], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
|
|
||||||
/(sd|kf)[0349hijorstuw]+\sbuild\/[\w\.]+.*silk\//i // Fire Phone
|
|
||||||
], [[MODEL, mapper.str, maps.device.amazon.model], [VENDOR, 'Amazon'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\((ip[honed|\s\w*]+);.+(apple)/i // iPod/iPhone
|
|
||||||
], [MODEL, VENDOR, [TYPE, MOBILE]], [
|
], [MODEL, VENDOR, [TYPE, MOBILE]], [
|
||||||
/\((ip[honed|\s\w*]+);/i // iPod/iPhone
|
|
||||||
], [MODEL, [VENDOR, 'Apple'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(blackberry)[\s-]?(\w+)/i, // BlackBerry
|
/(blackberry)[\s-]?(\w+)/i, // BlackBerry
|
||||||
/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola|polytron)[\s_-]?([\w-]+)*/i,
|
/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola)[\s_-]?([\w-]+)*/i,
|
||||||
// BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Huawei/Meizu/Motorola/Polytron
|
// BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Huawei/Meizu/Motorola
|
||||||
/(hp)\s([\w\s]+\w)/i, // HP iPAQ
|
/(hp)\s([\w\s]+\w)/i, // HP iPAQ
|
||||||
/(asus)-?(\w+)/i // Asus
|
/(asus)-?(\w+)/i // Asus
|
||||||
], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
||||||
/\(bb10;\s(\w+)/i // BlackBerry 10
|
/\((bb10);\s(\w+)/i // BlackBerry 10
|
||||||
], [MODEL, [VENDOR, 'BlackBerry'], [TYPE, MOBILE]], [
|
], [[VENDOR, 'BlackBerry'], MODEL, [TYPE, MOBILE]], [
|
||||||
// Asus Tablets
|
|
||||||
/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7)/i
|
|
||||||
], [MODEL, [VENDOR, 'Asus'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/(sony)\s(tablet\s[ps])\sbuild\//i, // Sony
|
/android.+((transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+))/i // Asus Tablets
|
||||||
/(sony)?(?:sgp.+)\sbuild\//i
|
], [[VENDOR, 'Asus'], MODEL, [TYPE, TABLET]], [
|
||||||
], [[VENDOR, 'Sony'], [MODEL, 'Xperia Tablet'], [TYPE, TABLET]], [
|
|
||||||
/(?:sony)?(?:(?:(?:c|d)\d{4})|(?:so[-l].+))\sbuild\//i
|
/(sony)\s(tablet\s[ps])/i // Sony Tablets
|
||||||
], [[VENDOR, 'Sony'], [MODEL, 'Xperia Phone'], [TYPE, MOBILE]], [
|
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
||||||
|
|
||||||
/\s(ouya)\s/i, // Ouya
|
|
||||||
/(nintendo)\s([wids3u]+)/i // Nintendo
|
/(nintendo)\s([wids3u]+)/i // Nintendo
|
||||||
], [VENDOR, MODEL, [TYPE, CONSOLE]], [
|
], [VENDOR, MODEL, [TYPE, CONSOLE]], [
|
||||||
|
|
||||||
/android.+;\s(shield)\sbuild/i // Nvidia
|
/((playstation)\s[3portablevi]+)/i // Playstation
|
||||||
], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
|
], [[VENDOR, 'Sony'], MODEL, [TYPE, CONSOLE]], [
|
||||||
|
|
||||||
/(playstation\s[3portablevi]+)/i // Playstation
|
|
||||||
], [MODEL, [VENDOR, 'Sony'], [TYPE, CONSOLE]], [
|
|
||||||
|
|
||||||
/(sprint\s(\w+))/i // Sprint Phones
|
/(sprint\s(\w+))/i // Sprint Phones
|
||||||
], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [
|
], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [
|
||||||
|
|
||||||
/(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i // Lenovo tablets
|
|
||||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC
|
/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC
|
||||||
/(zte)-(\w+)*/i, // ZTE
|
/(zte)-(\w+)*/i, // ZTE
|
||||||
/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i
|
/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i
|
||||||
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
|
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
|
||||||
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
||||||
|
|
||||||
/(nexus\s9)/i // HTC Nexus 9
|
/\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i, // Motorola
|
||||||
], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
|
/(mot)[\s-]?(\w+)*/i
|
||||||
|
], [[VENDOR, 'Motorola'], MODEL, [TYPE, MOBILE]], [
|
||||||
|
/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i
|
||||||
|
], [[VENDOR, 'Motorola'], MODEL, [TYPE, TABLET]], [
|
||||||
|
|
||||||
/[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox
|
/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n8000|sgh-t8[56]9))/i
|
||||||
], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [
|
|
||||||
/(kin\.[onetw]{3})/i // Microsoft Kin
|
|
||||||
], [[MODEL, /\./g, ' '], [VENDOR, 'Microsoft'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
// Motorola
|
|
||||||
/\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?)[\w\s]+build\//i,
|
|
||||||
/mot[\s-]?(\w+)*/i,
|
|
||||||
/(XT\d{3,4}) build\//i
|
|
||||||
], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [
|
|
||||||
/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i
|
|
||||||
], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n8000|sgh-t8[56]9|nexus 10))/i,
|
|
||||||
/((SM-T\w+))/i
|
|
||||||
], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung
|
], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung
|
||||||
/((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-n900))/i,
|
/((s[cgp]h-\w+|gt-\w+|galaxy\snexus))/i,
|
||||||
/(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i,
|
/(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i,
|
||||||
/sec-((sgh\w+))/i
|
/sec-((sgh\w+))/i
|
||||||
], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [
|
], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [
|
||||||
/(samsung);smarttv/i
|
/(sie)-(\w+)*/i // Siemens
|
||||||
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
|
], [[VENDOR, 'Siemens'], MODEL, [TYPE, MOBILE]], [
|
||||||
|
|
||||||
/\(dtv[\);].+(aquos)/i // Sharp
|
|
||||||
], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [
|
|
||||||
/sie-(\w+)*/i // Siemens
|
|
||||||
], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia
|
/(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia
|
||||||
/(nokia)[\s_-]?([\w-]+)*/i
|
/(nokia)[\s_-]?([\w-]+)*/i
|
||||||
], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
|
], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
|
||||||
|
|
||||||
/android\s3\.[\s\w;-]{10}(a\d{3})/i // Acer
|
/android\s3\.[\s\w-;]{10}((a\d{3}))/i // Acer
|
||||||
], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
|
], [[VENDOR, 'Acer'], MODEL, [TYPE, TABLET]], [
|
||||||
|
|
||||||
/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet
|
/android\s3\.[\s\w-;]{10}(lg?)-([06cv9]{3,4})/i // LG
|
||||||
], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
|
], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
|
||||||
/(lg) netcast\.tv/i // LG SmartTV
|
/((nexus\s4))/i,
|
||||||
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
|
/(lg)[e;\s-\/]+(\w+)*/i
|
||||||
/(nexus\s[45])/i, // LG
|
], [[VENDOR, 'LG'], MODEL, [TYPE, MOBILE]], [
|
||||||
/lg[e;\s\/-]+(\w+)*/i
|
|
||||||
], [MODEL, [VENDOR, 'LG'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/android.+(ideatab[a-z0-9\-\s]+)/i // Lenovo
|
|
||||||
], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/linux;.+((jolla));/i // Jolla
|
|
||||||
], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/((pebble))app\/[\d\.]+\s/i // Pebble
|
|
||||||
], [VENDOR, MODEL, [TYPE, WEARABLE]], [
|
|
||||||
|
|
||||||
/android.+;\s(glass)\s\d/i // Google Glass
|
|
||||||
], [MODEL, [VENDOR, 'Google'], [TYPE, WEARABLE]], [
|
|
||||||
|
|
||||||
/android.+(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
|
|
||||||
/android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi
|
|
||||||
/android.+(mi[\s\-_]*(?:one|one[\s_]plus)?[\s_]*(?:\d\w)?)\s+build/i // Xiaomi Mi
|
|
||||||
], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(mobile|tablet);.+rv\:.+gecko\//i // Unidentifiable
|
/(mobile|tablet);.+rv\:.+gecko\//i // Unidentifiable
|
||||||
], [[TYPE, util.lowerize], VENDOR, MODEL]
|
], [TYPE, VENDOR, MODEL]
|
||||||
|
|
||||||
/*//////////////////////////
|
|
||||||
// TODO: move to string map
|
|
||||||
////////////////////////////
|
|
||||||
|
|
||||||
/(C6603)/i // Sony Xperia Z C6603
|
|
||||||
], [[MODEL, 'Xperia Z C6603'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [
|
|
||||||
/(C6903)/i // Sony Xperia Z 1
|
|
||||||
], [[MODEL, 'Xperia Z 1'], [VENDOR, 'Sony'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(SM-G900[F|H])/i // Samsung Galaxy S5
|
|
||||||
], [[MODEL, 'Galaxy S5'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
|
|
||||||
/(SM-G7102)/i // Samsung Galaxy Grand 2
|
|
||||||
], [[MODEL, 'Galaxy Grand 2'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
|
|
||||||
/(SM-G530H)/i // Samsung Galaxy Grand Prime
|
|
||||||
], [[MODEL, 'Galaxy Grand Prime'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
|
|
||||||
/(SM-G313HZ)/i // Samsung Galaxy V
|
|
||||||
], [[MODEL, 'Galaxy V'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
|
|
||||||
/(SM-T805)/i // Samsung Galaxy Tab S 10.5
|
|
||||||
], [[MODEL, 'Galaxy Tab S 10.5'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [
|
|
||||||
/(SM-G800F)/i // Samsung Galaxy S5 Mini
|
|
||||||
], [[MODEL, 'Galaxy S5 Mini'], [VENDOR, 'Samsung'], [TYPE, MOBILE]], [
|
|
||||||
/(SM-T311)/i // Samsung Galaxy Tab 3 8.0
|
|
||||||
], [[MODEL, 'Galaxy Tab 3 8.0'], [VENDOR, 'Samsung'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/(R1001)/i // Oppo R1001
|
|
||||||
], [MODEL, [VENDOR, 'OPPO'], [TYPE, MOBILE]], [
|
|
||||||
/(X9006)/i // Oppo Find 7a
|
|
||||||
], [[MODEL, 'Find 7a'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [
|
|
||||||
/(R2001)/i // Oppo YOYO R2001
|
|
||||||
], [[MODEL, 'Yoyo R2001'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [
|
|
||||||
/(R815)/i // Oppo Clover R815
|
|
||||||
], [[MODEL, 'Clover R815'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [
|
|
||||||
/(U707)/i // Oppo Find Way S
|
|
||||||
], [[MODEL, 'Find Way S'], [VENDOR, 'Oppo'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(T3C)/i // Advan Vandroid T3C
|
|
||||||
], [MODEL, [VENDOR, 'Advan'], [TYPE, TABLET]], [
|
|
||||||
/(ADVAN T1J\+)/i // Advan Vandroid T1J+
|
|
||||||
], [[MODEL, 'Vandroid T1J+'], [VENDOR, 'Advan'], [TYPE, TABLET]], [
|
|
||||||
/(ADVAN S4A)/i // Advan Vandroid S4A
|
|
||||||
], [[MODEL, 'Vandroid S4A'], [VENDOR, 'Advan'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(V972M)/i // ZTE V972M
|
|
||||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(i-mobile)\s(IQ\s[\d\.]+)/i // i-mobile IQ
|
|
||||||
], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
|
||||||
/(IQ6.3)/i // i-mobile IQ IQ 6.3
|
|
||||||
], [[MODEL, 'IQ 6.3'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [
|
|
||||||
/(i-mobile)\s(i-style\s[\d\.]+)/i // i-mobile i-STYLE
|
|
||||||
], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
|
||||||
/(i-STYLE2.1)/i // i-mobile i-STYLE 2.1
|
|
||||||
], [[MODEL, 'i-STYLE 2.1'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/(mobiistar touch LAI 512)/i // mobiistar touch LAI 512
|
|
||||||
], [[MODEL, 'Touch LAI 512'], [VENDOR, 'mobiistar'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/////////////
|
|
||||||
// END TODO
|
|
||||||
///////////*/
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
engine : [[
|
engine : [[
|
||||||
|
|
||||||
/windows.+\sedge\/([\w\.]+)/i // EdgeHTML
|
|
||||||
], [VERSION, [NAME, 'EdgeHTML']], [
|
|
||||||
|
|
||||||
/(presto)\/([\w\.]+)/i, // Presto
|
/(presto)\/([\w\.]+)/i, // Presto
|
||||||
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
|
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
|
||||||
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
|
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
|
||||||
@@ -673,8 +357,6 @@
|
|||||||
os : [[
|
os : [[
|
||||||
|
|
||||||
// Windows based
|
// Windows based
|
||||||
/microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes)
|
|
||||||
], [NAME, VERSION], [
|
|
||||||
/(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
|
/(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
|
||||||
/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
|
/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
|
||||||
], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
|
], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
|
||||||
@@ -685,15 +367,12 @@
|
|||||||
/\((bb)(10);/i // BlackBerry 10
|
/\((bb)(10);/i // BlackBerry 10
|
||||||
], [[NAME, 'BlackBerry'], VERSION], [
|
], [[NAME, 'BlackBerry'], VERSION], [
|
||||||
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
|
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
|
||||||
/(tizen)[\/\s]([\w\.]+)/i, // Tizen
|
/(tizen)\/([\w\.]+)/i, // Tizen
|
||||||
/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
|
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i
|
||||||
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki
|
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo
|
||||||
/linux;.+(sailfish);/i // Sailfish OS
|
|
||||||
], [NAME, VERSION], [
|
], [NAME, VERSION], [
|
||||||
/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian
|
/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian
|
||||||
], [[NAME, 'Symbian'], VERSION], [
|
], [[NAME, 'Symbian'], VERSION],[
|
||||||
/\((series40);/i // Series 40
|
|
||||||
], [NAME], [
|
|
||||||
/mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
|
/mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
|
||||||
], [[NAME, 'Firefox OS'], VERSION], [
|
], [[NAME, 'Firefox OS'], VERSION], [
|
||||||
|
|
||||||
@@ -702,10 +381,9 @@
|
|||||||
|
|
||||||
// GNU/Linux based
|
// GNU/Linux based
|
||||||
/(mint)[\/\s\(]?(\w+)*/i, // Mint
|
/(mint)[\/\s\(]?(\w+)*/i, // Mint
|
||||||
/(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux
|
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,
|
||||||
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i,
|
|
||||||
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
|
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
|
||||||
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus
|
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk
|
||||||
/(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux
|
/(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux
|
||||||
/(gnu)\s?([\w\.]+)*/i // GNU
|
/(gnu)\s?([\w\.]+)*/i // GNU
|
||||||
], [NAME, VERSION], [
|
], [NAME, VERSION], [
|
||||||
@@ -724,16 +402,14 @@
|
|||||||
/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS
|
/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS
|
||||||
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [
|
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [
|
||||||
|
|
||||||
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i,
|
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i // Mac OS
|
||||||
/(macintosh|mac(?=_powerpc)\s)/i // Mac OS
|
], [NAME, [VERSION, /_/g, '.']], [
|
||||||
], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
/((?:open)?solaris)[\/\s-]?([\w\.]+)*/i, // Solaris
|
|
||||||
/(haiku)\s(\w+)/i, // Haiku
|
/(haiku)\s(\w+)/i, // Haiku
|
||||||
/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX
|
/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX
|
||||||
/(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms)/i,
|
/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,
|
||||||
// Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS
|
// Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS
|
||||||
/(unix)\s?([\w\.]+)*/i // UNIX
|
/(unix)\s?([\w\.]+)*/i // UNIX
|
||||||
], [NAME, VERSION]
|
], [NAME, VERSION]
|
||||||
]
|
]
|
||||||
@@ -745,40 +421,31 @@
|
|||||||
////////////////
|
////////////////
|
||||||
|
|
||||||
|
|
||||||
var UAParser = function (uastring, extensions) {
|
var UAParser = function (uastring) {
|
||||||
|
|
||||||
if (!(this instanceof UAParser)) {
|
|
||||||
return new UAParser(uastring, extensions).getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
|
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
|
||||||
var rgxmap = extensions ? util.extend(regexes, extensions) : regexes;
|
|
||||||
|
|
||||||
|
if (!(this instanceof UAParser)) {
|
||||||
|
return new UAParser(uastring).getResult();
|
||||||
|
}
|
||||||
this.getBrowser = function () {
|
this.getBrowser = function () {
|
||||||
var browser = mapper.rgx.apply(this, rgxmap.browser);
|
return mapper.rgx.apply(this, regexes.browser);
|
||||||
browser.major = util.major(browser.version);
|
|
||||||
return browser;
|
|
||||||
};
|
|
||||||
this.getCPU = function () {
|
|
||||||
return mapper.rgx.apply(this, rgxmap.cpu);
|
|
||||||
};
|
};
|
||||||
this.getDevice = function () {
|
this.getDevice = function () {
|
||||||
return mapper.rgx.apply(this, rgxmap.device);
|
return mapper.rgx.apply(this, regexes.device);
|
||||||
};
|
};
|
||||||
this.getEngine = function () {
|
this.getEngine = function () {
|
||||||
return mapper.rgx.apply(this, rgxmap.engine);
|
return mapper.rgx.apply(this, regexes.engine);
|
||||||
};
|
};
|
||||||
this.getOS = function () {
|
this.getOS = function () {
|
||||||
return mapper.rgx.apply(this, rgxmap.os);
|
return mapper.rgx.apply(this, regexes.os);
|
||||||
};
|
};
|
||||||
this.getResult = function() {
|
this.getResult = function() {
|
||||||
return {
|
return {
|
||||||
ua : this.getUA(),
|
|
||||||
browser : this.getBrowser(),
|
browser : this.getBrowser(),
|
||||||
engine : this.getEngine(),
|
engine : this.getEngine(),
|
||||||
os : this.getOS(),
|
os : this.getOS(),
|
||||||
device : this.getDevice(),
|
device : this.getDevice()
|
||||||
cpu : this.getCPU()
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
this.getUA = function () {
|
this.getUA = function () {
|
||||||
@@ -789,36 +456,6 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
this.setUA(ua);
|
this.setUA(ua);
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
UAParser.VERSION = LIBVERSION;
|
|
||||||
UAParser.BROWSER = {
|
|
||||||
NAME : NAME,
|
|
||||||
MAJOR : MAJOR, // deprecated
|
|
||||||
VERSION : VERSION
|
|
||||||
};
|
|
||||||
UAParser.CPU = {
|
|
||||||
ARCHITECTURE : ARCHITECTURE
|
|
||||||
};
|
|
||||||
UAParser.DEVICE = {
|
|
||||||
MODEL : MODEL,
|
|
||||||
VENDOR : VENDOR,
|
|
||||||
TYPE : TYPE,
|
|
||||||
CONSOLE : CONSOLE,
|
|
||||||
MOBILE : MOBILE,
|
|
||||||
SMARTTV : SMARTTV,
|
|
||||||
TABLET : TABLET,
|
|
||||||
WEARABLE: WEARABLE,
|
|
||||||
EMBEDDED: EMBEDDED
|
|
||||||
};
|
|
||||||
UAParser.ENGINE = {
|
|
||||||
NAME : NAME,
|
|
||||||
VERSION : VERSION
|
|
||||||
};
|
|
||||||
UAParser.OS = {
|
|
||||||
NAME : NAME,
|
|
||||||
VERSION : VERSION
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -830,41 +467,35 @@
|
|||||||
// check js environment
|
// check js environment
|
||||||
if (typeof(exports) !== UNDEF_TYPE) {
|
if (typeof(exports) !== UNDEF_TYPE) {
|
||||||
// nodejs env
|
// nodejs env
|
||||||
if (typeof module !== UNDEF_TYPE && module.exports) {
|
if (typeof(module) !== UNDEF_TYPE && module.exports) {
|
||||||
exports = module.exports = UAParser;
|
exports = module.exports = UAParser;
|
||||||
}
|
}
|
||||||
exports.UAParser = UAParser;
|
exports.UAParser = UAParser;
|
||||||
} else {
|
} else {
|
||||||
|
// browser env
|
||||||
|
window.UAParser = UAParser;
|
||||||
// requirejs env (optional)
|
// requirejs env (optional)
|
||||||
if (typeof(define) === FUNC_TYPE && define.amd) {
|
if (typeof(define) === FUNC_TYPE && define.amd) {
|
||||||
define(function () {
|
define(function () {
|
||||||
return UAParser;
|
return UAParser;
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
// browser env
|
// jQuery specific (optional)
|
||||||
window.UAParser = UAParser;
|
if (typeof(window.jQuery) !== UNDEF_TYPE) {
|
||||||
|
var $ = window.jQuery;
|
||||||
|
var parser = new UAParser();
|
||||||
|
$.ua = parser.getResult();
|
||||||
|
$.ua.get = function() {
|
||||||
|
return parser.getUA();
|
||||||
|
};
|
||||||
|
$.ua.set = function (uastring) {
|
||||||
|
parser.setUA(uastring);
|
||||||
|
var result = parser.getResult();
|
||||||
|
for (var prop in result) {
|
||||||
|
$.ua[prop] = result[prop];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// jQuery/Zepto specific (optional)
|
})(this);
|
||||||
// Note:
|
|
||||||
// In AMD env the global scope should be kept clean, but jQuery is an exception.
|
|
||||||
// jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
|
|
||||||
// and we should catch that.
|
|
||||||
var $ = window.jQuery || window.Zepto;
|
|
||||||
if (typeof $ !== UNDEF_TYPE) {
|
|
||||||
var parser = new UAParser();
|
|
||||||
$.ua = parser.getResult();
|
|
||||||
$.ua.get = function() {
|
|
||||||
return parser.getUA();
|
|
||||||
};
|
|
||||||
$.ua.set = function (uastring) {
|
|
||||||
parser.setUA(uastring);
|
|
||||||
var result = parser.getResult();
|
|
||||||
for (var prop in result) {
|
|
||||||
$.ua[prop] = result[prop];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
})(typeof window === 'object' ? window : this);
|
|
||||||
|
|||||||
7
src/ua-parser.min.js
vendored
Normal file
7
src/ua-parser.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"desc" : "Android Browser on HTC Flyer (P510E)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 3.2.1; ru-ru; HTC Flyer P510e Build/HTK75C) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Android Browser",
|
|
||||||
"version" : "4.0",
|
|
||||||
"major" : "4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Android Browser on Huawei Honor Glory II (U9508)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.0.4; ru-by; HUAWEI U9508 Build/HuaweiU9508) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 ACHEETAHI/2100050044",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Android Browser",
|
|
||||||
"version" : "4.0",
|
|
||||||
"major" : "4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "Arora",
|
"desc" : "Arora",
|
||||||
"ua" : "Mozilla/5.0 (Windows; U; Windows NT 5.1; de-CH) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2",
|
"ua" : "Mozilla/5.0 (Windows; U; Windows NT 5.1; de-CH) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.2",
|
||||||
@@ -34,7 +14,7 @@
|
|||||||
"ua" : "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB5; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
|
"ua" : "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB5; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
|
||||||
"expect" :
|
"expect" :
|
||||||
{
|
{
|
||||||
"name" : "Avant ",
|
"name" : "Avant Browser",
|
||||||
"version" : "undefined",
|
"version" : "undefined",
|
||||||
"major" : "undefined"
|
"major" : "undefined"
|
||||||
}
|
}
|
||||||
@@ -44,7 +24,7 @@
|
|||||||
"ua" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; baidubrowser 1.x)",
|
"ua" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; baidubrowser 1.x)",
|
||||||
"expect" :
|
"expect" :
|
||||||
{
|
{
|
||||||
"name" : "baidu",
|
"name" : "baidubrowser",
|
||||||
"version" : "1.x",
|
"version" : "1.x",
|
||||||
"major" : "1"
|
"major" : "1"
|
||||||
}
|
}
|
||||||
@@ -260,7 +240,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"desc" : "IE 11 with IE token",
|
"desc" : "IE 11",
|
||||||
"ua" : "Mozilla/5.0 (IE 11.0; Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko",
|
"ua" : "Mozilla/5.0 (IE 11.0; Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko",
|
||||||
"expect" :
|
"expect" :
|
||||||
{
|
{
|
||||||
@@ -269,16 +249,6 @@
|
|||||||
"major" : "11"
|
"major" : "11"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"desc" : "IE 11 without IE token",
|
|
||||||
"ua" : "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "IE",
|
|
||||||
"version" : "11.0",
|
|
||||||
"major" : "11"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "K-Meleon",
|
"desc" : "K-Meleon",
|
||||||
"ua" : "Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031016 K-Meleon/0.8.2",
|
"ua" : "Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031016 K-Meleon/0.8.2",
|
||||||
@@ -369,16 +339,6 @@
|
|||||||
"major" : "0"
|
"major" : "0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"desc" : "MIUI Browser on Xiaomi Hongmi WCDMA (HM2013023)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.2.2; ru-ru; 2013023 Build/HM2013023) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 XiaoMi/MiuiBrowser/1.0",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "MIUI Browser",
|
|
||||||
"version" : "1.0",
|
|
||||||
"major" : "1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "Mobile Safari",
|
"desc" : "Mobile Safari",
|
||||||
"ua" : "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7",
|
"ua" : "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7",
|
||||||
@@ -624,7 +584,7 @@
|
|||||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SlimBrowser)",
|
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SlimBrowser)",
|
||||||
"expect" :
|
"expect" :
|
||||||
{
|
{
|
||||||
"name" : "Slim",
|
"name" : "SlimBrowser",
|
||||||
"version" : "undefined",
|
"version" : "undefined",
|
||||||
"major" : "undefined"
|
"major" : "undefined"
|
||||||
}
|
}
|
||||||
@@ -669,16 +629,6 @@
|
|||||||
"major" : "8"
|
"major" : "8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"desc" : "Vivaldi",
|
|
||||||
"ua" : "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Vivaldi/1.0.83.38 Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Vivaldi",
|
|
||||||
"version" : "1.0.83.38",
|
|
||||||
"major" : "1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "Yandex",
|
"desc" : "Yandex",
|
||||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.5 (KHTML, like Gecko) YaBrowser/1.0.1084.5402 Chrome/19.0.1084.5402 Safari/536.5",
|
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.5 (KHTML, like Gecko) YaBrowser/1.0.1084.5402 Chrome/19.0.1084.5402 Safari/536.5",
|
||||||
@@ -688,25 +638,4 @@
|
|||||||
"version" : "1.0.1084.5402",
|
"version" : "1.0.1084.5402",
|
||||||
"major" : "1"
|
"major" : "1"
|
||||||
}
|
}
|
||||||
},
|
}]
|
||||||
{
|
|
||||||
"desc" : "Microsoft Edge",
|
|
||||||
"ua" : "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",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Edge",
|
|
||||||
"version" : "12.0",
|
|
||||||
"major" : "12"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Iridium",
|
|
||||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Iridium/43.8 Safari/537.36 Chrome/43.0.2357.132",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Iridium",
|
|
||||||
"version" : "43.8",
|
|
||||||
"major" : "43"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -1,106 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"desc" : "i686",
|
|
||||||
"ua" : "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:19.0) Gecko/20100101 Firefox/19.0",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "ia32"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "i386",
|
|
||||||
"ua" : "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040628 Epiphany/1.2.6",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "ia32"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "x86-64",
|
|
||||||
"ua" : "Opera/9.80 (X11; Linux x86_64; U; Linux Mint; en) Presto/2.2.15 Version/10.10",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "amd64"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "win64",
|
|
||||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Win64; x64; Trident/6.0; .NET4.0E; .NET4.0C)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "amd64"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "WOW64",
|
|
||||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "amd64"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "ARMv6",
|
|
||||||
"ua" : "Mozilla/5.0 (X11; U; Linux armv61; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "arm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Pocket PC",
|
|
||||||
"ua" : "Opera/9.7 (Windows Mobile; PPC; Opera Mobi/35166; U; en) Presto/2.2.1",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "arm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Mac PowerPC",
|
|
||||||
"ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "ppc"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Mac PowerPC",
|
|
||||||
"ua" : "Mozilla/4.0 (compatible; MSIE 5.17; Mac_PowerPC Mac OS; en)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "ppc"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Mac PowerPC",
|
|
||||||
"ua" : "iCab/2.9.5 (Macintosh; U; PPC; Mac OS X)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "ppc"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "UltraSPARC",
|
|
||||||
"ua" : "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "sparc"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "QuickTime",
|
|
||||||
"ua" : "QuickTime/7.5.6 (qtver=7.5.6;cpu=IA32;os=Mac 10.5.8)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "ia32"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "XBMC",
|
|
||||||
"ua" : "XBMC/12.0 Git:20130127-fb595f2 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"architecture" : "amd64"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -9,16 +9,6 @@
|
|||||||
"type" : "mobile"
|
"type" : "mobile"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"desc" : "HTC Nexus 9",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 5.0; Nexus 9 Build/LRX21R) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Mobile Crosswalk/7.36.154.13 Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "HTC",
|
|
||||||
"model" : "Nexus 9",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "LG Nexus 4",
|
"desc" : "LG Nexus 4",
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.2.1; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
|
"ua" : "Mozilla/5.0 (Linux; Android 4.2.1; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
|
||||||
@@ -28,215 +18,4 @@
|
|||||||
"model" : "Nexus 4",
|
"model" : "Nexus 4",
|
||||||
"type" : "mobile"
|
"type" : "mobile"
|
||||||
}
|
}
|
||||||
},
|
}]
|
||||||
{
|
|
||||||
"desc" : "LG Nexus 5",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "LG",
|
|
||||||
"model" : "Nexus 5",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Motorola Droid RAZR 4G",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 2.3; xx-xx; DROID RAZR 4G Build/6.5.1-73_DHD-11_M1-29) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Motorola",
|
|
||||||
"model" : "DROID RAZR 4G",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "iPhone",
|
|
||||||
"ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Apple",
|
|
||||||
"model" : "iPhone",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Motorola Droid RAZR 4G",
|
|
||||||
"ua" : "Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A501 Safari/9537.53",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Apple",
|
|
||||||
"model" : "iPod touch",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Moto X",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.2; xx-xx; XT1058 Build/13.9.0Q2.X-70-GHOST-ATT_LE-2) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Motorola",
|
|
||||||
"model" : "XT1058",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Nokia3xx",
|
|
||||||
"ua" : "Nokia303/14.87 CLDC-1.1",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Nokia",
|
|
||||||
"model" : "303",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Kindle Fire HD",
|
|
||||||
"ua" : "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",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Amazon",
|
|
||||||
"model" : "KFTT",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Samsung SM-T231",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.4.2; SM-T231 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Samsung",
|
|
||||||
"model" : "SM-T231",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Samsung SM-T700",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.4.2; SM-T700 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Samsung",
|
|
||||||
"model" : "SM-T700",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Samsung SM-T520",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.4.2; SM-T520 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Samsung",
|
|
||||||
"model" : "SM-T520",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Sony C5303 (Xperia SP)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.3; C5303 Build/12.1.A.1.205) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.93 Mobile Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Sony",
|
|
||||||
"model" : "Xperia Phone",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Sony SO-02F (Xperia Z1 F)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.2.2; SO-02F Build/14.1.H.2.119) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Sony",
|
|
||||||
"model" : "Xperia Phone",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Sony D6653 (Xperia Z3)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.4; D6653 Build/23.0.A.0.376) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.141 Mobile Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Sony",
|
|
||||||
"model" : "Xperia Phone",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Sony Xperia SOL25 (ZL2)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.4; SOL25 Build/17.1.1.C.1.64) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Sony",
|
|
||||||
"model" : "Xperia Phone",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Sony SGP521 (Xperia Z2 Tablet)",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 4.4; SGP521 Build/17.1.A.0.432) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Sony",
|
|
||||||
"model" : "Xperia Tablet",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Sony Tablet S",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 3.1; Sony Tablet S Build/THMAS10000) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Sony",
|
|
||||||
"model" : "Xperia Tablet",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Sony Tablet Z LTE",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.1; SonySGP321 Build/10.2.C.0.143) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Sony",
|
|
||||||
"model" : "Xperia Tablet",
|
|
||||||
"type" : "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Xiaomi 2013023",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.2.2; en-US; 2013023 Build/HM2013023) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/10.0.1.512 U3/0.8.0 Mobile Safari/533.1",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Xiaomi",
|
|
||||||
"model" : "2013023",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Xiaomi Hongmi Note 1W",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.2.2; zh-CN; HM NOTE 1W Build/JDQ39) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.7.9.439 U3/0.8.0 Mobile Safari/533.1",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Xiaomi",
|
|
||||||
"model" : "HM NOTE 1W",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Xiaomi Mi 3C",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.3; zh-CN; MI 3C Build/JLS36C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.7.9.439 U3/0.8.0 Mobile Safari/533.1",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Xiaomi",
|
|
||||||
"model" : "MI 3C",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "Xiaomi Mi One Plus",
|
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; MI-ONE Plus Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"vendor" : "Xiaomi",
|
|
||||||
"model" : "MI-ONE Plus",
|
|
||||||
"type" : "mobile"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -1,13 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"desc" : "EdgeHTML",
|
|
||||||
"ua" : "Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Edge/12.0",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "EdgeHTML",
|
|
||||||
"version" : "12.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "Gecko",
|
"desc" : "Gecko",
|
||||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20110111 Firefox/4.0b9pre",
|
"ua" : "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20110111 Firefox/4.0b9pre",
|
||||||
@@ -70,5 +61,4 @@
|
|||||||
"name" : "WebKit",
|
"name" : "WebKit",
|
||||||
"version" : "533.19.4"
|
"version" : "533.19.4"
|
||||||
}
|
}
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
|
|||||||
@@ -71,15 +71,6 @@
|
|||||||
"version" : "8"
|
"version" : "8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"desc" : "Windows 10",
|
|
||||||
"ua" : "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",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Windows",
|
|
||||||
"version" : "10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "Windows RT",
|
"desc" : "Windows RT",
|
||||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",
|
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",
|
||||||
@@ -478,11 +469,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"desc" : "Mac OS",
|
"desc" : "Mac OS",
|
||||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36",
|
"ua" : "",
|
||||||
"expect" :
|
"expect" :
|
||||||
{
|
{
|
||||||
"name" : "Mac OS",
|
"name" : "",
|
||||||
"version" : "10.6.8"
|
"version" : ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -566,15 +557,6 @@
|
|||||||
"version" : ""
|
"version" : ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"desc" : "iTunes Windows Vista",
|
|
||||||
"ua" : "iTunes/10.7 (Windows; Microsoft Windows Vista Home Premium Edition Service Pack 1 (Build 6001)) AppleWebKit/536.26.9",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Windows",
|
|
||||||
"version" : "Vista"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "",
|
"desc" : "",
|
||||||
"ua" : "",
|
"ua" : "",
|
||||||
@@ -583,23 +565,4 @@
|
|||||||
"name" : "",
|
"name" : "",
|
||||||
"version" : ""
|
"version" : ""
|
||||||
}
|
}
|
||||||
},
|
}]
|
||||||
{
|
|
||||||
"desc" : "iOS BE App",
|
|
||||||
"ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "iOS",
|
|
||||||
"version" : "7.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc" : "KTB-Nexus 5",
|
|
||||||
"ua" : "APP-My App/1.0 (Linux; Android 4.2.1; Nexus 5 Build/JOP40D)",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Android",
|
|
||||||
"version" : "4.2.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|||||||
22
test/test.js
22
test/test.js
@@ -1,7 +1,6 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var UAParser = require('./../src/ua-parser');
|
var UAParser = require('./../src/ua-parser');
|
||||||
var browsers = require('./browser-test.json');
|
var browsers = require('./browser-test.json');
|
||||||
var cpus = require('./cpu-test.json');
|
|
||||||
var devices = require('./device-test.json');
|
var devices = require('./device-test.json');
|
||||||
var engines = require('./engine-test.json');
|
var engines = require('./engine-test.json');
|
||||||
var os = require('./os-test.json');
|
var os = require('./os-test.json');
|
||||||
@@ -13,12 +12,6 @@ var methods = [
|
|||||||
list : browsers,
|
list : browsers,
|
||||||
properties : ['name', 'major', 'version']
|
properties : ['name', 'major', 'version']
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title : 'getCPU',
|
|
||||||
label : 'cpu',
|
|
||||||
list : cpus,
|
|
||||||
properties : ['architecture']
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title : 'getDevice',
|
title : 'getDevice',
|
||||||
label : 'device',
|
label : 'device',
|
||||||
@@ -43,15 +36,6 @@ describe('UAParser()', function () {
|
|||||||
assert.deepEqual(UAParser(ua), new UAParser().setUA(ua).getResult());
|
assert.deepEqual(UAParser(ua), new UAParser().setUA(ua).getResult());
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Injected Browser', function () {
|
|
||||||
var uaString = 'ownbrowser/1.3';
|
|
||||||
var ownBrowser = [[/(ownbrowser)\/((\d+)?[\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION, UAParser.BROWSER.MAJOR]];
|
|
||||||
var parser = new UAParser(uaString, {browser: ownBrowser});
|
|
||||||
assert.equal(parser.getBrowser().name, 'ownbrowser');
|
|
||||||
assert.equal(parser.getBrowser().major, '1');
|
|
||||||
assert.equal(parser.getBrowser().version, '1.3');
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var i in methods) {
|
for (var i in methods) {
|
||||||
describe(methods[i]['title'], function () {
|
describe(methods[i]['title'], function () {
|
||||||
for (var j in methods[i]['list']) {
|
for (var j in methods[i]['list']) {
|
||||||
@@ -60,12 +44,12 @@ for (var i in methods) {
|
|||||||
describe('"' + methods[i]['list'][j].ua + '"', function () {
|
describe('"' + methods[i]['list'][j].ua + '"', function () {
|
||||||
var expect = methods[i]['list'][j].expect;
|
var expect = methods[i]['list'][j].expect;
|
||||||
var result = parser.setUA(methods[i]['list'][j].ua).getResult()[methods[i]['label']];
|
var result = parser.setUA(methods[i]['list'][j].ua).getResult()[methods[i]['label']];
|
||||||
|
for (var k in methods[i]['properties']) {
|
||||||
methods[i]['properties'].forEach(function(m) {
|
var m = methods[i]['properties'][k];
|
||||||
it('should return ' + methods[i]['label'] + ' ' + m + ': ' + expect[m], function () {
|
it('should return ' + methods[i]['label'] + ' ' + m + ': ' + expect[m], function () {
|
||||||
assert.equal(result[m], expect[m] != 'undefined' ? expect[m] : undefined);
|
assert.equal(result[m], expect[m] != 'undefined' ? expect[m] : undefined);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,31 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.9",
|
"version": "0.5.27",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"user-agent",
|
"user-agent",
|
||||||
"parser",
|
"parser",
|
||||||
"browser",
|
"browser",
|
||||||
"engine",
|
"engine",
|
||||||
"os",
|
"os",
|
||||||
"device",
|
"device"
|
||||||
"cpu"
|
],
|
||||||
],
|
"homepage": "https://faisalman.github.com/ua-parser-js",
|
||||||
"homepage": "https://faisalman.github.com/ua-parser-js",
|
"author": {
|
||||||
"author": {
|
"name": "Faisal Salman",
|
||||||
"name": "Faisal Salman",
|
"email": "fyzlman@gmail.com"
|
||||||
"email": "fyzlman@gmail.com"
|
},
|
||||||
},
|
"dependencies": {
|
||||||
"dependencies": {
|
"jquery": ">=1.5"
|
||||||
"jquery": ">=1.5"
|
},
|
||||||
},
|
"licenses": [
|
||||||
"licenses": [
|
{
|
||||||
{
|
"type": "MIT",
|
||||||
"type": "MIT",
|
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
}
|
||||||
}
|
],
|
||||||
],
|
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
||||||
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
"docs": "https://github.com/faisalman/ua-parser-js",
|
||||||
"docs": "https://github.com/faisalman/ua-parser-js",
|
"download": "https://raw.github.com/faisalman/ua-parser-js/master/src/ua-parser.min.js"
|
||||||
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.min.js"
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user