mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-11 18:19:58 +00:00
Use hybrid user agent string only on YouTube
This commit is contained in:
@@ -441,8 +441,10 @@ async function initWhitelist () {
|
|||||||
|
|
||||||
|
|
||||||
const originUrlCache: string[] = [];
|
const originUrlCache: string[] = [];
|
||||||
const chromeUserAgent = getChromeUserAgent(
|
|
||||||
(await browser.runtime.getPlatformInfo()).os, true);
|
// TODO: Allow hybrid UA to be configurable
|
||||||
|
const platform = (await browser.runtime.getPlatformInfo()).os;
|
||||||
|
const chromeUserAgent = getChromeUserAgent(platform);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web apps usually only load the sender library and
|
* Web apps usually only load the sender library and
|
||||||
@@ -466,7 +468,9 @@ async function initWhitelist () {
|
|||||||
|
|
||||||
for (const header of details.requestHeaders) {
|
for (const header of details.requestHeaders) {
|
||||||
if (header.name === "User-Agent") {
|
if (header.name === "User-Agent") {
|
||||||
header.value = chromeUserAgent;
|
header.value = host?.value === "www.youtube.com"
|
||||||
|
? getChromeUserAgent(platform, true)
|
||||||
|
: chromeUserAgent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -491,9 +495,14 @@ async function initWhitelist () {
|
|||||||
|
|
||||||
for (const ancestor of details.frameAncestors) {
|
for (const ancestor of details.frameAncestors) {
|
||||||
if (originUrlCache.includes(ancestor.url)) {
|
if (originUrlCache.includes(ancestor.url)) {
|
||||||
|
const host = details.requestHeaders.find(
|
||||||
|
header => header.name === "Host");
|
||||||
|
|
||||||
for (const header of details.requestHeaders) {
|
for (const header of details.requestHeaders) {
|
||||||
if (header.name === "User-Agent") {
|
if (header.name === "User-Agent") {
|
||||||
header.value = chromeUserAgent;
|
header.value = host?.value === "www.youtube.com"
|
||||||
|
? getChromeUserAgent(platform, true)
|
||||||
|
: chromeUserAgent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user