Redirect cast extension chrome-extension:// URLs to regular API URL

This commit is contained in:
hensm
2019-03-13 07:51:38 +00:00
parent 00e923c8ce
commit 870a759251
4 changed files with 80 additions and 8 deletions

View File

@@ -173,10 +173,19 @@ async function onBeforeSendHeaders (
currentUAString = getChromeUserAgent(os);
}
const host = details.requestHeaders.find(
(header: any) => header.name === "Host");
// Find and rewrite the User-Agent header
for (const header of details.requestHeaders) {
if (header.name.toLowerCase() === "user-agent") {
header.value = currentUAString;
// TODO: Move this somewhere else
if (host.value === "www.youtube.com") {
header.value = getChromeUserAgent(os, true);
} else {
header.value = currentUAString;
}
break;
}
}