mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-21 01:26:40 +03:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80d6d137ba | ||
|
|
19b5ddd038 | ||
|
|
9133d73d50 | ||
|
|
3699c70a3a | ||
|
|
e6d276032b | ||
|
|
b68caafd94 | ||
|
|
eed632e3dd | ||
|
|
c5ce73f7de | ||
|
|
2c9c721a5c | ||
|
|
ec50c619ea | ||
|
|
07a7956eda | ||
|
|
be0eec6716 | ||
|
|
8d439d26b8 |
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.6.0",
|
"version": "0.6.2",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device"],
|
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device", "cpu"],
|
||||||
"scripts": ["src/ua-parser.js"],
|
"scripts": ["src/ua-parser.js"],
|
||||||
"main": "src/ua-parser.js",
|
"main": "src/ua-parser.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.6.0",
|
"version": "0.6.2",
|
||||||
"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,7 +10,8 @@
|
|||||||
"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": [
|
||||||
|
|||||||
18
readme.md
18
readme.md
@@ -10,7 +10,7 @@ Lightweight JavaScript-based User-Agent string parser. Supports browser & node.j
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
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.
|
Extract detailed type of web browser, layout engine, operating system, cpu architecture, 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.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -23,11 +23,12 @@ Extract detailed type of web browser, layout engine, operating system, and devic
|
|||||||
# Possible 'browser.name':
|
# Possible 'browser.name':
|
||||||
Amaya, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome, Chromium,
|
Amaya, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome, Chromium,
|
||||||
Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Epiphany, Fennec, Firebird,
|
Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Epiphany, Fennec, Firebird,
|
||||||
Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, Iceweasel,
|
Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, IceDragon,
|
||||||
IE [Mobile], Jasmine, K-Meleon, Konqueror, Kindle, Links, Lunascape, Lynx, Maemo,
|
Iceweasel, IE [Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle, Links,
|
||||||
Maxthon, Midori, Minimo, [Mobile] Safari, Mosaic, Mozilla, Netfront, Netscape,
|
Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, [Mobile] Safari, Mosaic, Mozilla,
|
||||||
NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet], Phoenix, Polaris, RockMelt,
|
Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet], Phoenix,
|
||||||
Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox, Tizen, UCBrowser, w3m, Yandex
|
Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox,
|
||||||
|
Tizen, UCBrowser, w3m, Yandex
|
||||||
|
|
||||||
# 'browser.version' & 'browser.major' determined dynamically
|
# 'browser.version' & 'browser.major' determined dynamically
|
||||||
```
|
```
|
||||||
@@ -78,11 +79,11 @@ Windows [Phone/Mobile], Zenwalk
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Possible 'cpu.architecture'
|
# Possible 'cpu.architecture'
|
||||||
68k, amd64, arm, ia32, ia64, irix, mips, pa-risc, ppc, sparc
|
68k, amd64, arm, ia32, ia64, irix, irix64, mips, mips64, pa-risc, ppc, sparc, sparc64
|
||||||
```
|
```
|
||||||
|
|
||||||
* `getResult()`
|
* `getResult()`
|
||||||
* returns `{ browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
||||||
* `getUA()`
|
* `getUA()`
|
||||||
* returns UA string of current instance
|
* returns UA string of current instance
|
||||||
* `setUA(uastring)`
|
* `setUA(uastring)`
|
||||||
@@ -104,6 +105,7 @@ Windows [Phone/Mobile], Zenwalk
|
|||||||
/*
|
/*
|
||||||
/// this will print an object structured like this:
|
/// this will print an object structured like this:
|
||||||
{
|
{
|
||||||
|
ua: "",
|
||||||
browser: {
|
browser: {
|
||||||
name: "",
|
name: "",
|
||||||
version: "",
|
version: "",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// UAParser.js v0.6.0
|
// UAParser.js v0.6.2
|
||||||
// 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
|
||||||
//
|
//
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
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 in map[i]) {
|
for (var j = 0; j < map[i].length; j++) {
|
||||||
if (util.has(map[i][j], str)) {
|
if (util.has(map[i][j], str)) {
|
||||||
return (i === UNKNOWN) ? undefined : i;
|
return (i === UNKNOWN) ? undefined : i;
|
||||||
}
|
}
|
||||||
@@ -224,10 +224,13 @@
|
|||||||
|
|
||||||
// Webkit/KHTML based
|
// Webkit/KHTML based
|
||||||
/(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq
|
/(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq
|
||||||
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i
|
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron)\/((\d+)?[\w\.-]+)/i
|
||||||
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt
|
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron
|
||||||
], [NAME, VERSION, MAJOR], [
|
], [NAME, VERSION, MAJOR], [
|
||||||
|
|
||||||
|
/(trident).+rv[:\s]((\d+)?[\w\.]+).+like\sgecko/i // IE11
|
||||||
|
], [[NAME, 'IE'], VERSION, MAJOR], [
|
||||||
|
|
||||||
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
|
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
|
||||||
], [[NAME, 'Yandex'], VERSION, MAJOR], [
|
], [[NAME, 'Yandex'], VERSION, MAJOR], [
|
||||||
|
|
||||||
@@ -261,15 +264,15 @@
|
|||||||
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
|
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
|
||||||
], [[NAME, 'Netscape'], VERSION, MAJOR], [
|
], [[NAME, 'Netscape'], VERSION, MAJOR], [
|
||||||
/(swiftfox)/i, // Swiftfox
|
/(swiftfox)/i, // Swiftfox
|
||||||
/(iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,
|
/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,
|
||||||
// Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
|
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
|
||||||
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\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)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
|
/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?((\d+)?[\w\.]+)/i,
|
/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|qqbrowser)[\/\s]?((\d+)?[\w\.]+)/i,
|
||||||
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf
|
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/QQBrowser
|
||||||
/(links)\s\(((\d+)?[\w\.]+)/i, // Links
|
/(links)\s\(((\d+)?[\w\.]+)/i, // Links
|
||||||
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
|
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
|
||||||
/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser
|
/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser
|
||||||
@@ -285,6 +288,10 @@
|
|||||||
/((?:i[346]|x)86)[;\)]/i // IA32
|
/((?:i[346]|x)86)[;\)]/i // IA32
|
||||||
], [[ARCHITECTURE, 'ia32']], [
|
], [[ARCHITECTURE, 'ia32']], [
|
||||||
|
|
||||||
|
// PocketPC mistakenly identified as PowerPC
|
||||||
|
/windows\s(ce|mobile);\sppc;/i
|
||||||
|
], [[ARCHITECTURE, 'arm']], [
|
||||||
|
|
||||||
/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
|
/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
|
||||||
], [[ARCHITECTURE, /ower/, '', util.lowerize]], [
|
], [[ARCHITECTURE, /ower/, '', util.lowerize]], [
|
||||||
|
|
||||||
@@ -340,7 +347,8 @@
|
|||||||
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
|
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
|
||||||
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
||||||
|
|
||||||
/\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i, // Motorola
|
// Motorola
|
||||||
|
/\s((milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?))[\w\s]+build\//i,
|
||||||
/(mot)[\s-]?(\w+)*/i
|
/(mot)[\s-]?(\w+)*/i
|
||||||
], [[VENDOR, 'Motorola'], MODEL, [TYPE, MOBILE]], [
|
], [[VENDOR, 'Motorola'], MODEL, [TYPE, MOBILE]], [
|
||||||
/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i
|
/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i
|
||||||
@@ -475,6 +483,7 @@
|
|||||||
};
|
};
|
||||||
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(),
|
||||||
|
|||||||
8
src/ua-parser.min.js
vendored
8
src/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -240,7 +240,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"desc" : "IE 11",
|
"desc" : "IE 11 with IE token",
|
||||||
"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" :
|
||||||
{
|
{
|
||||||
@@ -249,6 +249,16 @@
|
|||||||
"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",
|
||||||
|
|||||||
@@ -47,6 +47,14 @@
|
|||||||
"architecture" : "arm"
|
"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",
|
"desc" : "Mac PowerPC",
|
||||||
"ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)",
|
"ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)",
|
||||||
|
|||||||
@@ -18,4 +18,14 @@
|
|||||||
"model" : "Nexus 4",
|
"model" : "Nexus 4",
|
||||||
"type" : "mobile"
|
"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"
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.6.0",
|
"version": "0.6.2",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"user-agent",
|
"user-agent",
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
"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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user