1 | /////////////////////////////////////////////////////////////////////////////////
|
---|
2 | /* UAParser.js v0.7.31
|
---|
3 | Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
|
---|
4 | MIT License *//*
|
---|
5 | Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
|
---|
6 | Supports browser & node.js environment.
|
---|
7 | Demo : https://faisalman.github.io/ua-parser-js
|
---|
8 | Source : https://github.com/faisalman/ua-parser-js */
|
---|
9 | /////////////////////////////////////////////////////////////////////////////////
|
---|
10 |
|
---|
11 | (function (window, undefined) {
|
---|
12 |
|
---|
13 | 'use strict';
|
---|
14 |
|
---|
15 | //////////////
|
---|
16 | // Constants
|
---|
17 | /////////////
|
---|
18 |
|
---|
19 |
|
---|
20 | var LIBVERSION = '0.7.31',
|
---|
21 | EMPTY = '',
|
---|
22 | UNKNOWN = '?',
|
---|
23 | FUNC_TYPE = 'function',
|
---|
24 | UNDEF_TYPE = 'undefined',
|
---|
25 | OBJ_TYPE = 'object',
|
---|
26 | STR_TYPE = 'string',
|
---|
27 | MAJOR = 'major',
|
---|
28 | MODEL = 'model',
|
---|
29 | NAME = 'name',
|
---|
30 | TYPE = 'type',
|
---|
31 | VENDOR = 'vendor',
|
---|
32 | VERSION = 'version',
|
---|
33 | ARCHITECTURE= 'architecture',
|
---|
34 | CONSOLE = 'console',
|
---|
35 | MOBILE = 'mobile',
|
---|
36 | TABLET = 'tablet',
|
---|
37 | SMARTTV = 'smarttv',
|
---|
38 | WEARABLE = 'wearable',
|
---|
39 | EMBEDDED = 'embedded',
|
---|
40 | UA_MAX_LENGTH = 255;
|
---|
41 |
|
---|
42 | var AMAZON = 'Amazon',
|
---|
43 | APPLE = 'Apple',
|
---|
44 | ASUS = 'ASUS',
|
---|
45 | BLACKBERRY = 'BlackBerry',
|
---|
46 | BROWSER = 'Browser',
|
---|
47 | CHROME = 'Chrome',
|
---|
48 | EDGE = 'Edge',
|
---|
49 | FIREFOX = 'Firefox',
|
---|
50 | GOOGLE = 'Google',
|
---|
51 | HUAWEI = 'Huawei',
|
---|
52 | LG = 'LG',
|
---|
53 | MICROSOFT = 'Microsoft',
|
---|
54 | MOTOROLA = 'Motorola',
|
---|
55 | OPERA = 'Opera',
|
---|
56 | SAMSUNG = 'Samsung',
|
---|
57 | SONY = 'Sony',
|
---|
58 | XIAOMI = 'Xiaomi',
|
---|
59 | ZEBRA = 'Zebra',
|
---|
60 | FACEBOOK = 'Facebook';
|
---|
61 |
|
---|
62 | ///////////
|
---|
63 | // Helper
|
---|
64 | //////////
|
---|
65 |
|
---|
66 | var extend = function (regexes, extensions) {
|
---|
67 | var mergedRegexes = {};
|
---|
68 | for (var i in regexes) {
|
---|
69 | if (extensions[i] && extensions[i].length % 2 === 0) {
|
---|
70 | mergedRegexes[i] = extensions[i].concat(regexes[i]);
|
---|
71 | } else {
|
---|
72 | mergedRegexes[i] = regexes[i];
|
---|
73 | }
|
---|
74 | }
|
---|
75 | return mergedRegexes;
|
---|
76 | },
|
---|
77 | enumerize = function (arr) {
|
---|
78 | var enums = {};
|
---|
79 | for (var i=0; i<arr.length; i++) {
|
---|
80 | enums[arr[i].toUpperCase()] = arr[i];
|
---|
81 | }
|
---|
82 | return enums;
|
---|
83 | },
|
---|
84 | has = function (str1, str2) {
|
---|
85 | return typeof str1 === STR_TYPE ? lowerize(str2).indexOf(lowerize(str1)) !== -1 : false;
|
---|
86 | },
|
---|
87 | lowerize = function (str) {
|
---|
88 | return str.toLowerCase();
|
---|
89 | },
|
---|
90 | majorize = function (version) {
|
---|
91 | return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split('.')[0] : undefined;
|
---|
92 | },
|
---|
93 | trim = function (str, len) {
|
---|
94 | if (typeof(str) === STR_TYPE) {
|
---|
95 | str = str.replace(/^\s\s*/, EMPTY).replace(/\s\s*$/, EMPTY);
|
---|
96 | return typeof(len) === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
|
---|
97 | }
|
---|
98 | };
|
---|
99 |
|
---|
100 | ///////////////
|
---|
101 | // Map helper
|
---|
102 | //////////////
|
---|
103 |
|
---|
104 | var rgxMapper = function (ua, arrays) {
|
---|
105 |
|
---|
106 | var i = 0, j, k, p, q, matches, match;
|
---|
107 |
|
---|
108 | // loop through all regexes maps
|
---|
109 | while (i < arrays.length && !matches) {
|
---|
110 |
|
---|
111 | var regex = arrays[i], // even sequence (0,2,4,..)
|
---|
112 | props = arrays[i + 1]; // odd sequence (1,3,5,..)
|
---|
113 | j = k = 0;
|
---|
114 |
|
---|
115 | // try matching uastring with regexes
|
---|
116 | while (j < regex.length && !matches) {
|
---|
117 |
|
---|
118 | matches = regex[j++].exec(ua);
|
---|
119 |
|
---|
120 | if (!!matches) {
|
---|
121 | for (p = 0; p < props.length; p++) {
|
---|
122 | match = matches[++k];
|
---|
123 | q = props[p];
|
---|
124 | // check if given property is actually array
|
---|
125 | if (typeof q === OBJ_TYPE && q.length > 0) {
|
---|
126 | if (q.length === 2) {
|
---|
127 | if (typeof q[1] == FUNC_TYPE) {
|
---|
128 | // assign modified match
|
---|
129 | this[q[0]] = q[1].call(this, match);
|
---|
130 | } else {
|
---|
131 | // assign given value, ignore regex match
|
---|
132 | this[q[0]] = q[1];
|
---|
133 | }
|
---|
134 | } else if (q.length === 3) {
|
---|
135 | // check whether function or regex
|
---|
136 | if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
|
---|
137 | // call function (usually string mapper)
|
---|
138 | this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
|
---|
139 | } else {
|
---|
140 | // sanitize match using given regex
|
---|
141 | this[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
|
---|
142 | }
|
---|
143 | } else if (q.length === 4) {
|
---|
144 | this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
|
---|
145 | }
|
---|
146 | } else {
|
---|
147 | this[q] = match ? match : undefined;
|
---|
148 | }
|
---|
149 | }
|
---|
150 | }
|
---|
151 | }
|
---|
152 | i += 2;
|
---|
153 | }
|
---|
154 | },
|
---|
155 |
|
---|
156 | strMapper = function (str, map) {
|
---|
157 |
|
---|
158 | for (var i in map) {
|
---|
159 | // check if current value is array
|
---|
160 | if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
|
---|
161 | for (var j = 0; j < map[i].length; j++) {
|
---|
162 | if (has(map[i][j], str)) {
|
---|
163 | return (i === UNKNOWN) ? undefined : i;
|
---|
164 | }
|
---|
165 | }
|
---|
166 | } else if (has(map[i], str)) {
|
---|
167 | return (i === UNKNOWN) ? undefined : i;
|
---|
168 | }
|
---|
169 | }
|
---|
170 | return str;
|
---|
171 | };
|
---|
172 |
|
---|
173 | ///////////////
|
---|
174 | // String map
|
---|
175 | //////////////
|
---|
176 |
|
---|
177 | // Safari < 3.0
|
---|
178 | var oldSafariMap = {
|
---|
179 | '1.0' : '/8',
|
---|
180 | '1.2' : '/1',
|
---|
181 | '1.3' : '/3',
|
---|
182 | '2.0' : '/412',
|
---|
183 | '2.0.2' : '/416',
|
---|
184 | '2.0.3' : '/417',
|
---|
185 | '2.0.4' : '/419',
|
---|
186 | '?' : '/'
|
---|
187 | },
|
---|
188 | windowsVersionMap = {
|
---|
189 | 'ME' : '4.90',
|
---|
190 | 'NT 3.11' : 'NT3.51',
|
---|
191 | 'NT 4.0' : 'NT4.0',
|
---|
192 | '2000' : 'NT 5.0',
|
---|
193 | 'XP' : ['NT 5.1', 'NT 5.2'],
|
---|
194 | 'Vista' : 'NT 6.0',
|
---|
195 | '7' : 'NT 6.1',
|
---|
196 | '8' : 'NT 6.2',
|
---|
197 | '8.1' : 'NT 6.3',
|
---|
198 | '10' : ['NT 6.4', 'NT 10.0'],
|
---|
199 | 'RT' : 'ARM'
|
---|
200 | };
|
---|
201 |
|
---|
202 | //////////////
|
---|
203 | // Regex map
|
---|
204 | /////////////
|
---|
205 |
|
---|
206 | var regexes = {
|
---|
207 |
|
---|
208 | browser : [[
|
---|
209 |
|
---|
210 | /\b(?:crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
|
---|
211 | ], [VERSION, [NAME, 'Chrome']], [
|
---|
212 | /edg(?:e|ios|a)?\/([\w\.]+)/i // Microsoft Edge
|
---|
213 | ], [VERSION, [NAME, 'Edge']], [
|
---|
214 |
|
---|
215 | // Presto based
|
---|
216 | /(opera mini)\/([-\w\.]+)/i, // Opera Mini
|
---|
217 | /(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i, // Opera Mobi/Tablet
|
---|
218 | /(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i // Opera
|
---|
219 | ], [NAME, VERSION], [
|
---|
220 | /opios[\/ ]+([\w\.]+)/i // Opera mini on iphone >= 8.0
|
---|
221 | ], [VERSION, [NAME, OPERA+' Mini']], [
|
---|
222 | /\bopr\/([\w\.]+)/i // Opera Webkit
|
---|
223 | ], [VERSION, [NAME, OPERA]], [
|
---|
224 |
|
---|
225 | // Mixed
|
---|
226 | /(kindle)\/([\w\.]+)/i, // Kindle
|
---|
227 | /(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i, // Lunascape/Maxthon/Netfront/Jasmine/Blazer
|
---|
228 | // Trident based
|
---|
229 | /(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i, // Avant/IEMobile/SlimBrowser
|
---|
230 | /(ba?idubrowser)[\/ ]?([\w\.]+)/i, // Baidu Browser
|
---|
231 | /(?:ms|\()(ie) ([\w\.]+)/i, // Internet Explorer
|
---|
232 |
|
---|
233 | // Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
|
---|
234 | /(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq)\/([-\w\.]+)/i,
|
---|
235 | // Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ, aka ShouQ
|
---|
236 | /(weibo)__([\d\.]+)/i // Weibo
|
---|
237 | ], [NAME, VERSION], [
|
---|
238 | /(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser
|
---|
239 | ], [VERSION, [NAME, 'UC'+BROWSER]], [
|
---|
240 | /\bqbcore\/([\w\.]+)/i // WeChat Desktop for Windows Built-in Browser
|
---|
241 | ], [VERSION, [NAME, 'WeChat(Win) Desktop']], [
|
---|
242 | /micromessenger\/([\w\.]+)/i // WeChat
|
---|
243 | ], [VERSION, [NAME, 'WeChat']], [
|
---|
244 | /konqueror\/([\w\.]+)/i // Konqueror
|
---|
245 | ], [VERSION, [NAME, 'Konqueror']], [
|
---|
246 | /trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i // IE11
|
---|
247 | ], [VERSION, [NAME, 'IE']], [
|
---|
248 | /yabrowser\/([\w\.]+)/i // Yandex
|
---|
249 | ], [VERSION, [NAME, 'Yandex']], [
|
---|
250 | /(avast|avg)\/([\w\.]+)/i // Avast/AVG Secure Browser
|
---|
251 | ], [[NAME, /(.+)/, '$1 Secure '+BROWSER], VERSION], [
|
---|
252 | /\bfocus\/([\w\.]+)/i // Firefox Focus
|
---|
253 | ], [VERSION, [NAME, FIREFOX+' Focus']], [
|
---|
254 | /\bopt\/([\w\.]+)/i // Opera Touch
|
---|
255 | ], [VERSION, [NAME, OPERA+' Touch']], [
|
---|
256 | /coc_coc\w+\/([\w\.]+)/i // Coc Coc Browser
|
---|
257 | ], [VERSION, [NAME, 'Coc Coc']], [
|
---|
258 | /dolfin\/([\w\.]+)/i // Dolphin
|
---|
259 | ], [VERSION, [NAME, 'Dolphin']], [
|
---|
260 | /coast\/([\w\.]+)/i // Opera Coast
|
---|
261 | ], [VERSION, [NAME, OPERA+' Coast']], [
|
---|
262 | /miuibrowser\/([\w\.]+)/i // MIUI Browser
|
---|
263 | ], [VERSION, [NAME, 'MIUI '+BROWSER]], [
|
---|
264 | /fxios\/([-\w\.]+)/i // Firefox for iOS
|
---|
265 | ], [VERSION, [NAME, FIREFOX]], [
|
---|
266 | /\bqihu|(qi?ho?o?|360)browser/i // 360
|
---|
267 | ], [[NAME, '360 '+BROWSER]], [
|
---|
268 | /(oculus|samsung|sailfish)browser\/([\w\.]+)/i
|
---|
269 | ], [[NAME, /(.+)/, '$1 '+BROWSER], VERSION], [ // Oculus/Samsung/Sailfish Browser
|
---|
270 | /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
|
---|
271 | ], [[NAME, /_/g, ' '], VERSION], [
|
---|
272 | /(electron)\/([\w\.]+) safari/i, // Electron-based App
|
---|
273 | /(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, // Tesla
|
---|
274 | /m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i // QQBrowser/Baidu App/2345 Browser
|
---|
275 | ], [NAME, VERSION], [
|
---|
276 | /(metasr)[\/ ]?([\w\.]+)/i, // SouGouBrowser
|
---|
277 | /(lbbrowser)/i // LieBao Browser
|
---|
278 | ], [NAME], [
|
---|
279 |
|
---|
280 | // WebView
|
---|
281 | /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
|
---|
282 | ], [[NAME, FACEBOOK], VERSION], [
|
---|
283 | /safari (line)\/([\w\.]+)/i, // Line App for iOS
|
---|
284 | /\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
|
---|
285 | /(chromium|instagram)[\/ ]([-\w\.]+)/i // Chromium/Instagram
|
---|
286 | ], [NAME, VERSION], [
|
---|
287 | /\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
|
---|
288 | ], [VERSION, [NAME, 'GSA']], [
|
---|
289 |
|
---|
290 | /headlesschrome(?:\/([\w\.]+)| )/i // Chrome Headless
|
---|
291 | ], [VERSION, [NAME, CHROME+' Headless']], [
|
---|
292 |
|
---|
293 | / wv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
|
---|
294 | ], [[NAME, CHROME+' WebView'], VERSION], [
|
---|
295 |
|
---|
296 | /droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i // Android Browser
|
---|
297 | ], [VERSION, [NAME, 'Android '+BROWSER]], [
|
---|
298 |
|
---|
299 | /(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i // Chrome/OmniWeb/Arora/Tizen/Nokia
|
---|
300 | ], [NAME, VERSION], [
|
---|
301 |
|
---|
302 | /version\/([\w\.]+) .*mobile\/\w+ (safari)/i // Mobile Safari
|
---|
303 | ], [VERSION, [NAME, 'Mobile Safari']], [
|
---|
304 | /version\/([\w\.]+) .*(mobile ?safari|safari)/i // Safari & Safari Mobile
|
---|
305 | ], [VERSION, NAME], [
|
---|
306 | /webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
|
---|
307 | ], [NAME, [VERSION, strMapper, oldSafariMap]], [
|
---|
308 |
|
---|
309 | /(webkit|khtml)\/([\w\.]+)/i
|
---|
310 | ], [NAME, VERSION], [
|
---|
311 |
|
---|
312 | // Gecko based
|
---|
313 | /(navigator|netscape\d?)\/([-\w\.]+)/i // Netscape
|
---|
314 | ], [[NAME, 'Netscape'], VERSION], [
|
---|
315 | /mobile vr; rv:([\w\.]+)\).+firefox/i // Firefox Reality
|
---|
316 | ], [VERSION, [NAME, FIREFOX+' Reality']], [
|
---|
317 | /ekiohf.+(flow)\/([\w\.]+)/i, // Flow
|
---|
318 | /(swiftfox)/i, // Swiftfox
|
---|
319 | /(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,
|
---|
320 | // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror/Klar
|
---|
321 | /(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,
|
---|
322 | // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
|
---|
323 | /(firefox)\/([\w\.]+)/i, // Other Firefox-based
|
---|
324 | /(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i, // Mozilla
|
---|
325 |
|
---|
326 | // Other
|
---|
327 | /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
|
---|
328 | // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir/Obigo/Mosaic/Go/ICE/UP.Browser
|
---|
329 | /(links) \(([\w\.]+)/i // Links
|
---|
330 | ], [NAME, VERSION]
|
---|
331 | ],
|
---|
332 |
|
---|
333 | cpu : [[
|
---|
334 |
|
---|
335 | /(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i // AMD64 (x64)
|
---|
336 | ], [[ARCHITECTURE, 'amd64']], [
|
---|
337 |
|
---|
338 | /(ia32(?=;))/i // IA32 (quicktime)
|
---|
339 | ], [[ARCHITECTURE, lowerize]], [
|
---|
340 |
|
---|
341 | /((?:i[346]|x)86)[;\)]/i // IA32 (x86)
|
---|
342 | ], [[ARCHITECTURE, 'ia32']], [
|
---|
343 |
|
---|
344 | /\b(aarch64|arm(v?8e?l?|_?64))\b/i // ARM64
|
---|
345 | ], [[ARCHITECTURE, 'arm64']], [
|
---|
346 |
|
---|
347 | /\b(arm(?:v[67])?ht?n?[fl]p?)\b/i // ARMHF
|
---|
348 | ], [[ARCHITECTURE, 'armhf']], [
|
---|
349 |
|
---|
350 | // PocketPC mistakenly identified as PowerPC
|
---|
351 | /windows (ce|mobile); ppc;/i
|
---|
352 | ], [[ARCHITECTURE, 'arm']], [
|
---|
353 |
|
---|
354 | /((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i // PowerPC
|
---|
355 | ], [[ARCHITECTURE, /ower/, EMPTY, lowerize]], [
|
---|
356 |
|
---|
357 | /(sun4\w)[;\)]/i // SPARC
|
---|
358 | ], [[ARCHITECTURE, 'sparc']], [
|
---|
359 |
|
---|
360 | /((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i
|
---|
361 | // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
|
---|
362 | ], [[ARCHITECTURE, lowerize]]
|
---|
363 | ],
|
---|
364 |
|
---|
365 | device : [[
|
---|
366 |
|
---|
367 | //////////////////////////
|
---|
368 | // MOBILES & TABLETS
|
---|
369 | // Ordered by popularity
|
---|
370 | /////////////////////////
|
---|
371 |
|
---|
372 | // Samsung
|
---|
373 | /\b(sch-i[89]0\d|shw-m380s|sm-[pt]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
|
---|
374 | ], [MODEL, [VENDOR, SAMSUNG], [TYPE, TABLET]], [
|
---|
375 | /\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,
|
---|
376 | /samsung[- ]([-\w]+)/i,
|
---|
377 | /sec-(sgh\w+)/i
|
---|
378 | ], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [
|
---|
379 |
|
---|
380 | // Apple
|
---|
381 | /\((ip(?:hone|od)[\w ]*);/i // iPod/iPhone
|
---|
382 | ], [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]], [
|
---|
383 | /\((ipad);[-\w\),; ]+apple/i, // iPad
|
---|
384 | /applecoremedia\/[\w\.]+ \((ipad)/i,
|
---|
385 | /\b(ipad)\d\d?,\d\d?[;\]].+ios/i
|
---|
386 | ], [MODEL, [VENDOR, APPLE], [TYPE, TABLET]], [
|
---|
387 |
|
---|
388 | // Huawei
|
---|
389 | /\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
|
---|
390 | ], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [
|
---|
391 | /(?:huawei|honor)([-\w ]+)[;\)]/i,
|
---|
392 | /\b(nexus 6p|\w{2,4}-[atu]?[ln][01259x][012359][an]?)\b(?!.+d\/s)/i
|
---|
393 | ], [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]], [
|
---|
394 |
|
---|
395 | // Xiaomi
|
---|
396 | /\b(poco[\w ]+)(?: bui|\))/i, // Xiaomi POCO
|
---|
397 | /\b; (\w+) build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
|
---|
398 | /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i, // Xiaomi Hongmi
|
---|
399 | /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i, // Xiaomi Redmi
|
---|
400 | /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i // Xiaomi Mi
|
---|
401 | ], [[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, MOBILE]], [
|
---|
402 | /\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i // Mi Pad tablets
|
---|
403 | ],[[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, TABLET]], [
|
---|
404 |
|
---|
405 | // OPPO
|
---|
406 | /; (\w+) bui.+ oppo/i,
|
---|
407 | /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
|
---|
408 | ], [MODEL, [VENDOR, 'OPPO'], [TYPE, MOBILE]], [
|
---|
409 |
|
---|
410 | // Vivo
|
---|
411 | /vivo (\w+)(?: bui|\))/i,
|
---|
412 | /\b(v[12]\d{3}\w?[at])(?: bui|;)/i
|
---|
413 | ], [MODEL, [VENDOR, 'Vivo'], [TYPE, MOBILE]], [
|
---|
414 |
|
---|
415 | // Realme
|
---|
416 | /\b(rmx[12]\d{3})(?: bui|;|\))/i
|
---|
417 | ], [MODEL, [VENDOR, 'Realme'], [TYPE, MOBILE]], [
|
---|
418 |
|
---|
419 | // Motorola
|
---|
420 | /\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,
|
---|
421 | /\bmot(?:orola)?[- ](\w*)/i,
|
---|
422 | /((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i
|
---|
423 | ], [MODEL, [VENDOR, MOTOROLA], [TYPE, MOBILE]], [
|
---|
424 | /\b(mz60\d|xoom[2 ]{0,2}) build\//i
|
---|
425 | ], [MODEL, [VENDOR, MOTOROLA], [TYPE, TABLET]], [
|
---|
426 |
|
---|
427 | // LG
|
---|
428 | /((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
|
---|
429 | ], [MODEL, [VENDOR, LG], [TYPE, TABLET]], [
|
---|
430 | /(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
|
---|
431 | /\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,
|
---|
432 | /\blg-?([\d\w]+) bui/i
|
---|
433 | ], [MODEL, [VENDOR, LG], [TYPE, MOBILE]], [
|
---|
434 |
|
---|
435 | // Lenovo
|
---|
436 | /(ideatab[-\w ]+)/i,
|
---|
437 | /lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i
|
---|
438 | ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
|
---|
439 |
|
---|
440 | // Nokia
|
---|
441 | /(?:maemo|nokia).*(n900|lumia \d+)/i,
|
---|
442 | /nokia[-_ ]?([-\w\.]*)/i
|
---|
443 | ], [[MODEL, /_/g, ' '], [VENDOR, 'Nokia'], [TYPE, MOBILE]], [
|
---|
444 |
|
---|
445 | // Google
|
---|
446 | /(pixel c)\b/i // Google Pixel C
|
---|
447 | ], [MODEL, [VENDOR, GOOGLE], [TYPE, TABLET]], [
|
---|
448 | /droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i // Google Pixel
|
---|
449 | ], [MODEL, [VENDOR, GOOGLE], [TYPE, MOBILE]], [
|
---|
450 |
|
---|
451 | // Sony
|
---|
452 | /droid.+ ([c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i
|
---|
453 | ], [MODEL, [VENDOR, SONY], [TYPE, MOBILE]], [
|
---|
454 | /sony tablet [ps]/i,
|
---|
455 | /\b(?:sony)?sgp\w+(?: bui|\))/i
|
---|
456 | ], [[MODEL, 'Xperia Tablet'], [VENDOR, SONY], [TYPE, TABLET]], [
|
---|
457 |
|
---|
458 | // OnePlus
|
---|
459 | / (kb2005|in20[12]5|be20[12][59])\b/i,
|
---|
460 | /(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
|
---|
461 | ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [
|
---|
462 |
|
---|
463 | // Amazon
|
---|
464 | /(alexa)webm/i,
|
---|
465 | /(kf[a-z]{2}wi)( bui|\))/i, // Kindle Fire without Silk
|
---|
466 | /(kf[a-z]+)( bui|\)).+silk\//i // Kindle Fire HD
|
---|
467 | ], [MODEL, [VENDOR, AMAZON], [TYPE, TABLET]], [
|
---|
468 | /((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i // Fire Phone
|
---|
469 | ], [[MODEL, /(.+)/g, 'Fire Phone $1'], [VENDOR, AMAZON], [TYPE, MOBILE]], [
|
---|
470 |
|
---|
471 | // BlackBerry
|
---|
472 | /(playbook);[-\w\),; ]+(rim)/i // BlackBerry PlayBook
|
---|
473 | ], [MODEL, VENDOR, [TYPE, TABLET]], [
|
---|
474 | /\b((?:bb[a-f]|st[hv])100-\d)/i,
|
---|
475 | /\(bb10; (\w+)/i // BlackBerry 10
|
---|
476 | ], [MODEL, [VENDOR, BLACKBERRY], [TYPE, MOBILE]], [
|
---|
477 |
|
---|
478 | // Asus
|
---|
479 | /(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i
|
---|
480 | ], [MODEL, [VENDOR, ASUS], [TYPE, TABLET]], [
|
---|
481 | / (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i
|
---|
482 | ], [MODEL, [VENDOR, ASUS], [TYPE, MOBILE]], [
|
---|
483 |
|
---|
484 | // HTC
|
---|
485 | /(nexus 9)/i // HTC Nexus 9
|
---|
486 | ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
|
---|
487 | /(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i, // HTC
|
---|
488 |
|
---|
489 | // ZTE
|
---|
490 | /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
|
---|
491 | /(alcatel|geeksphone|nexian|panasonic|sony)[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
|
---|
492 | ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
---|
493 |
|
---|
494 | // Acer
|
---|
495 | /droid.+; ([ab][1-7]-?[0178a]\d\d?)/i
|
---|
496 | ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
|
---|
497 |
|
---|
498 | // Meizu
|
---|
499 | /droid.+; (m[1-5] note) bui/i,
|
---|
500 | /\bmz-([-\w]{2,})/i
|
---|
501 | ], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [
|
---|
502 |
|
---|
503 | // Sharp
|
---|
504 | /\b(sh-?[altvz]?\d\d[a-ekm]?)/i
|
---|
505 | ], [MODEL, [VENDOR, 'Sharp'], [TYPE, MOBILE]], [
|
---|
506 |
|
---|
507 | // MIXED
|
---|
508 | /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,
|
---|
509 | // BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
|
---|
510 | /(hp) ([\w ]+\w)/i, // HP iPAQ
|
---|
511 | /(asus)-?(\w+)/i, // Asus
|
---|
512 | /(microsoft); (lumia[\w ]+)/i, // Microsoft Lumia
|
---|
513 | /(lenovo)[-_ ]?([-\w]+)/i, // Lenovo
|
---|
514 | /(jolla)/i, // Jolla
|
---|
515 | /(oppo) ?([\w ]+) bui/i // OPPO
|
---|
516 | ], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
---|
517 |
|
---|
518 | /(archos) (gamepad2?)/i, // Archos
|
---|
519 | /(hp).+(touchpad(?!.+tablet)|tablet)/i, // HP TouchPad
|
---|
520 | /(kindle)\/([\w\.]+)/i, // Kindle
|
---|
521 | /(nook)[\w ]+build\/(\w+)/i, // Nook
|
---|
522 | /(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
|
---|
523 | /(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
|
---|
524 | /(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
|
---|
525 | /(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
|
---|
526 | /(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
|
---|
527 | ], [VENDOR, MODEL, [TYPE, TABLET]], [
|
---|
528 |
|
---|
529 | /(surface duo)/i // Surface Duo
|
---|
530 | ], [MODEL, [VENDOR, MICROSOFT], [TYPE, TABLET]], [
|
---|
531 | /droid [\d\.]+; (fp\du?)(?: b|\))/i // Fairphone
|
---|
532 | ], [MODEL, [VENDOR, 'Fairphone'], [TYPE, MOBILE]], [
|
---|
533 | /(u304aa)/i // AT&T
|
---|
534 | ], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
|
---|
535 | /\bsie-(\w*)/i // Siemens
|
---|
536 | ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
|
---|
537 | /\b(rct\w+) b/i // RCA Tablets
|
---|
538 | ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
|
---|
539 | /\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
|
---|
540 | ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
|
---|
541 | /\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
|
---|
542 | ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
|
---|
543 | /\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
|
---|
544 | ], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
|
---|
545 | /\b(tm\d{3}\w+) b/i
|
---|
546 | ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
|
---|
547 | /\b(k88) b/i // ZTE K Series Tablet
|
---|
548 | ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
|
---|
549 | /\b(nx\d{3}j) b/i // ZTE Nubia
|
---|
550 | ], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
|
---|
551 | /\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
|
---|
552 | ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
|
---|
553 | /\b(zur\d{3}) b/i // Swiss ZUR Tablet
|
---|
554 | ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
|
---|
555 | /\b((zeki)?tb.*\b) b/i // Zeki Tablets
|
---|
556 | ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
|
---|
557 | /\b([yr]\d{2}) b/i,
|
---|
558 | /\b(dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
|
---|
559 | ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [
|
---|
560 | /\b(ns-?\w{0,9}) b/i // Insignia Tablets
|
---|
561 | ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
|
---|
562 | /\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
|
---|
563 | ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
|
---|
564 | /\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
|
---|
565 | ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
|
---|
566 | /\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
|
---|
567 | ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
|
---|
568 | /\b(ph-1) /i // Essential PH-1
|
---|
569 | ], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
|
---|
570 | /\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
|
---|
571 | ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
|
---|
572 | /\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
|
---|
573 | ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
|
---|
574 | /\btu_(1491) b/i // Rotor Tablets
|
---|
575 | ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
|
---|
576 | /(shield[\w ]+) b/i // Nvidia Shield Tablets
|
---|
577 | ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, TABLET]], [
|
---|
578 | /(sprint) (\w+)/i // Sprint Phones
|
---|
579 | ], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
---|
580 | /(kin\.[onetw]{3})/i // Microsoft Kin
|
---|
581 | ], [[MODEL, /\./g, ' '], [VENDOR, MICROSOFT], [TYPE, MOBILE]], [
|
---|
582 | /droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i // Zebra
|
---|
583 | ], [MODEL, [VENDOR, ZEBRA], [TYPE, TABLET]], [
|
---|
584 | /droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
|
---|
585 | ], [MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]], [
|
---|
586 |
|
---|
587 | ///////////////////
|
---|
588 | // CONSOLES
|
---|
589 | ///////////////////
|
---|
590 |
|
---|
591 | /(ouya)/i, // Ouya
|
---|
592 | /(nintendo) ([wids3utch]+)/i // Nintendo
|
---|
593 | ], [VENDOR, MODEL, [TYPE, CONSOLE]], [
|
---|
594 | /droid.+; (shield) bui/i // Nvidia
|
---|
595 | ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
|
---|
596 | /(playstation [345portablevi]+)/i // Playstation
|
---|
597 | ], [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]], [
|
---|
598 | /\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
|
---|
599 | ], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [
|
---|
600 |
|
---|
601 | ///////////////////
|
---|
602 | // SMARTTVS
|
---|
603 | ///////////////////
|
---|
604 |
|
---|
605 | /smart-tv.+(samsung)/i // Samsung
|
---|
606 | ], [VENDOR, [TYPE, SMARTTV]], [
|
---|
607 | /hbbtv.+maple;(\d+)/i
|
---|
608 | ], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
|
---|
609 | /(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
|
---|
610 | ], [[VENDOR, LG], [TYPE, SMARTTV]], [
|
---|
611 | /(apple) ?tv/i // Apple TV
|
---|
612 | ], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
|
---|
613 | /crkey/i // Google Chromecast
|
---|
614 | ], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
|
---|
615 | /droid.+aft(\w)( bui|\))/i // Fire TV
|
---|
616 | ], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
|
---|
617 | /\(dtv[\);].+(aquos)/i // Sharp
|
---|
618 | ], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [
|
---|
619 | /\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
|
---|
620 | /hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i // HbbTV devices
|
---|
621 | ], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
|
---|
622 | /\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
|
---|
623 | ], [[TYPE, SMARTTV]], [
|
---|
624 |
|
---|
625 | ///////////////////
|
---|
626 | // WEARABLES
|
---|
627 | ///////////////////
|
---|
628 |
|
---|
629 | /((pebble))app/i // Pebble
|
---|
630 | ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
|
---|
631 | /droid.+; (glass) \d/i // Google Glass
|
---|
632 | ], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [
|
---|
633 | /droid.+; (wt63?0{2,3})\)/i
|
---|
634 | ], [MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]], [
|
---|
635 | /(quest( 2)?)/i // Oculus Quest
|
---|
636 | ], [MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]], [
|
---|
637 |
|
---|
638 | ///////////////////
|
---|
639 | // EMBEDDED
|
---|
640 | ///////////////////
|
---|
641 |
|
---|
642 | /(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i // Tesla
|
---|
643 | ], [VENDOR, [TYPE, EMBEDDED]], [
|
---|
644 |
|
---|
645 | ////////////////////
|
---|
646 | // MIXED (GENERIC)
|
---|
647 | ///////////////////
|
---|
648 |
|
---|
649 | /droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i // Android Phones from Unidentified Vendors
|
---|
650 | ], [MODEL, [TYPE, MOBILE]], [
|
---|
651 | /droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i // Android Tablets from Unidentified Vendors
|
---|
652 | ], [MODEL, [TYPE, TABLET]], [
|
---|
653 | /\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i // Unidentifiable Tablet
|
---|
654 | ], [[TYPE, TABLET]], [
|
---|
655 | /(phone|mobile(?:[;\/]| safari)|pda(?=.+windows ce))/i // Unidentifiable Mobile
|
---|
656 | ], [[TYPE, MOBILE]], [
|
---|
657 | /(android[-\w\. ]{0,9});.+buil/i // Generic Android Device
|
---|
658 | ], [MODEL, [VENDOR, 'Generic']]
|
---|
659 | ],
|
---|
660 |
|
---|
661 | engine : [[
|
---|
662 |
|
---|
663 | /windows.+ edge\/([\w\.]+)/i // EdgeHTML
|
---|
664 | ], [VERSION, [NAME, EDGE+'HTML']], [
|
---|
665 |
|
---|
666 | /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
|
---|
667 | ], [VERSION, [NAME, 'Blink']], [
|
---|
668 |
|
---|
669 | /(presto)\/([\w\.]+)/i, // Presto
|
---|
670 | /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna
|
---|
671 | /ekioh(flow)\/([\w\.]+)/i, // Flow
|
---|
672 | /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i, // KHTML/Tasman/Links
|
---|
673 | /(icab)[\/ ]([23]\.[\d\.]+)/i // iCab
|
---|
674 | ], [NAME, VERSION], [
|
---|
675 |
|
---|
676 | /rv\:([\w\.]{1,9})\b.+(gecko)/i // Gecko
|
---|
677 | ], [VERSION, NAME]
|
---|
678 | ],
|
---|
679 |
|
---|
680 | os : [[
|
---|
681 |
|
---|
682 | // Windows
|
---|
683 | /microsoft (windows) (vista|xp)/i // Windows (iTunes)
|
---|
684 | ], [NAME, VERSION], [
|
---|
685 | /(windows) nt 6\.2; (arm)/i, // Windows RT
|
---|
686 | /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i, // Windows Phone
|
---|
687 | /(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i
|
---|
688 | ], [NAME, [VERSION, strMapper, windowsVersionMap]], [
|
---|
689 | /(win(?=3|9|n)|win 9x )([nt\d\.]+)/i
|
---|
690 | ], [[NAME, 'Windows'], [VERSION, strMapper, windowsVersionMap]], [
|
---|
691 |
|
---|
692 | // iOS/macOS
|
---|
693 | /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS
|
---|
694 | /cfnetwork\/.+darwin/i
|
---|
695 | ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
|
---|
696 | /(mac os x) ?([\w\. ]*)/i,
|
---|
697 | /(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
|
---|
698 | ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
|
---|
699 |
|
---|
700 | // Mobile OSes
|
---|
701 | /droid ([\w\.]+)\b.+(android[- ]x86)/i // Android-x86
|
---|
702 | ], [VERSION, NAME], [ // Android/WebOS/QNX/Bada/RIM/Maemo/MeeGo/Sailfish OS
|
---|
703 | /(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,
|
---|
704 | /(blackberry)\w*\/([\w\.]*)/i, // Blackberry
|
---|
705 | /(tizen|kaios)[\/ ]([\w\.]+)/i, // Tizen/KaiOS
|
---|
706 | /\((series40);/i // Series 40
|
---|
707 | ], [NAME, VERSION], [
|
---|
708 | /\(bb(10);/i // BlackBerry 10
|
---|
709 | ], [VERSION, [NAME, BLACKBERRY]], [
|
---|
710 | /(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i // Symbian
|
---|
711 | ], [VERSION, [NAME, 'Symbian']], [
|
---|
712 | /mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i // Firefox OS
|
---|
713 | ], [VERSION, [NAME, FIREFOX+' OS']], [
|
---|
714 | /web0s;.+rt(tv)/i,
|
---|
715 | /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i // WebOS
|
---|
716 | ], [VERSION, [NAME, 'webOS']], [
|
---|
717 |
|
---|
718 | // Google Chromecast
|
---|
719 | /crkey\/([\d\.]+)/i // Google Chromecast
|
---|
720 | ], [VERSION, [NAME, CHROME+'cast']], [
|
---|
721 | /(cros) [\w]+ ([\w\.]+\w)/i // Chromium OS
|
---|
722 | ], [[NAME, 'Chromium OS'], VERSION],[
|
---|
723 |
|
---|
724 | // Console
|
---|
725 | /(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
|
---|
726 | /(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)
|
---|
727 |
|
---|
728 | // Other
|
---|
729 | /\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, // Joli/Palm
|
---|
730 | /(mint)[\/\(\) ]?(\w*)/i, // Mint
|
---|
731 | /(mageia|vectorlinux)[; ]/i, // Mageia/VectorLinux
|
---|
732 | /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,
|
---|
733 | // Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware/Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus/Raspbian/Plan9/Minix/RISCOS/Contiki/Deepin/Manjaro/elementary/Sabayon/Linspire
|
---|
734 | /(hurd|linux) ?([\w\.]*)/i, // Hurd/Linux
|
---|
735 | /(gnu) ?([\w\.]*)/i, // GNU
|
---|
736 | /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i, // FreeBSD/NetBSD/OpenBSD/PC-BSD/GhostBSD/DragonFly
|
---|
737 | /(haiku) (\w+)/i // Haiku
|
---|
738 | ], [NAME, VERSION], [
|
---|
739 | /(sunos) ?([\w\.\d]*)/i // Solaris
|
---|
740 | ], [[NAME, 'Solaris'], VERSION], [
|
---|
741 | /((?:open)?solaris)[-\/ ]?([\w\.]*)/i, // Solaris
|
---|
742 | /(aix) ((\d)(?=\.|\)| )[\w\.])*/i, // AIX
|
---|
743 | /\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i, // BeOS/OS2/AmigaOS/MorphOS/OpenVMS/Fuchsia/HP-UX
|
---|
744 | /(unix) ?([\w\.]*)/i // UNIX
|
---|
745 | ], [NAME, VERSION]
|
---|
746 | ]
|
---|
747 | };
|
---|
748 |
|
---|
749 | /////////////////
|
---|
750 | // Constructor
|
---|
751 | ////////////////
|
---|
752 |
|
---|
753 | var UAParser = function (ua, extensions) {
|
---|
754 |
|
---|
755 | if (typeof ua === OBJ_TYPE) {
|
---|
756 | extensions = ua;
|
---|
757 | ua = undefined;
|
---|
758 | }
|
---|
759 |
|
---|
760 | if (!(this instanceof UAParser)) {
|
---|
761 | return new UAParser(ua, extensions).getResult();
|
---|
762 | }
|
---|
763 |
|
---|
764 | var _ua = ua || ((typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
|
---|
765 | var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
|
---|
766 |
|
---|
767 | this.getBrowser = function () {
|
---|
768 | var _browser = {};
|
---|
769 | _browser[NAME] = undefined;
|
---|
770 | _browser[VERSION] = undefined;
|
---|
771 | rgxMapper.call(_browser, _ua, _rgxmap.browser);
|
---|
772 | _browser.major = majorize(_browser.version);
|
---|
773 | return _browser;
|
---|
774 | };
|
---|
775 | this.getCPU = function () {
|
---|
776 | var _cpu = {};
|
---|
777 | _cpu[ARCHITECTURE] = undefined;
|
---|
778 | rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
|
---|
779 | return _cpu;
|
---|
780 | };
|
---|
781 | this.getDevice = function () {
|
---|
782 | var _device = {};
|
---|
783 | _device[VENDOR] = undefined;
|
---|
784 | _device[MODEL] = undefined;
|
---|
785 | _device[TYPE] = undefined;
|
---|
786 | rgxMapper.call(_device, _ua, _rgxmap.device);
|
---|
787 | return _device;
|
---|
788 | };
|
---|
789 | this.getEngine = function () {
|
---|
790 | var _engine = {};
|
---|
791 | _engine[NAME] = undefined;
|
---|
792 | _engine[VERSION] = undefined;
|
---|
793 | rgxMapper.call(_engine, _ua, _rgxmap.engine);
|
---|
794 | return _engine;
|
---|
795 | };
|
---|
796 | this.getOS = function () {
|
---|
797 | var _os = {};
|
---|
798 | _os[NAME] = undefined;
|
---|
799 | _os[VERSION] = undefined;
|
---|
800 | rgxMapper.call(_os, _ua, _rgxmap.os);
|
---|
801 | return _os;
|
---|
802 | };
|
---|
803 | this.getResult = function () {
|
---|
804 | return {
|
---|
805 | ua : this.getUA(),
|
---|
806 | browser : this.getBrowser(),
|
---|
807 | engine : this.getEngine(),
|
---|
808 | os : this.getOS(),
|
---|
809 | device : this.getDevice(),
|
---|
810 | cpu : this.getCPU()
|
---|
811 | };
|
---|
812 | };
|
---|
813 | this.getUA = function () {
|
---|
814 | return _ua;
|
---|
815 | };
|
---|
816 | this.setUA = function (ua) {
|
---|
817 | _ua = (typeof ua === STR_TYPE && ua.length > UA_MAX_LENGTH) ? trim(ua, UA_MAX_LENGTH) : ua;
|
---|
818 | return this;
|
---|
819 | };
|
---|
820 | this.setUA(_ua);
|
---|
821 | return this;
|
---|
822 | };
|
---|
823 |
|
---|
824 | UAParser.VERSION = LIBVERSION;
|
---|
825 | UAParser.BROWSER = enumerize([NAME, VERSION, MAJOR]);
|
---|
826 | UAParser.CPU = enumerize([ARCHITECTURE]);
|
---|
827 | UAParser.DEVICE = enumerize([MODEL, VENDOR, TYPE, CONSOLE, MOBILE, SMARTTV, TABLET, WEARABLE, EMBEDDED]);
|
---|
828 | UAParser.ENGINE = UAParser.OS = enumerize([NAME, VERSION]);
|
---|
829 |
|
---|
830 | ///////////
|
---|
831 | // Export
|
---|
832 | //////////
|
---|
833 |
|
---|
834 | // check js environment
|
---|
835 | if (typeof(exports) !== UNDEF_TYPE) {
|
---|
836 | // nodejs env
|
---|
837 | if (typeof module !== UNDEF_TYPE && module.exports) {
|
---|
838 | exports = module.exports = UAParser;
|
---|
839 | }
|
---|
840 | exports.UAParser = UAParser;
|
---|
841 | } else {
|
---|
842 | // requirejs env (optional)
|
---|
843 | if (typeof(define) === FUNC_TYPE && define.amd) {
|
---|
844 | define(function () {
|
---|
845 | return UAParser;
|
---|
846 | });
|
---|
847 | } else if (typeof window !== UNDEF_TYPE) {
|
---|
848 | // browser env
|
---|
849 | window.UAParser = UAParser;
|
---|
850 | }
|
---|
851 | }
|
---|
852 |
|
---|
853 | // jQuery/Zepto specific (optional)
|
---|
854 | // Note:
|
---|
855 | // In AMD env the global scope should be kept clean, but jQuery is an exception.
|
---|
856 | // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
|
---|
857 | // and we should catch that.
|
---|
858 | var $ = typeof window !== UNDEF_TYPE && (window.jQuery || window.Zepto);
|
---|
859 | if ($ && !$.ua) {
|
---|
860 | var parser = new UAParser();
|
---|
861 | $.ua = parser.getResult();
|
---|
862 | $.ua.get = function () {
|
---|
863 | return parser.getUA();
|
---|
864 | };
|
---|
865 | $.ua.set = function (ua) {
|
---|
866 | parser.setUA(ua);
|
---|
867 | var result = parser.getResult();
|
---|
868 | for (var prop in result) {
|
---|
869 | $.ua[prop] = result[prop];
|
---|
870 | }
|
---|
871 | };
|
---|
872 | }
|
---|
873 |
|
---|
874 | })(typeof window === 'object' ? window : this);
|
---|