EmbyCrackedClient/web/modules/browser.js

1 line
4.1 KiB
JavaScript
Raw Permalink Normal View History

2025-06-25 11:46:04 +08:00
function isTv(userAgent){return!!((userAgent=userAgent.toLowerCase()).includes("tv")||userAgent.includes("viera")||userAgent.includes("web0s")||userAgent.includes("zidoo"))}function tizenVersion(){var v;if("undefined"!=typeof tizen&&tizen.systeminfo)return v=tizen.systeminfo.getCapability("http://tizen.org/feature/platform.version"),parseFloat(v)}function isXbox(userAgentLower){return!!userAgentLower.includes("xbox")||!("undefined"==typeof Windows||!Windows.System)&&"Windows.Xbox"===Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily}function isMobile(userAgent){var lower=userAgent.toLowerCase();if(lower.includes("android tv"))return!1;var terms=["mobi","ipad","iphone","ipod","silk","kindle fire","opera mini"];for(let i=0,length=terms.length;i<length;i++)if(lower.includes(terms[i]))return!0;return"undefined"!=typeof document&&"ontouchstart"in document.documentElement}function polyfillBrands(userAgentData,browser){let brands=userAgentData.brands;if(brands||(brands=[],userAgentData.brands=brands),!brands.length){let deviceName;deviceName=browser.chrome?"Chrome":browser.edge?"Edge":browser.firefox?"Firefox":browser.opera?"Opera":browser.safari?"Safari":"Web Browser";try{brands.push({brand:deviceName})}catch(err){console.log("error adding brands: "+err)}if(browser.chrome||browser.opera)try{brands.push({brand:"Chromium"})}catch(err){console.log("error adding brands: "+err)}}}function getHighEntropyValues(){var info={};return this.android?info.platform="Android":this.iOS?info.platform="iOS":this.ipad?info.platform="iPadOS":this.osx?info.platform="macOS":this.xboxOne?info.platform="Xbox One":this.windows?info.platform="Windows":this.playstation?info.platform="PlayStation":this.netcast?info.platform="LG TV":this.tizen?info.platform="Samsung TV":this.operaTv&&(info.platform="Opera TV"),Promise.resolve(info)}function polyfilUserAgentData(browser,userAgent){let userAgentData=navigator.userAgentData;if(userAgentData||(userAgentData={},navigator.userAgentData=userAgentData),null==userAgentData.mobile)try{userAgentData.mobile=isMobile(userAgent)}catch(err){console.log("error setting userAgentData.mobile: "+err)}polyfillBrands(userAgentData,browser),userAgentData.getHighEntropyValues||(userAgentData.getHighEntropyValues=getHighEntropyValues.bind(browser))}let uaMatch=function(ua){ua=ua.toLowerCase();var match=/(edge)[ \/]([\w.]+)/.exec(ua)||/(opera)[ \/]([\w.]+)/.exec(ua)||/(opr)[ \/]([\w.]+)/.exec(ua)||/(chrome)[ \/]([\w.]+)/.exec(ua)||/(safari)[ \/]([\w.]+)/.exec(ua)||/(firefox)[ \/]([\w.]+)/.exec(ua)||[];let platform_match=/(ipad)/.exec(ua)||/(iphone)/.exec(ua)||/(android)/.exec(ua)||[],browser=match[1]||"";return"edge"===browser&&(platform_match=[""]),{browser:browser="opr"===browser?"opera":browser,platform:platform_match[0]||""}},userAgent=navigator.userAgent,matched=uaMatch(userAgent),browser={},userAgentLower=(matched.browser&&(browser[matched.browser]=!0),matched.platform&&(browser[matched.platform]=!0),userAgent.toLowerCase());browser.chrome||browser.edge||browser.opera||!userAgentLower.includes("webkit")||(browser.safari=!0),userAgentLower.includes("playstation")&&(browser.playstation=!0,browser.tv=!0,userAgentLower.includes("playstation 4"))&&(browser.ps4=!0),browser.xboxOne=isXbox(userAgentLower),browser.tizen=userAgentLower.includes("tizen")||null!=globalThis.tizen,browser.netcast=userAgentLower.includes("netcast")||userAgentLower.includes("Web0S".toLowerCase()),browser.electron=userAgentLower.includes("electron"),browser.windows=userAgentLower.includes("windows"),browser.tizen&&(browser.sdkVersion=tizenVersion()),browser.tv=isTv(userAgent),(browser.tv&&userAgentLower.includes("opr/")||globalThis.location&&(globalThis.location.href||"").toString().toLowerCase().includes("operatv"))&&(browser.tv=!0,browser.operaTv=!0),(browser.xboxOne||browser.playstation||browser.tizen||browser.netcast||browser.operaTv||userAgentLower.includes("smarthub"))&&(browser.tv=!0),browser.iOS=browser.ipad||browser.iphone||browser.ipod,browser.iOS||(browser.osx=userAgentLower.includes("mac os x")),browser.chromecast=browser.chrome&&user