From 028b287f4355abc2bdf56ade31f1735d96a61ca0 Mon Sep 17 00:00:00 2001 From: Juan Lago Date: Mon, 3 Aug 2020 14:08:36 +0200 Subject: [PATCH 1/3] Implemented osVersion --- README.md | 1 + lib/express-useragent.js | 50 ++++++++++++++++++++++ lib/express-useragent.min.js | 2 +- test/os_version.test.js | 82 ++++++++++++++++++++++++++++++++++++ test/tests.js | 3 ++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 test/os_version.test.js diff --git a/README.md b/README.md index b98ca53..5b28c59 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ module provides details such as the following: "browser":"Chrome", "version":"17.0.963.79", "os":"Windows 7", + "osVersion": "6.1" "platform":"Microsoft Windows", "source":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79..." } diff --git a/lib/express-useragent.js b/lib/express-useragent.js index a40e393..d24b9c1 100644 --- a/lib/express-useragent.js +++ b/lib/express-useragent.js @@ -180,6 +180,7 @@ Wii: /wii/i, PS3: /playstation 3/i, PSP: /playstation portable/i, + PS4: /playstation 4/i, iPad: /\(iPad.*os (\d+)[._](\d+)/i, iPhone: /\(iPhone.*os (\d+)[._](\d+)/i, iOS: /ios/i, @@ -187,6 +188,20 @@ Curl: /curl\/(\d+)\.(\d+)\.(\d+)/i, Electron: /Electron\/(\d+)\.(\d+)\.(\d+)/i, }; + + this._OSVersions = { + Windows: /(?:windows nt) ([\d\.\-\_]+)/i, + WindowsPhone: /(?:windows phone) ([\d\.\-\_]+)/i, + Mac: /(?:os x) ([\d\.\-\_]+)/i, + iPhone: /(?:iphone.* os) ([\d\.\-\_]+)/i, + iPad: /(?:ipad.* os) ([\d\.\-\_]+)/i, + Android: /(?:android) ([\d\.\-\_]+)/i, + Ubuntu: /(?:ubuntu)\/([\d\.\-\_]+)/i, + ChromeOS: /(?:cros(.*)?) ([\d\.\-\_]+)/i, + PS3: /(?:playstation 3[;]?) ([\d\.\-\_]+)/i, + PS4: /(?:playstation 4) ([\d\.\-\_]+)/i, + }; + this._Platform = { Windows: /windows nt/i, WindowsPhone: /windows phone/i, @@ -592,6 +607,40 @@ } }; + this.getOSVersion = function (string) { + + var osVersion = null; + + if (this.Agent.isWindowsPhone) + osVersion = this._OSVersions.WindowsPhone.exec(string); + else if (this.Agent.isWindows) + osVersion = this._OSVersions.Windows.exec(string); + else if (this.Agent.isiPhone) + osVersion = this._OSVersions.iPhone.exec(string); + else if (this.Agent.isiPad) + osVersion = this._OSVersions.iPad.exec(string); + else if (this.Agent.isMac) + osVersion = this._OSVersions.Mac.exec(string); + else if (this.Agent.isChromeOS) + osVersion = this._OSVersions.ChromeOS.exec(string); + else if (this.Agent.isAndroid || this.isAndroidNative || this.isAndroidTablet) + osVersion = this._OSVersions.Android.exec(string); + else if (this.Agent.isLinux || this.Agent.isLinux64) { + osVersion = this._OSVersions.Ubuntu.exec(string); + + // Android is basically Linux, we can try to find the version for Android devices. + if (!osVersion) + osVersion = this._OSVersions.Android.exec(string); + } + + if (osVersion && osVersion.length > 1) + osVersion = osVersion[osVersion.length - 1]; + else + return ''; + + return osVersion.replace(/(_)/g, '.'); + }; + this.getPlatform = function (string) { switch (true) { case this._Platform.Windows.test(string): @@ -851,6 +900,7 @@ ua.Agent.browser = ua.getBrowser(ua.Agent.source); ua.Agent.version = ua.getBrowserVersion(ua.Agent.source); ua.Agent.electronVersion = ua.getElectronVersion(ua.Agent.source); + ua.Agent.osVersion = ua.getOSVersion(ua.Agent.source); ua.testBot(); ua.testSmartTV(); ua.testMobile(); diff --git a/lib/express-useragent.min.js b/lib/express-useragent.min.js index 53391bb..450ee35 100644 --- a/lib/express-useragent.min.js +++ b/lib/express-useragent.min.js @@ -3,4 +3,4 @@ * Copyright 2011-2020 Aleksejs Gordejevs * Licensed under MIT (https://github.com/biggora/express-useragent/blob/master/README.md#license) */ -!function(a){"use strict";var b=["\\+https:\\/\\/developers.google.com\\/\\+\\/web\\/snippet\\/","ad\\smonitoring","adsbot","apex","applebot","archive.org_bot","baiduspider","bingbot","chromeheadless","cloudflare","cloudinary","crawler","curl","discordbot","duckduckbot","embedly","exabot","facebookexternalhit","facebot","flipboard","google","googlebot","gsa-crawler","gurujibot","guzzlehttp","heritrix","ia_archiver","insights","linkedinbot","ltx71","mediapartners","msnbot","odklbot","phantom\\.js","phantomjs","pingdom","pinterest","python","rtlnieuws","skypeuripreview","slackbot","slurp","spbot","telegrambot","test\\scertificate","testing","tiabot","tumblr ","twitterbot","vkshare","web\\sscraper","wget","yandexbot","whatsapp","orangebot","smtbot","qwantify","mj12bot","ahrefsbot","seznambot","panscient.com","duckduckgo-favicons-bot","uptimerobot","semrushbot","postman","dotbot","zoominfobot","ifttt","sogou","ru_bot","researchscan","nimbostratus-bot","slack-imgproxy","node-superagent","go-http-client","jersey","dataprovider.com","github-camo","dispatch","checkmarknetwork","screaming frog","whatweb","daum","netcraftsurveyagent","mojeekbot","surdotlybot","springbot"],c=new RegExp("^.*("+b.join("|")+").*$"),d=function(){return this.version="1.0.15",this._Versions={Edge:/(?:edge|edga|edgios|edg)\/([\d\w\.\-]+)/i,Firefox:/(?:firefox|fxios)\/([\d\w\.\-]+)/i,IE:/msie\s([\d\.]+[\d])|trident\/\d+\.\d+;.*[rv:]+(\d+\.\d)/i,Chrome:/(?:chrome|crios)\/([\d\w\.\-]+)/i,Chromium:/chromium\/([\d\w\.\-]+)/i,Safari:/(version|safari)\/([\d\w\.\-]+)/i,Opera:/version\/([\d\w\.\-]+)|OPR\/([\d\w\.\-]+)/i,Ps3:/([\d\w\.\-]+)\)\s*$/i,Psp:/([\d\w\.\-]+)\)?\s*$/i,Amaya:/amaya\/([\d\w\.\-]+)/i,SeaMonkey:/seamonkey\/([\d\w\.\-]+)/i,OmniWeb:/omniweb\/v([\d\w\.\-]+)/i,Flock:/flock\/([\d\w\.\-]+)/i,Epiphany:/epiphany\/([\d\w\.\-]+)/i,WinJs:/msapphost\/([\d\w\.\-]+)/i,PhantomJS:/phantomjs\/([\d\w\.\-]+)/i,AlamoFire:/alamofire\/([\d\w\.\-]+)/i,UC:/ucbrowser\/([\d\w\.]+)/i,Facebook:/FBAV\/([\d\w\.]+)/i,WebKit:/applewebkit\/([\d\w\.]+)/i,Wechat:/micromessenger\/([\d\w\.]+)/i,Electron:/Electron\/([\d\w\.]+)/i},this._Browsers={YaBrowser:/yabrowser/i,Edge:/edge|edga|edgios|edg/i,Amaya:/amaya/i,Konqueror:/konqueror/i,Epiphany:/epiphany/i,SeaMonkey:/seamonkey/i,Flock:/flock/i,OmniWeb:/omniweb/i,Chromium:/chromium/i,Chrome:/chrome|crios/i,Safari:/safari/i,IE:/msie|trident/i,Opera:/opera|OPR\//i,PS3:/playstation 3/i,PSP:/playstation portable/i,Firefox:/firefox|fxios/i,WinJs:/msapphost/i,PhantomJS:/phantomjs/i,AlamoFire:/alamofire/i,UC:/UCBrowser/i,Facebook:/FBA[NV]/},this._OS={Windows10:/windows nt 10\.0/i,Windows81:/windows nt 6\.3/i,Windows8:/windows nt 6\.2/i,Windows7:/windows nt 6\.1/i,UnknownWindows:/windows nt 6\.\d+/i,WindowsVista:/windows nt 6\.0/i,Windows2003:/windows nt 5\.2/i,WindowsXP:/windows nt 5\.1/i,Windows2000:/windows nt 5\.0/i,WindowsPhone81:/windows phone 8\.1/i,WindowsPhone80:/windows phone 8\.0/i,OSXCheetah:/os x 10[._]0/i,OSXPuma:/os x 10[._]1(\D|$)/i,OSXJaguar:/os x 10[._]2/i,OSXPanther:/os x 10[._]3/i,OSXTiger:/os x 10[._]4/i,OSXLeopard:/os x 10[._]5/i,OSXSnowLeopard:/os x 10[._]6/i,OSXLion:/os x 10[._]7/i,OSXMountainLion:/os x 10[._]8/i,OSXMavericks:/os x 10[._]9/i,OSXYosemite:/os x 10[._]10/i,OSXElCapitan:/os x 10[._]11/i,MacOSSierra:/os x 10[._]12/i,MacOSHighSierra:/os x 10[._]13/i,MacOSMojave:/os x 10[._]14/i,Mac:/os x/i,Linux:/linux/i,Linux64:/linux x86\_64/i,ChromeOS:/cros/i,Wii:/wii/i,PS3:/playstation 3/i,PSP:/playstation portable/i,iPad:/\(iPad.*os (\d+)[._](\d+)/i,iPhone:/\(iPhone.*os (\d+)[._](\d+)/i,iOS:/ios/i,Bada:/Bada\/(\d+)\.(\d+)/i,Curl:/curl\/(\d+)\.(\d+)\.(\d+)/i,Electron:/Electron\/(\d+)\.(\d+)\.(\d+)/i},this._Platform={Windows:/windows nt/i,WindowsPhone:/windows phone/i,Mac:/macintosh/i,Linux:/linux/i,Wii:/wii/i,Playstation:/playstation/i,iPad:/ipad/i,iPod:/ipod/i,iPhone:/iphone/i,Android:/android/i,Blackberry:/blackberry/i,Samsung:/samsung/i,Curl:/curl/i,Electron:/Electron/i,iOS:/^ios\-/i},this.DefaultAgent={isYaBrowser:!1,isAuthoritative:!0,isMobile:!1,isMobileNative:!1,isTablet:!1,isiPad:!1,isiPod:!1,isiPhone:!1,isiPhoneNative:!1,isAndroid:!1,isAndroidNative:!1,isBlackberry:!1,isOpera:!1,isIE:!1,isEdge:!1,isIECompatibilityMode:!1,isSafari:!1,isFirefox:!1,isWebkit:!1,isChrome:!1,isKonqueror:!1,isOmniWeb:!1,isSeaMonkey:!1,isFlock:!1,isAmaya:!1,isPhantomJS:!1,isEpiphany:!1,isDesktop:!1,isWindows:!1,isLinux:!1,isLinux64:!1,isMac:!1,isChromeOS:!1,isBada:!1,isSamsung:!1,isRaspberry:!1,isBot:!1,isCurl:!1,isAndroidTablet:!1,isWinJs:!1,isKindleFire:!1,isSilk:!1,isCaptive:!1,isSmartTV:!1,isUC:!1,isFacebook:!1,isAlamoFire:!1,isElectron:!1,silkAccelerated:!1,browser:"unknown",version:"unknown",os:"unknown",platform:"unknown",geoIp:{},source:"",isWechat:!1},this.Agent={},this.getBrowser=function(a){switch(!0){case this._Browsers.YaBrowser.test(a):return this.Agent.isYaBrowser=!0,"YaBrowser";case this._Browsers.AlamoFire.test(a):return this.Agent.isAlamoFire=!0,"AlamoFire";case this._Browsers.Edge.test(a):return this.Agent.isEdge=!0,"Edge";case this._Browsers.PhantomJS.test(a):return this.Agent.isPhantomJS=!0,"PhantomJS";case this._Browsers.Konqueror.test(a):return this.Agent.isKonqueror=!0,"Konqueror";case this._Browsers.Amaya.test(a):return this.Agent.isAmaya=!0,"Amaya";case this._Browsers.Epiphany.test(a):return this.Agent.isEpiphany=!0,"Epiphany";case this._Browsers.SeaMonkey.test(a):return this.Agent.isSeaMonkey=!0,"SeaMonkey";case this._Browsers.Flock.test(a):return this.Agent.isFlock=!0,"Flock";case this._Browsers.OmniWeb.test(a):return this.Agent.isOmniWeb=!0,"OmniWeb";case this._Browsers.Opera.test(a):return this.Agent.isOpera=!0,"Opera";case this._Browsers.Chromium.test(a):return this.Agent.isChrome=!0,"Chromium";case this._Browsers.Facebook.test(a):return this.Agent.isFacebook=!0,"Facebook";case this._Browsers.Chrome.test(a):return this.Agent.isChrome=!0,"Chrome";case this._Browsers.WinJs.test(a):return this.Agent.isWinJs=!0,"WinJs";case this._Browsers.IE.test(a):return this.Agent.isIE=!0,"IE";case this._Browsers.Firefox.test(a):return this.Agent.isFirefox=!0,"Firefox";case this._Browsers.Safari.test(a):return this.Agent.isSafari=!0,"Safari";case this._Browsers.PS3.test(a):return"ps3";case this._Browsers.PSP.test(a):return"psp";case this._Browsers.UC.test(a):return this.Agent.isUC=!0,"UCBrowser";default:return a.indexOf("Dalvik")!==-1?"unknown":0!==a.indexOf("Mozilla")&&/^([\d\w\-\.]+)\/[\d\w\.\-]+/i.test(a)?(this.Agent.isAuthoritative=!1,RegExp.$1):"unknown"}},this.getBrowserVersion=function(a){var b;switch(this.Agent.browser){case"Edge":if(this._Versions.Edge.test(a))return RegExp.$1;break;case"PhantomJS":if(this._Versions.PhantomJS.test(a))return RegExp.$1;break;case"Chrome":if(this._Versions.Chrome.test(a))return RegExp.$1;break;case"Chromium":if(this._Versions.Chromium.test(a))return RegExp.$1;break;case"Safari":if(this._Versions.Safari.test(a))return RegExp.$2;break;case"Opera":if(this._Versions.Opera.test(a))return RegExp.$1?RegExp.$1:RegExp.$2;break;case"Firefox":if(this._Versions.Firefox.test(a))return RegExp.$1;break;case"WinJs":if(this._Versions.WinJs.test(a))return RegExp.$1;break;case"IE":if(this._Versions.IE.test(a))return RegExp.$2?RegExp.$2:RegExp.$1;break;case"ps3":if(this._Versions.Ps3.test(a))return RegExp.$1;break;case"psp":if(this._Versions.Psp.test(a))return RegExp.$1;break;case"Amaya":if(this._Versions.Amaya.test(a))return RegExp.$1;break;case"Epiphany":if(this._Versions.Epiphany.test(a))return RegExp.$1;break;case"SeaMonkey":if(this._Versions.SeaMonkey.test(a))return RegExp.$1;break;case"Flock":if(this._Versions.Flock.test(a))return RegExp.$1;break;case"OmniWeb":if(this._Versions.OmniWeb.test(a))return RegExp.$1;break;case"UCBrowser":if(this._Versions.UC.test(a))return RegExp.$1;break;case"Facebook":if(this._Versions.Facebook.test(a))return RegExp.$1;break;default:if("unknown"===this.Agent.browser)return this.testWebkit(),this.Agent.isWebkit&&this._Versions.WebKit.test(a)?RegExp.$1:"unknown";if(b=new RegExp(this.Agent.browser+"[\\/ ]([\\d\\w\\.\\-]+)","i"),b.test(a))return RegExp.$1}},this.getWechatVersion=function(a){return this._Versions.Wechat.test(a)?RegExp.$1:"unknown"},this.getElectronVersion=function(a){return this._Versions.Electron.test(a)?(this.Agent.isElectron=!0,RegExp.$1):""},this.getOS=function(a){switch(!0){case this._OS.WindowsVista.test(a):return this.Agent.isWindows=!0,"Windows Vista";case this._OS.Windows7.test(a):return this.Agent.isWindows=!0,"Windows 7";case this._OS.Windows8.test(a):return this.Agent.isWindows=!0,"Windows 8";case this._OS.Windows81.test(a):return this.Agent.isWindows=!0,"Windows 8.1";case this._OS.Windows10.test(a):return this.Agent.isWindows=!0,"Windows 10.0";case this._OS.Windows2003.test(a):return this.Agent.isWindows=!0,"Windows 2003";case this._OS.WindowsXP.test(a):return this.Agent.isWindows=!0,"Windows XP";case this._OS.Windows2000.test(a):return this.Agent.isWindows=!0,"Windows 2000";case this._OS.WindowsPhone81.test(a):return this.Agent.isWindowsPhone=!0,"Windows Phone 8.1";case this._OS.WindowsPhone80.test(a):return this.Agent.isWindowsPhone=!0,"Windows Phone 8.0";case this._OS.Linux64.test(a):return this.Agent.isLinux=!0,this.Agent.isLinux64=!0,"Linux 64";case this._OS.Linux.test(a):return this.Agent.isLinux=!0,"Linux";case this._OS.ChromeOS.test(a):return this.Agent.isChromeOS=!0,"Chrome OS";case this._OS.Wii.test(a):return"Wii";case this._OS.PS3.test(a):return"Playstation";case this._OS.PSP.test(a):return"Playstation";case this._OS.OSXCheetah.test(a):return this.Agent.isMac=!0,"OS X Cheetah";case this._OS.OSXPuma.test(a):return this.Agent.isMac=!0,"OS X Puma";case this._OS.OSXJaguar.test(a):return this.Agent.isMac=!0,"OS X Jaguar";case this._OS.OSXPanther.test(a):return this.Agent.isMac=!0,"OS X Panther";case this._OS.OSXTiger.test(a):return this.Agent.isMac=!0,"OS X Tiger";case this._OS.OSXLeopard.test(a):return this.Agent.isMac=!0,"OS X Leopard";case this._OS.OSXSnowLeopard.test(a):return this.Agent.isMac=!0,"OS X Snow Leopard";case this._OS.OSXLion.test(a):return this.Agent.isMac=!0,"OS X Lion";case this._OS.OSXMountainLion.test(a):return this.Agent.isMac=!0,"OS X Mountain Lion";case this._OS.OSXMavericks.test(a):return this.Agent.isMac=!0,"OS X Mavericks";case this._OS.OSXYosemite.test(a):return this.Agent.isMac=!0,"OS X Yosemite";case this._OS.OSXElCapitan.test(a):return this.Agent.isMac=!0,"OS X El Capitan";case this._OS.MacOSSierra.test(a):return this.Agent.isMac=!0,"macOS Sierra";case this._OS.MacOSHighSierra.test(a):return this.Agent.isMac=!0,"macOS High Sierra";case this._OS.MacOSMojave.test(a):return this.Agent.isMac=!0,"macOS Mojave";case this._OS.Mac.test(a):return this.Agent.isMac=!0,"OS X";case this._OS.iPad.test(a):return this.Agent.isiPad=!0,a.match(this._OS.iPad)[0].replace("_",".");case this._OS.iPhone.test(a):return this.Agent.isiPhone=!0,a.match(this._OS.iPhone)[0].replace("_",".");case this._OS.Bada.test(a):return this.Agent.isBada=!0,"Bada";case this._OS.Curl.test(a):return this.Agent.isCurl=!0,"Curl";case this._OS.iOS.test(a):return this.Agent.isiPhone=!0,"iOS";case this._OS.Electron.test(a):return this.Agent.isElectron=!0,"Electron";default:return"unknown"}},this.getPlatform=function(a){switch(!0){case this._Platform.Windows.test(a):return"Microsoft Windows";case this._Platform.WindowsPhone.test(a):return this.Agent.isWindowsPhone=!0,"Microsoft Windows Phone";case this._Platform.Mac.test(a):return"Apple Mac";case this._Platform.Curl.test(a):return"Curl";case this._Platform.Electron.test(a):return this.Agent.isElectron=!0,"Electron";case this._Platform.Android.test(a):return this.Agent.isAndroid=!0,"Android";case this._Platform.Blackberry.test(a):return this.Agent.isBlackberry=!0,"Blackberry";case this._Platform.Linux.test(a):return"Linux";case this._Platform.Wii.test(a):return"Wii";case this._Platform.Playstation.test(a):return"Playstation";case this._Platform.iPad.test(a):return this.Agent.isiPad=!0,"iPad";case this._Platform.iPod.test(a):return this.Agent.isiPod=!0,"iPod";case this._Platform.iPhone.test(a):return this.Agent.isiPhone=!0,"iPhone";case this._Platform.Samsung.test(a):return this.Agent.isSamsung=!0,"Samsung";case this._Platform.iOS.test(a):return"Apple iOS";default:return"unknown"}},this.testCompatibilityMode=function(){var a=this;if(this.Agent.isIE&&/Trident\/(\d)\.0/i.test(a.Agent.source)){var b=parseInt(RegExp.$1,10),c=parseInt(a.Agent.version,10);7===c&&7===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=11),7===c&&6===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=10),7===c&&5===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=9),7===c&&4===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=8)}},this.testSilk=function(){var a=this;switch(!0){case new RegExp("silk","gi").test(a.Agent.source):this.Agent.isSilk=!0}return/Silk-Accelerated=true/gi.test(a.Agent.source)&&(this.Agent.SilkAccelerated=!0),!!this.Agent.isSilk&&"Silk"},this.testKindleFire=function(){var a=this;switch(!0){case/KFOT/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire";case/KFTT/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD";case/KFJWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD 8.9";case/KFJWA/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD 8.9 4G";case/KFSOWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD 7";case/KFTHWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 7";case/KFTHWA/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 7 4G";case/KFAPWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 8.9";case/KFAPWA/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 8.9 4G";default:return!1}},this.testCaptiveNetwork=function(){var a=this;switch(!0){case/CaptiveNetwork/gi.test(a.Agent.source):return a.Agent.isCaptive=!0,a.Agent.isMac=!0,a.Agent.platform="Apple Mac","CaptiveNetwork";default:return!1}},this.reset=function(){var a=this;for(var b in a.DefaultAgent)a.Agent[b]=a.DefaultAgent[b];return a},this.testMobile=function(){var a=this;switch(!0){case a.Agent.isWindows:case a.Agent.isLinux:case a.Agent.isMac:case a.Agent.isChromeOS:a.Agent.isDesktop=!0;break;case a.Agent.isAndroid:case a.Agent.isSamsung:a.Agent.isMobile=!0}switch(!0){case a.Agent.isiPad:case a.Agent.isiPod:case a.Agent.isiPhone:case a.Agent.isBada:case a.Agent.isBlackberry:case a.Agent.isAndroid:case a.Agent.isWindowsPhone:a.Agent.isMobile=!0,a.Agent.isDesktop=!1}/mobile|^ios\-/i.test(a.Agent.source)&&(a.Agent.isMobile=!0,a.Agent.isDesktop=!1),/dalvik/i.test(a.Agent.source)&&(a.Agent.isAndroidNative=!0,a.Agent.isMobileNative=!0),/scale/i.test(a.Agent.source)&&(a.Agent.isiPhoneNative=!0,a.Agent.isMobileNative=!0)},this.testTablet=function(){var a=this;switch(!0){case a.Agent.isiPad:case a.Agent.isAndroidTablet:case a.Agent.isKindleFire:a.Agent.isTablet=!0}/tablet/i.test(a.Agent.source)&&(a.Agent.isTablet=!0)},this.testNginxGeoIP=function(a){var b=this;return Object.keys(a).forEach(function(c){/^GEOIP/i.test(c)&&(b.Agent.geoIp[c]=a[c])}),b},this.testBot=function(){var a=this,b=c.exec(a.Agent.source.toLowerCase());b?a.Agent.isBot=b[1]:a.Agent.isAuthoritative||(a.Agent.isBot=/bot/i.test(a.Agent.source))},this.testSmartTV=function(){var a=this;a.Agent.isSmartTV=new RegExp("smart-tv|smarttv|googletv|appletv|hbbtv|pov_tv|netcast.tv","gi").test(a.Agent.source.toLowerCase())},this.testAndroidTablet=function(){var a=this;a.Agent.isAndroid&&!/mobile/i.test(a.Agent.source)&&(a.Agent.isAndroidTablet=!0)},this.testWebkit=function(){var a=this;"unknown"===a.Agent.browser&&/applewebkit/i.test(a.Agent.source)&&(a.Agent.browser="Apple WebKit",a.Agent.isWebkit=!0)},this.testWechat=function(){var a=this;/micromessenger/i.test(a.Agent.source)&&(a.Agent.isWechat=!0,a.Agent.version=this.getWechatVersion(a.Agent.source))},this.parse=function(a){var b=new d;return b.Agent.source=a.replace(/^\s*/,"").replace(/\s*$/,""),b.Agent.os=b.getOS(b.Agent.source),b.Agent.platform=b.getPlatform(b.Agent.source),b.Agent.browser=b.getBrowser(b.Agent.source),b.Agent.version=b.getBrowserVersion(b.Agent.source),b.Agent.electronVersion=b.getElectronVersion(b.Agent.source),b.testBot(),b.testSmartTV(),b.testMobile(),b.testAndroidTablet(),b.testTablet(),b.testCompatibilityMode(),b.testSilk(),b.testKindleFire(),b.testCaptiveNetwork(),b.testWebkit(),b.testWechat(),b.Agent},this.Agent=this.DefaultAgent,this};return a.UserAgent=d,new d}(this); \ No newline at end of file +!function(a){"use strict";var b=["\\+https:\\/\\/developers.google.com\\/\\+\\/web\\/snippet\\/","ad\\smonitoring","adsbot","apex","applebot","archive.org_bot","baiduspider","bingbot","chromeheadless","cloudflare","cloudinary","crawler","curl","discordbot","duckduckbot","embedly","exabot","facebookexternalhit","facebot","flipboard","google","googlebot","gsa-crawler","gurujibot","guzzlehttp","heritrix","ia_archiver","insights","linkedinbot","ltx71","mediapartners","msnbot","odklbot","phantom\\.js","phantomjs","pingdom","pinterest","python","rtlnieuws","skypeuripreview","slackbot","slurp","spbot","telegrambot","test\\scertificate","testing","tiabot","tumblr ","twitterbot","vkshare","web\\sscraper","wget","yandexbot","whatsapp","orangebot","smtbot","qwantify","mj12bot","ahrefsbot","seznambot","panscient.com","duckduckgo-favicons-bot","uptimerobot","semrushbot","postman","dotbot","zoominfobot","ifttt","sogou","ru_bot","researchscan","nimbostratus-bot","slack-imgproxy","node-superagent","go-http-client","jersey","dataprovider.com","github-camo","dispatch","checkmarknetwork","screaming frog","whatweb","daum","netcraftsurveyagent","mojeekbot","surdotlybot","springbot"],c=new RegExp("^.*("+b.join("|")+").*$"),d=function(){return this.version="1.0.15",this._Versions={Edge:/(?:edge|edga|edgios|edg)\/([\d\w\.\-]+)/i,Firefox:/(?:firefox|fxios)\/([\d\w\.\-]+)/i,IE:/msie\s([\d\.]+[\d])|trident\/\d+\.\d+;.*[rv:]+(\d+\.\d)/i,Chrome:/(?:chrome|crios)\/([\d\w\.\-]+)/i,Chromium:/chromium\/([\d\w\.\-]+)/i,Safari:/(version|safari)\/([\d\w\.\-]+)/i,Opera:/version\/([\d\w\.\-]+)|OPR\/([\d\w\.\-]+)/i,Ps3:/([\d\w\.\-]+)\)\s*$/i,Psp:/([\d\w\.\-]+)\)?\s*$/i,Amaya:/amaya\/([\d\w\.\-]+)/i,SeaMonkey:/seamonkey\/([\d\w\.\-]+)/i,OmniWeb:/omniweb\/v([\d\w\.\-]+)/i,Flock:/flock\/([\d\w\.\-]+)/i,Epiphany:/epiphany\/([\d\w\.\-]+)/i,WinJs:/msapphost\/([\d\w\.\-]+)/i,PhantomJS:/phantomjs\/([\d\w\.\-]+)/i,AlamoFire:/alamofire\/([\d\w\.\-]+)/i,UC:/ucbrowser\/([\d\w\.]+)/i,Facebook:/FBAV\/([\d\w\.]+)/i,WebKit:/applewebkit\/([\d\w\.]+)/i,Wechat:/micromessenger\/([\d\w\.]+)/i,Electron:/Electron\/([\d\w\.]+)/i},this._Browsers={YaBrowser:/yabrowser/i,Edge:/edge|edga|edgios|edg/i,Amaya:/amaya/i,Konqueror:/konqueror/i,Epiphany:/epiphany/i,SeaMonkey:/seamonkey/i,Flock:/flock/i,OmniWeb:/omniweb/i,Chromium:/chromium/i,Chrome:/chrome|crios/i,Safari:/safari/i,IE:/msie|trident/i,Opera:/opera|OPR\//i,PS3:/playstation 3/i,PSP:/playstation portable/i,Firefox:/firefox|fxios/i,WinJs:/msapphost/i,PhantomJS:/phantomjs/i,AlamoFire:/alamofire/i,UC:/UCBrowser/i,Facebook:/FBA[NV]/},this._OS={Windows10:/windows nt 10\.0/i,Windows81:/windows nt 6\.3/i,Windows8:/windows nt 6\.2/i,Windows7:/windows nt 6\.1/i,UnknownWindows:/windows nt 6\.\d+/i,WindowsVista:/windows nt 6\.0/i,Windows2003:/windows nt 5\.2/i,WindowsXP:/windows nt 5\.1/i,Windows2000:/windows nt 5\.0/i,WindowsPhone81:/windows phone 8\.1/i,WindowsPhone80:/windows phone 8\.0/i,OSXCheetah:/os x 10[._]0/i,OSXPuma:/os x 10[._]1(\D|$)/i,OSXJaguar:/os x 10[._]2/i,OSXPanther:/os x 10[._]3/i,OSXTiger:/os x 10[._]4/i,OSXLeopard:/os x 10[._]5/i,OSXSnowLeopard:/os x 10[._]6/i,OSXLion:/os x 10[._]7/i,OSXMountainLion:/os x 10[._]8/i,OSXMavericks:/os x 10[._]9/i,OSXYosemite:/os x 10[._]10/i,OSXElCapitan:/os x 10[._]11/i,MacOSSierra:/os x 10[._]12/i,MacOSHighSierra:/os x 10[._]13/i,MacOSMojave:/os x 10[._]14/i,Mac:/os x/i,Linux:/linux/i,Linux64:/linux x86\_64/i,ChromeOS:/cros/i,Wii:/wii/i,PS3:/playstation 3/i,PSP:/playstation portable/i,PS4:/playstation 4/i,iPad:/\(iPad.*os (\d+)[._](\d+)/i,iPhone:/\(iPhone.*os (\d+)[._](\d+)/i,iOS:/ios/i,Bada:/Bada\/(\d+)\.(\d+)/i,Curl:/curl\/(\d+)\.(\d+)\.(\d+)/i,Electron:/Electron\/(\d+)\.(\d+)\.(\d+)/i},this._OSVersions={Windows:/(?:windows nt) ([\d\.\-\_]+)/i,WindowsPhone:/(?:windows phone) ([\d\.\-\_]+)/i,Mac:/(?:os x) ([\d\.\-\_]+)/i,iPhone:/(?:iphone.* os) ([\d\.\-\_]+)/i,iPad:/(?:ipad.* os) ([\d\.\-\_]+)/i,Android:/(?:android) ([\d\.\-\_]+)/i,Ubuntu:/(?:ubuntu)\/([\d\.\-\_]+)/i,ChromeOS:/(?:cros(.*)?) ([\d\.\-\_]+)/i,PS3:/(?:playstation 3[;]?) ([\d\.\-\_]+)/i,PS4:/(?:playstation 4) ([\d\.\-\_]+)/i},this._Platform={Windows:/windows nt/i,WindowsPhone:/windows phone/i,Mac:/macintosh/i,Linux:/linux/i,Wii:/wii/i,Playstation:/playstation/i,iPad:/ipad/i,iPod:/ipod/i,iPhone:/iphone/i,Android:/android/i,Blackberry:/blackberry/i,Samsung:/samsung/i,Curl:/curl/i,Electron:/Electron/i,iOS:/^ios\-/i},this.DefaultAgent={isYaBrowser:!1,isAuthoritative:!0,isMobile:!1,isMobileNative:!1,isTablet:!1,isiPad:!1,isiPod:!1,isiPhone:!1,isiPhoneNative:!1,isAndroid:!1,isAndroidNative:!1,isBlackberry:!1,isOpera:!1,isIE:!1,isEdge:!1,isIECompatibilityMode:!1,isSafari:!1,isFirefox:!1,isWebkit:!1,isChrome:!1,isKonqueror:!1,isOmniWeb:!1,isSeaMonkey:!1,isFlock:!1,isAmaya:!1,isPhantomJS:!1,isEpiphany:!1,isDesktop:!1,isWindows:!1,isLinux:!1,isLinux64:!1,isMac:!1,isChromeOS:!1,isBada:!1,isSamsung:!1,isRaspberry:!1,isBot:!1,isCurl:!1,isAndroidTablet:!1,isWinJs:!1,isKindleFire:!1,isSilk:!1,isCaptive:!1,isSmartTV:!1,isUC:!1,isFacebook:!1,isAlamoFire:!1,isElectron:!1,silkAccelerated:!1,browser:"unknown",version:"unknown",os:"unknown",platform:"unknown",geoIp:{},source:"",isWechat:!1},this.Agent={},this.getBrowser=function(a){switch(!0){case this._Browsers.YaBrowser.test(a):return this.Agent.isYaBrowser=!0,"YaBrowser";case this._Browsers.AlamoFire.test(a):return this.Agent.isAlamoFire=!0,"AlamoFire";case this._Browsers.Edge.test(a):return this.Agent.isEdge=!0,"Edge";case this._Browsers.PhantomJS.test(a):return this.Agent.isPhantomJS=!0,"PhantomJS";case this._Browsers.Konqueror.test(a):return this.Agent.isKonqueror=!0,"Konqueror";case this._Browsers.Amaya.test(a):return this.Agent.isAmaya=!0,"Amaya";case this._Browsers.Epiphany.test(a):return this.Agent.isEpiphany=!0,"Epiphany";case this._Browsers.SeaMonkey.test(a):return this.Agent.isSeaMonkey=!0,"SeaMonkey";case this._Browsers.Flock.test(a):return this.Agent.isFlock=!0,"Flock";case this._Browsers.OmniWeb.test(a):return this.Agent.isOmniWeb=!0,"OmniWeb";case this._Browsers.Opera.test(a):return this.Agent.isOpera=!0,"Opera";case this._Browsers.Chromium.test(a):return this.Agent.isChrome=!0,"Chromium";case this._Browsers.Facebook.test(a):return this.Agent.isFacebook=!0,"Facebook";case this._Browsers.Chrome.test(a):return this.Agent.isChrome=!0,"Chrome";case this._Browsers.WinJs.test(a):return this.Agent.isWinJs=!0,"WinJs";case this._Browsers.IE.test(a):return this.Agent.isIE=!0,"IE";case this._Browsers.Firefox.test(a):return this.Agent.isFirefox=!0,"Firefox";case this._Browsers.Safari.test(a):return this.Agent.isSafari=!0,"Safari";case this._Browsers.PS3.test(a):return"ps3";case this._Browsers.PSP.test(a):return"psp";case this._Browsers.UC.test(a):return this.Agent.isUC=!0,"UCBrowser";default:return a.indexOf("Dalvik")!==-1?"unknown":0!==a.indexOf("Mozilla")&&/^([\d\w\-\.]+)\/[\d\w\.\-]+/i.test(a)?(this.Agent.isAuthoritative=!1,RegExp.$1):"unknown"}},this.getBrowserVersion=function(a){var b;switch(this.Agent.browser){case"Edge":if(this._Versions.Edge.test(a))return RegExp.$1;break;case"PhantomJS":if(this._Versions.PhantomJS.test(a))return RegExp.$1;break;case"Chrome":if(this._Versions.Chrome.test(a))return RegExp.$1;break;case"Chromium":if(this._Versions.Chromium.test(a))return RegExp.$1;break;case"Safari":if(this._Versions.Safari.test(a))return RegExp.$2;break;case"Opera":if(this._Versions.Opera.test(a))return RegExp.$1?RegExp.$1:RegExp.$2;break;case"Firefox":if(this._Versions.Firefox.test(a))return RegExp.$1;break;case"WinJs":if(this._Versions.WinJs.test(a))return RegExp.$1;break;case"IE":if(this._Versions.IE.test(a))return RegExp.$2?RegExp.$2:RegExp.$1;break;case"ps3":if(this._Versions.Ps3.test(a))return RegExp.$1;break;case"psp":if(this._Versions.Psp.test(a))return RegExp.$1;break;case"Amaya":if(this._Versions.Amaya.test(a))return RegExp.$1;break;case"Epiphany":if(this._Versions.Epiphany.test(a))return RegExp.$1;break;case"SeaMonkey":if(this._Versions.SeaMonkey.test(a))return RegExp.$1;break;case"Flock":if(this._Versions.Flock.test(a))return RegExp.$1;break;case"OmniWeb":if(this._Versions.OmniWeb.test(a))return RegExp.$1;break;case"UCBrowser":if(this._Versions.UC.test(a))return RegExp.$1;break;case"Facebook":if(this._Versions.Facebook.test(a))return RegExp.$1;break;default:if("unknown"===this.Agent.browser)return this.testWebkit(),this.Agent.isWebkit&&this._Versions.WebKit.test(a)?RegExp.$1:"unknown";if(b=new RegExp(this.Agent.browser+"[\\/ ]([\\d\\w\\.\\-]+)","i"),b.test(a))return RegExp.$1}},this.getWechatVersion=function(a){return this._Versions.Wechat.test(a)?RegExp.$1:"unknown"},this.getElectronVersion=function(a){return this._Versions.Electron.test(a)?(this.Agent.isElectron=!0,RegExp.$1):""},this.getOS=function(a){switch(!0){case this._OS.WindowsVista.test(a):return this.Agent.isWindows=!0,"Windows Vista";case this._OS.Windows7.test(a):return this.Agent.isWindows=!0,"Windows 7";case this._OS.Windows8.test(a):return this.Agent.isWindows=!0,"Windows 8";case this._OS.Windows81.test(a):return this.Agent.isWindows=!0,"Windows 8.1";case this._OS.Windows10.test(a):return this.Agent.isWindows=!0,"Windows 10.0";case this._OS.Windows2003.test(a):return this.Agent.isWindows=!0,"Windows 2003";case this._OS.WindowsXP.test(a):return this.Agent.isWindows=!0,"Windows XP";case this._OS.Windows2000.test(a):return this.Agent.isWindows=!0,"Windows 2000";case this._OS.WindowsPhone81.test(a):return this.Agent.isWindowsPhone=!0,"Windows Phone 8.1";case this._OS.WindowsPhone80.test(a):return this.Agent.isWindowsPhone=!0,"Windows Phone 8.0";case this._OS.Linux64.test(a):return this.Agent.isLinux=!0,this.Agent.isLinux64=!0,"Linux 64";case this._OS.Linux.test(a):return this.Agent.isLinux=!0,"Linux";case this._OS.ChromeOS.test(a):return this.Agent.isChromeOS=!0,"Chrome OS";case this._OS.Wii.test(a):return"Wii";case this._OS.PS3.test(a):return"Playstation";case this._OS.PSP.test(a):return"Playstation";case this._OS.OSXCheetah.test(a):return this.Agent.isMac=!0,"OS X Cheetah";case this._OS.OSXPuma.test(a):return this.Agent.isMac=!0,"OS X Puma";case this._OS.OSXJaguar.test(a):return this.Agent.isMac=!0,"OS X Jaguar";case this._OS.OSXPanther.test(a):return this.Agent.isMac=!0,"OS X Panther";case this._OS.OSXTiger.test(a):return this.Agent.isMac=!0,"OS X Tiger";case this._OS.OSXLeopard.test(a):return this.Agent.isMac=!0,"OS X Leopard";case this._OS.OSXSnowLeopard.test(a):return this.Agent.isMac=!0,"OS X Snow Leopard";case this._OS.OSXLion.test(a):return this.Agent.isMac=!0,"OS X Lion";case this._OS.OSXMountainLion.test(a):return this.Agent.isMac=!0,"OS X Mountain Lion";case this._OS.OSXMavericks.test(a):return this.Agent.isMac=!0,"OS X Mavericks";case this._OS.OSXYosemite.test(a):return this.Agent.isMac=!0,"OS X Yosemite";case this._OS.OSXElCapitan.test(a):return this.Agent.isMac=!0,"OS X El Capitan";case this._OS.MacOSSierra.test(a):return this.Agent.isMac=!0,"macOS Sierra";case this._OS.MacOSHighSierra.test(a):return this.Agent.isMac=!0,"macOS High Sierra";case this._OS.MacOSMojave.test(a):return this.Agent.isMac=!0,"macOS Mojave";case this._OS.Mac.test(a):return this.Agent.isMac=!0,"OS X";case this._OS.iPad.test(a):return this.Agent.isiPad=!0,a.match(this._OS.iPad)[0].replace("_",".");case this._OS.iPhone.test(a):return this.Agent.isiPhone=!0,a.match(this._OS.iPhone)[0].replace("_",".");case this._OS.Bada.test(a):return this.Agent.isBada=!0,"Bada";case this._OS.Curl.test(a):return this.Agent.isCurl=!0,"Curl";case this._OS.iOS.test(a):return this.Agent.isiPhone=!0,"iOS";case this._OS.Electron.test(a):return this.Agent.isElectron=!0,"Electron";default:return"unknown"}},this.getOSVersion=function(a){var b=null;return this.Agent.isWindowsPhone?b=this._OSVersions.WindowsPhone.exec(a):this.Agent.isWindows?b=this._OSVersions.Windows.exec(a):this.Agent.isiPhone?b=this._OSVersions.iPhone.exec(a):this.Agent.isiPad?b=this._OSVersions.iPad.exec(a):this.Agent.isMac?b=this._OSVersions.Mac.exec(a):this.Agent.isChromeOS?b=this._OSVersions.ChromeOS.exec(a):this.Agent.isAndroid||this.isAndroidNative||this.isAndroidTablet?b=this._OSVersions.Android.exec(a):(this.Agent.isLinux||this.Agent.isLinux64)&&(b=this._OSVersions.Ubuntu.exec(a),b||(b=this._OSVersions.Android.exec(a))),b&&b.length>1?(b=b[b.length-1],b.replace(/(_)/g,".")):""},this.getPlatform=function(a){switch(!0){case this._Platform.Windows.test(a):return"Microsoft Windows";case this._Platform.WindowsPhone.test(a):return this.Agent.isWindowsPhone=!0,"Microsoft Windows Phone";case this._Platform.Mac.test(a):return"Apple Mac";case this._Platform.Curl.test(a):return"Curl";case this._Platform.Electron.test(a):return this.Agent.isElectron=!0,"Electron";case this._Platform.Android.test(a):return this.Agent.isAndroid=!0,"Android";case this._Platform.Blackberry.test(a):return this.Agent.isBlackberry=!0,"Blackberry";case this._Platform.Linux.test(a):return"Linux";case this._Platform.Wii.test(a):return"Wii";case this._Platform.Playstation.test(a):return"Playstation";case this._Platform.iPad.test(a):return this.Agent.isiPad=!0,"iPad";case this._Platform.iPod.test(a):return this.Agent.isiPod=!0,"iPod";case this._Platform.iPhone.test(a):return this.Agent.isiPhone=!0,"iPhone";case this._Platform.Samsung.test(a):return this.Agent.isSamsung=!0,"Samsung";case this._Platform.iOS.test(a):return"Apple iOS";default:return"unknown"}},this.testCompatibilityMode=function(){var a=this;if(this.Agent.isIE&&/Trident\/(\d)\.0/i.test(a.Agent.source)){var b=parseInt(RegExp.$1,10),c=parseInt(a.Agent.version,10);7===c&&7===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=11),7===c&&6===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=10),7===c&&5===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=9),7===c&&4===b&&(a.Agent.isIECompatibilityMode=!0,a.Agent.version=8)}},this.testSilk=function(){var a=this;switch(!0){case new RegExp("silk","gi").test(a.Agent.source):this.Agent.isSilk=!0}return/Silk-Accelerated=true/gi.test(a.Agent.source)&&(this.Agent.SilkAccelerated=!0),!!this.Agent.isSilk&&"Silk"},this.testKindleFire=function(){var a=this;switch(!0){case/KFOT/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire";case/KFTT/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD";case/KFJWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD 8.9";case/KFJWA/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD 8.9 4G";case/KFSOWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HD 7";case/KFTHWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 7";case/KFTHWA/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 7 4G";case/KFAPWI/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 8.9";case/KFAPWA/gi.test(a.Agent.source):return this.Agent.isKindleFire=!0,"Kindle Fire HDX 8.9 4G";default:return!1}},this.testCaptiveNetwork=function(){var a=this;switch(!0){case/CaptiveNetwork/gi.test(a.Agent.source):return a.Agent.isCaptive=!0,a.Agent.isMac=!0,a.Agent.platform="Apple Mac","CaptiveNetwork";default:return!1}},this.reset=function(){var a=this;for(var b in a.DefaultAgent)a.Agent[b]=a.DefaultAgent[b];return a},this.testMobile=function(){var a=this;switch(!0){case a.Agent.isWindows:case a.Agent.isLinux:case a.Agent.isMac:case a.Agent.isChromeOS:a.Agent.isDesktop=!0;break;case a.Agent.isAndroid:case a.Agent.isSamsung:a.Agent.isMobile=!0}switch(!0){case a.Agent.isiPad:case a.Agent.isiPod:case a.Agent.isiPhone:case a.Agent.isBada:case a.Agent.isBlackberry:case a.Agent.isAndroid:case a.Agent.isWindowsPhone:a.Agent.isMobile=!0,a.Agent.isDesktop=!1}/mobile|^ios\-/i.test(a.Agent.source)&&(a.Agent.isMobile=!0,a.Agent.isDesktop=!1),/dalvik/i.test(a.Agent.source)&&(a.Agent.isAndroidNative=!0,a.Agent.isMobileNative=!0),/scale/i.test(a.Agent.source)&&(a.Agent.isiPhoneNative=!0,a.Agent.isMobileNative=!0)},this.testTablet=function(){var a=this;switch(!0){case a.Agent.isiPad:case a.Agent.isAndroidTablet:case a.Agent.isKindleFire:a.Agent.isTablet=!0}/tablet/i.test(a.Agent.source)&&(a.Agent.isTablet=!0)},this.testNginxGeoIP=function(a){var b=this;return Object.keys(a).forEach(function(c){/^GEOIP/i.test(c)&&(b.Agent.geoIp[c]=a[c])}),b},this.testBot=function(){var a=this,b=c.exec(a.Agent.source.toLowerCase());b?a.Agent.isBot=b[1]:a.Agent.isAuthoritative||(a.Agent.isBot=/bot/i.test(a.Agent.source))},this.testSmartTV=function(){var a=this;a.Agent.isSmartTV=new RegExp("smart-tv|smarttv|googletv|appletv|hbbtv|pov_tv|netcast.tv","gi").test(a.Agent.source.toLowerCase())},this.testAndroidTablet=function(){var a=this;a.Agent.isAndroid&&!/mobile/i.test(a.Agent.source)&&(a.Agent.isAndroidTablet=!0)},this.testWebkit=function(){var a=this;"unknown"===a.Agent.browser&&/applewebkit/i.test(a.Agent.source)&&(a.Agent.browser="Apple WebKit",a.Agent.isWebkit=!0)},this.testWechat=function(){var a=this;/micromessenger/i.test(a.Agent.source)&&(a.Agent.isWechat=!0,a.Agent.version=this.getWechatVersion(a.Agent.source))},this.parse=function(a){var b=new d;return b.Agent.source=a.replace(/^\s*/,"").replace(/\s*$/,""),b.Agent.os=b.getOS(b.Agent.source),b.Agent.platform=b.getPlatform(b.Agent.source),b.Agent.browser=b.getBrowser(b.Agent.source),b.Agent.version=b.getBrowserVersion(b.Agent.source),b.Agent.electronVersion=b.getElectronVersion(b.Agent.source),b.Agent.osVersion=b.getOSVersion(b.Agent.source),b.testBot(),b.testSmartTV(),b.testMobile(),b.testAndroidTablet(),b.testTablet(),b.testCompatibilityMode(),b.testSilk(),b.testKindleFire(),b.testCaptiveNetwork(),b.testWebkit(),b.testWechat(),b.Agent},this.Agent=this.DefaultAgent,this};return a.UserAgent=d,new d}(this); \ No newline at end of file diff --git a/test/os_version.test.js b/test/os_version.test.js new file mode 100644 index 0000000..67547a3 --- /dev/null +++ b/test/os_version.test.js @@ -0,0 +1,82 @@ +/** + * @author Juan Lago + * + * User-agents samples extracted from https://developers.whatismybrowser.com + **/ + +var ua = require(".."); + +var VERSIONS_SAMPLES = [ + // iOS for iPad + { + source: 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', + expected: '12.2' + }, + + // iOS for iPhone + { + source: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1', + expected: '13.3.1' + }, + + // Android + { + source: 'Mozilla/5.0 (Linux; Android 7.1.2; AFTMM Build/NS6265; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.110 Mobile Safari/537.36', + expected: '7.1.2' + }, + + // Chrome OS + { + source: 'Mozilla/5.0 (X11; CrOS x86_64 12871.102.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36', + expected: '12871.102.0' + }, + { + source: 'Mozilla/5.0 (X11; CrOS x86_64 12739.111.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36', + expected: '12739.111.0' + }, + { + source: 'Mozilla/5.0 (X11; CrOS armv7l 11647.104.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.88 Safari/537.36', + expected: '11647.104.0' + }, + + // OS X + { + source: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A', + expected: '10.9.3' + }, + { + source: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:16.0) Gecko/20100101 Firefox/16.0', + expected: '10.6' + }, + + // Windows + { + source: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36', + expected: '10.0' + }, + { + source: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)', + expected: '5.1' + }, + { + source: ' Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko)', + expected: '6.1' + }, + + // Windows Mobile + { + source: 'Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Lumia 435) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537', + expected: '8.1' + } +] + + + +exports["OS Versions"] = function (test) { + VERSIONS_SAMPLES.forEach(function (eTest) { + var userAgent = ua.parse(eTest.source); + test.equal(userAgent.osVersion, eTest.expected); + }); + + test.done(); +} diff --git a/test/tests.js b/test/tests.js index 6bc8e9a..09d13cd 100644 --- a/test/tests.js +++ b/test/tests.js @@ -6,9 +6,11 @@ var browsers = require('./browsers.test.js'); var smartTV = require('./smart_tv.test.js'); var silk = require('./silk.test.js'); var electron = require('./electron.test.js'); +var osVersions = require('./os_version.test.js'); var wechat = require('./wechat.test.js'); var geoip = require('./geoip.test.js'); + var tests = {}; Object.assign( @@ -21,6 +23,7 @@ Object.assign( smartTV, silk, electron, + osVersions, geoip, wechat ); From a0738f8ac6b21a0befdd17a0e54b952154f49fdb Mon Sep 17 00:00:00 2001 From: Juan Lago Date: Mon, 3 Aug 2020 14:19:11 +0200 Subject: [PATCH 2/3] Added Typescript definitions --- index.d.ts | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..acc07ee --- /dev/null +++ b/index.d.ts @@ -0,0 +1,152 @@ +// Type definitions for express-useragent 1.0 +// Project: https://www.npmjs.org/package/express-useragent +// Definitions by: Isman Usoh +// CiarĂ¡n Ingle +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Request, Response, NextFunction } from 'express'; + +declare global { + namespace Express { + interface Request { + useragent?: Details; + } + } +} + +export interface Details { + isMobile: boolean; + isTablet: boolean; + isiPad: boolean; + isiPod: boolean; + isiPhone: boolean; + isAndroid: boolean; + isBlackberry: boolean; + isOpera: boolean; + isIE: boolean; + isEdge: boolean; + isIECompatibilityMode: boolean; + isSafari: boolean; + isFirefox: boolean; + isWebkit: boolean; + isChrome: boolean; + isKonqueror: boolean; + isOmniWeb: boolean; + isSeaMonkey: boolean; + isFlock: boolean; + isAmaya: boolean; + isEpiphany: boolean; + isDesktop: boolean; + isWindows: boolean; + isWindowsPhone: boolean; + isLinux: boolean; + isLinux64: boolean; + isMac: boolean; + isChromeOS: boolean; + isBada: boolean; + isSamsung: boolean; + isRaspberry: boolean; + isBot: boolean; + isCurl: boolean; + isAndroidTablet: boolean; + isWinJs: boolean; + isKindleFire: boolean; + isSilk: boolean; + isCaptive: boolean; + isSmartTV: boolean; + silkAccelerated: boolean; + browser: string; + version: string; + os: string; + osVersion: string; + platform: string; + geoIp: { [key: string]: any }; + source: string; +} + +export const version: string; + +export const DefaultAgent: Details; + +export const Agent: Details; + +export function getBrowser(string: string): string; + +export function getBrowserVersion(string: string): string; + +export function getOS(string: string): string; + +export function getPlatform(string: string): string; + +export function testCompatibilityMode(): void; + +export function testSilk(): 'Silk' | false; + +export function testKindleFire(): string | false; + +export function testCaptiveNetwork(): 'CaptiveNetwork' | false; + +export function reset(): Details; + +export function testMobile(): void; + +export function testTablet(): void; + +export function testNginxGeoIP(): void; + +export function testBot(): void; + +export function testSmartTV(): void; + +export function testAndroidTablet(): void; + +export function testWebkit(): void; + +export function parse(source: string): Details; + +export class UserAgent { + version: string; + + DefaultAgent: Details; + + Agent: Details; + + getBrowser(string: string): string; + + getBrowserVersion(string: string): string; + + getOS(string: string): string; + + getOSVersion(string: string) : string; + + getPlatform(string: string): string; + + testCompatibilityMode(): void; + + testSilk(): 'Silk' | false; + + testKindleFire(): string | false; + + testCaptiveNetwork(): 'CaptiveNetwork' | false; + + reset(): Details; + + testMobile(): void; + + testTablet(): void; + + testNginxGeoIP(): void; + + testBot(): void; + + testSmartTV(): void; + + testAndroidTablet(): void; + + testWebkit(): void; + + parse(source: string): Details; +} + +export function express(): (req: Request, res: Response, next?: NextFunction) => void; From 44b3ae4d54d34959115a52a392fac9511023a0d9 Mon Sep 17 00:00:00 2001 From: Juan Lago Date: Tue, 29 Sep 2020 13:59:01 +0200 Subject: [PATCH 3/3] isBot result is casted as boolean --- lib/express-useragent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/express-useragent.js b/lib/express-useragent.js index d24b9c1..c16a889 100644 --- a/lib/express-useragent.js +++ b/lib/express-useragent.js @@ -856,7 +856,7 @@ var ua = this; var isBot = IS_BOT_REGEXP.exec(ua.Agent.source.toLowerCase()); if (isBot) { - ua.Agent.isBot = isBot[1]; + ua.Agent.isBot = !!isBot[1]; } else if (!ua.Agent.isAuthoritative) { // Test unauthoritative parse for `bot` in UA to flag for bot ua.Agent.isBot = /bot/i.test(ua.Agent.source);