mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
commit
9c06febfce
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.14",
|
"version": "0.7.17",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Faisal Salman <fyzlman@gmail.com>"
|
"Faisal Salman <fyzlman@gmail.com>"
|
||||||
],
|
],
|
||||||
|
4
dist/ua-parser.min.js
vendored
4
dist/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
4
dist/ua-parser.pack.js
vendored
4
dist/ua-parser.pack.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
Package.describe({
|
Package.describe({
|
||||||
name: 'faisalman:ua-parser-js',
|
name: 'faisalman:ua-parser-js',
|
||||||
version: '0.7.14',
|
version: '0.7.17',
|
||||||
summary: 'Lightweight JavaScript-based user-agent string parser',
|
summary: 'Lightweight JavaScript-based user-agent string parser',
|
||||||
git: 'https://github.com/faisalman/ua-parser-js.git',
|
git: 'https://github.com/faisalman/ua-parser-js.git',
|
||||||
documentation: 'readme.md'
|
documentation: 'readme.md'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UAParser.js",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.7.14",
|
"version": "0.7.17",
|
||||||
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
|
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
14
readme.md
14
readme.md
@ -230,6 +230,18 @@ $ bower install ua-parser-js
|
|||||||
$ meteor add faisalman:ua-parser-js
|
$ meteor add faisalman:ua-parser-js
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Using CLI
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ node ua-parser.min.js "Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)"
|
||||||
|
# multiple args
|
||||||
|
$ node ua-parser.min.js "Opera/1.2" "Opera/3.4"
|
||||||
|
# piped args
|
||||||
|
$ echo "Opera/1.2" | node ua-parser.min.js
|
||||||
|
# log file
|
||||||
|
$ cat ua.log | node ua-parser.min.js
|
||||||
|
```
|
||||||
|
|
||||||
## Using jQuery/Zepto ($.ua)
|
## 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)`.
|
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)`.
|
||||||
@ -302,7 +314,7 @@ Do you use & like UAParser.js but you don’t find a way to show some love? If y
|
|||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
Dual licensed under GPLv2 & MIT
|
Dual licensed under GPLv2 or MIT
|
||||||
|
|
||||||
Copyright © 2012-2016 Faisal Salman <<fyzlman@gmail.com>>
|
Copyright © 2012-2016 Faisal Salman <<fyzlman@gmail.com>>
|
||||||
|
|
||||||
|
37
src/ua-parser.js
Normal file → Executable file
37
src/ua-parser.js
Normal file → Executable file
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* UAParser.js v0.7.14
|
* UAParser.js v0.7.17
|
||||||
* 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
|
||||||
*
|
*
|
||||||
@ -16,7 +16,7 @@
|
|||||||
/////////////
|
/////////////
|
||||||
|
|
||||||
|
|
||||||
var LIBVERSION = '0.7.14',
|
var LIBVERSION = '0.7.17',
|
||||||
EMPTY = '',
|
EMPTY = '',
|
||||||
UNKNOWN = '?',
|
UNKNOWN = '?',
|
||||||
FUNC_TYPE = 'function',
|
FUNC_TYPE = 'function',
|
||||||
@ -292,7 +292,7 @@
|
|||||||
/;fbav\/([\w\.]+);/i // Facebook App for iOS & Android
|
/;fbav\/([\w\.]+);/i // Facebook App for iOS & Android
|
||||||
], [VERSION, [NAME, 'Facebook']], [
|
], [VERSION, [NAME, 'Facebook']], [
|
||||||
|
|
||||||
/(headlesschrome) ([\w\.]+)/i // Chrome Headless
|
/headlesschrome(?:\/([\w\.]+)|\s)/i // Chrome Headless
|
||||||
], [VERSION, [NAME, 'Chrome Headless']], [
|
], [VERSION, [NAME, 'Chrome Headless']], [
|
||||||
|
|
||||||
/\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
|
/\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
|
||||||
@ -858,7 +858,7 @@
|
|||||||
], [NAME, VERSION],[
|
], [NAME, VERSION],[
|
||||||
|
|
||||||
/cfnetwork\/.+darwin/i,
|
/cfnetwork\/.+darwin/i,
|
||||||
/ip[honead]+(?:.*os\s([\w]+)*\slike\smac|;\sopera)/i // iOS
|
/ip[honead]+(?:.*os\s([\w]+)\slike\smac|;\sopera)/i // iOS
|
||||||
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
|
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
|
||||||
|
|
||||||
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i,
|
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i,
|
||||||
@ -1006,6 +1006,35 @@
|
|||||||
if (typeof module !== UNDEF_TYPE && module.exports) {
|
if (typeof module !== UNDEF_TYPE && module.exports) {
|
||||||
exports = module.exports = UAParser;
|
exports = module.exports = UAParser;
|
||||||
}
|
}
|
||||||
|
// TODO: test!!!!!!!!
|
||||||
|
/*
|
||||||
|
if (require && require.main === module && process) {
|
||||||
|
// cli
|
||||||
|
var jsonize = function (arr) {
|
||||||
|
var res = [];
|
||||||
|
for (var i in arr) {
|
||||||
|
res.push(new UAParser(arr[i]).getResult());
|
||||||
|
}
|
||||||
|
process.stdout.write(JSON.stringify(res, null, 2) + '\n');
|
||||||
|
};
|
||||||
|
if (process.stdin.isTTY) {
|
||||||
|
// via args
|
||||||
|
jsonize(process.argv.slice(2));
|
||||||
|
} else {
|
||||||
|
// via pipe
|
||||||
|
var str = '';
|
||||||
|
process.stdin.on('readable', function() {
|
||||||
|
var read = process.stdin.read();
|
||||||
|
if (read !== null) {
|
||||||
|
str += read;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
process.stdin.on('end', function () {
|
||||||
|
jsonize(str.replace(/\n$/, '').split('\n'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
exports.UAParser = UAParser;
|
exports.UAParser = UAParser;
|
||||||
} else {
|
} else {
|
||||||
// requirejs env (optional)
|
// requirejs env (optional)
|
||||||
|
@ -1,14 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"desc" : "Chrome Headless",
|
|
||||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36",
|
|
||||||
"expect" :
|
|
||||||
{
|
|
||||||
"name" : "Chrome Headless",
|
|
||||||
"version" : "HeadlessChrome",
|
|
||||||
"major" : ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"desc" : "Android Browser on Galaxy Nexus",
|
"desc" : "Android Browser on Galaxy Nexus",
|
||||||
"ua" : "Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
"ua" : "Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||||
@ -149,6 +139,26 @@
|
|||||||
"major" : "20"
|
"major" : "20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"desc" : "Chrome Headless",
|
||||||
|
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36",
|
||||||
|
"expect" :
|
||||||
|
{
|
||||||
|
"name" : "Chrome Headless",
|
||||||
|
"version" : "undefined",
|
||||||
|
"major" : "undefined"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"desc" : "Chrome Headless",
|
||||||
|
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/60.0.3112.113 Safari/537.36",
|
||||||
|
"expect" :
|
||||||
|
{
|
||||||
|
"name" : "Chrome Headless",
|
||||||
|
"version" : "60.0.3112.113",
|
||||||
|
"major" : "60"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"desc" : "Chrome WebView",
|
"desc" : "Chrome WebView",
|
||||||
"ua" : "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36",
|
"ua" : "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user