source: trip-planner-front/node_modules/ua-parser-js/src/ua-parser.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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