-
Notifications
You must be signed in to change notification settings - Fork 3
/
sua.min.js
7 lines (7 loc) · 5.68 KB
/
sua.min.js
1
2
3
4
5
6
7
/**
* @name sua.js
* @author Kei Funagayama <[email protected]>
* @overview UserAgent decision for browser. fork Zepto v1.0-1-ga3cab6c - polyfill zepto detect event ajax form fx - zeptojs.com/license
* @license MIT
*/
!function(h){function i(i){if(!i&&h&&h.navigator&&h.navigator.userAgent&&(i=h.navigator.userAgent),!i)throw new Error("useragent setup error. useragent not found.");if(this.ie=!!(0<=i.indexOf("MSIE")||0<=i.indexOf("Trident")||0<=i.indexOf("Edge")),this.webkit=i.match(/(WebKit|Webkit)\/([\d.]+)/),this.android=i.match(/(Android)\s+([\d.]+)/),this.android23=i.match(/(Android)\s+(2\.3)([\d.]+)/),this.android4=i.match(/(Android)\s+(4)([\d.]+)/),this.android5=i.match(/(Android)\s+(5)([\d.]+)/),this.android6=i.match(/(Android)\s+(6)([\d.]+)/),this.android7=i.match(/(Android)\s+(7)([\d.]+)/),this.android8=i.match(/(Android)\s+(8)([\d.]+)/),this.ipad=i.match(/(iPad).*OS\s([\d_]+)/),this.iphone=!this.ipad&&i.match(/(iPhone\sOS)\s([\d_]+)/),this.webos=i.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),this.touchpad=this.webos&&i.match(/TouchPad/),this.kindle=i.match(/(Kindle)/),this.silk=i.match(/(Silk)/),this.blackberry=i.match(/(BlackBerry).*/),this.bb10=i.match(/(BB10).*Version\/([\d.]+)/),this.rimtabletos=i.match(/(RIM\sTablet\sOS)\s([\d.]+)/),this.playbook=i.match(/PlayBook/),this.chrome=i.match(/Chrome\/([\d.]+)/)||i.match(/CriOS\/([\d.]+)/),this.firefox=i.match(/Firefox\/([\d.]+)/),this.wii=i.match(/Nintendo (Wii);/),this.wiiu=i.match(/Nintendo (WiiU)/),this.ds=i.match(/Nintendo (DS|3DS|DSi);/),this.nintendo_switch=i.match(/Nintendo (Switch);/),this.ps3=i.match(/PLAYSTATION 3/i),this.ps4=i.match(/PLAYSTATION 4/i),this.psp=i.match(/(PlayStation Portable)/),this.psvita=i.match(/(PlayStation Vita)/),this.windowsphone=i.match(/(Windows Phone |Windows Phone OS )([\d.]+)/),this.safari=i.match(/(Version)\/([0-9\.]+).*Safari\/([0-9\.]+)/),this.trident=i.match(/Trident\/([\d\.]+)/),this.xbox=i.match(/Xbox/i),this.iphone5=!("undefined"!=typeof module&&module.exports)&&this.iphone&&screen&&320===screen.width&&568===screen.height,this.vivaldi=i.match(/Vivaldi\/([\d.]+)/),this.iphone3=!(!this.iphone||1!==h.devicePixelRatio),this.chromecast=i.match(/CrKey/),this.roku=i.match(/Roku([\w.]+)/),this.firetv1=i.match(/AFTB/),this.firetv2=i.match(/AFTS/),this.firetvstick1=i.match(/AFTM/),this.firetvstick2=i.match(/AFTT/),this.firetv=!!(this.firetv1||this.firetv2||this.firetvstick1||this.firetvstick2),this.nexusplayer=i.match(/Nexus Player/),this.appletv=i.match(/AppleTV/),this.browser={locale:void 0,lang:void 0,country:void 0},this.os={name:"unknown"},this.webkit&&!this.ie&&(this.browser.webkit=!0,this.browser.version=this.webkit[1]),this.trident&&(this.browser.trident=!0,this.browser.version=this.trident[1]),this.android){this.os.name="android",this.os.android=!0,this.os.version=this.android[2];try{this.browser.locale=i.match(/(Android)\s(.+);\s([^;]+);/)[3],this.browser.lang=this.browser.locale.substring(0,2),this.browser.country=this.browser.locale.substring(3)}catch(i){}}if(this.iphone&&(this.os.ios=this.os.iphone=!0,this.os.name="ios",this.os.version=this.iphone[2].replace(/_/g,".")),this.ipad&&(this.os.ios=this.os.ipad=!0,this.os.name="ios",this.os.version=this.ipad[2].replace(/_/g,".")),this.os.ios){var s=null;this.os.version&&(s=this.os.version.split(".")[0]);for(var t=3;t<13;t++)this["ios"+t]=s===""+t}this.webos&&(this.os.webos=!0,this.os.name="webos",this.os.version=this.webos[2]),this.touchpad&&(this.os.touchpad=!0,this.os.name="webos"),this.blackberry&&(this.os.blackberry=!0,this.os.name="blackberry"),this.bb10&&(this.os.bb10=!0,this.os.name="bb10",this.os.version=this.bb10[2]),this.rimtabletos&&(this.os.rimtabletos=!0,this.os.name="rimtabletos",this.os.version=this.rimtabletos[2]),this.playbook&&(this.browser.playbook=!0),this.kindle&&(this.os.kindle=!0,this.os.name="fireos"),this.silk&&(this.browser.silk=!0),!this.silk&&this.os.android&&i.match(/Kindle Fire/)&&(this.browser.silk=!0),this.chrome&&!this.ie&&(this.browser.chrome=!0,this.browser.version=this.chrome[1]),this.firefox&&(this.browser.firefox=!0,this.browser.version=this.firefox[1],i.match(/Android/)&&(this.android=["Android","Android",""])),(this.wii||this.ds||this.wiiu||this.nintendo_switch)&&(this.os.nintendo=!0,(this.wiiu||this.nintendo_switch)&&(this.browser.nintendo=i.match(/NintendoBrowser\/([\d.]+)/),this.browser.version=this.browser.nintendo[1])),this.windowsphone&&(this.browser.windowsphone=!0,this.browser.version=this.windowsphone[2]),this.safari&&(this.browser.safari=!0,this.browser.version=this.safari[2]),this.ie&&(this.browser.ie=/(MSIE|rv:?)\s?([\d\.]+)/.exec(i),this.edge=!1,this.browser.ie?this.windowsphone||(this.browser.version=this.browser.ie?this.browser.ie[2]:""):(this.browser.ie=/(Edge\/)(\d.+)/.exec(i),this.browser.version=this.browser.ie[2],this.edge=!0,this.chrome=!1,this.webkit=!1),0<this.browser.version.indexOf(".")?this.browser.majorversion=this.browser.version.substring(0,this.browser.version.indexOf(".")):this.browser.majorversion=this.browser.version),this.xbox&&(this.os.name="unknown"),this.firetv&&(this.os.name="fireos"),this.nexusplayer&&(this.os.name="nexusplayer"),this.vivaldi&&(this.browser.vivaldi=!0,this.browser.version=this.vivaldi[1]),this.os.tablet=!!(this.ipad||this.kindle||this.playbook||this.android&&!i.match(/Mobile/)||this.firefox&&i.match(/Tablet/)),this.os.phone=!(this.os.tablet||!(this.android||this.iphone||this.webos||this.blackberry||this.bb10||this.chrome&&i.match(/Android/)||this.chrome&&i.match(/CriOS\/([\d.]+)/)||this.firefox&&i.match(/Mobile/)||this.windowsphone&&i.match(/IEMobile/))),this.mobile=!(!this.os.tablet&&!this.os.phone),this.webview={},i.match(/Twitter/)&&(this.webview.twitter=!0)}i.VERSION="2.6.1","undefined"!=typeof module&&module.exports&&(module.exports=i),h.SUA||(h.SUA=i)}(this);