mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-09 09:09:58 +00:00
Replace legacy UA with hybrid Firefox/Chrome UA
This commit is contained in:
@@ -1,36 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
const PLATFORM_MAC = "Macintosh; Intel Mac OS X 10_14_1";
|
||||
const PLATFORM_MAC = "Macintosh; Intel Mac OS X 10_15_2";
|
||||
const PLATFORM_MAC_HYBRID = "Macintosh; Intel Mac OS X 10.15; rv:72.0";
|
||||
const PLATFORM_WIN = "Windows NT 10.0; Win64; x64";
|
||||
const PLATFORM_LINUX = "Mozilla/5.0 (X11; Linux x86_64";
|
||||
const PLATFORM_LINUX = "X11; Linux x86_64";
|
||||
|
||||
const UA_PREFIX = "Mozilla/5.0";
|
||||
const UA_CHROME = "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36";
|
||||
const UA_HYBRID = "Chrome/80.0.3987.87 Gecko/20100101 Firefox/72.0"
|
||||
|
||||
const UA_CHROME = "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36";
|
||||
const UA_CHROME_LEGACY = "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2883.87 Safari/537.36";
|
||||
const UA_SAFARI = "AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15";
|
||||
|
||||
|
||||
function getPlatformComponent (platform: string): string | undefined {
|
||||
switch (platform) {
|
||||
case "mac": return PLATFORM_MAC; break;
|
||||
case "win": return PLATFORM_WIN; break;
|
||||
case "linux": return PLATFORM_LINUX; break;
|
||||
export function getChromeUserAgent(platform: string, hybrid = false) {
|
||||
let platformComponent: string;
|
||||
if (platform === "mac") {
|
||||
platformComponent = hybrid
|
||||
? PLATFORM_MAC_HYBRID
|
||||
: PLATFORM_MAC;
|
||||
} else if (platform === "win") {
|
||||
platformComponent = PLATFORM_WIN;
|
||||
} else if (platform === "linux") {
|
||||
platformComponent = PLATFORM_LINUX;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export function getChromeUserAgent (
|
||||
platform: string
|
||||
, legacy: boolean = false): string {
|
||||
|
||||
const platformComponent = getPlatformComponent(platform);
|
||||
const browserComponent = legacy
|
||||
? UA_CHROME_LEGACY
|
||||
const browserComponent = hybrid
|
||||
? UA_HYBRID
|
||||
: UA_CHROME;
|
||||
|
||||
return `${UA_PREFIX} (${platformComponent}) ${browserComponent}`;
|
||||
}
|
||||
|
||||
export function getSafariUserAgent (): string {
|
||||
return `${UA_PREFIX} (${PLATFORM_MAC}) ${UA_SAFARI}`;
|
||||
return `Mozilla/5.0 (${platformComponent}) ${browserComponent}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user