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