Improvements

This commit is contained in:
younesaassila 2024-01-26 17:59:22 +01:00
parent 1c622d7ce0
commit c3924c17b1
3 changed files with 16 additions and 35 deletions

View File

@ -12,24 +12,22 @@ export default function onInstalledStoreCleanup(
if (details.reason === "update") {
// Remove old Chromium normal proxy.
if (
store.state.normalProxies.includes("chrome.api.cdn-perfprod.com:4023")
) {
const oldChromiumProxy = "chrome.api.cdn-perfprod.com:4023";
if (store.state.normalProxies.includes(oldChromiumProxy)) {
store.state.normalProxies = store.state.normalProxies.filter(
proxy => proxy !== "chrome.api.cdn-perfprod.com:4023"
proxy => proxy !== oldChromiumProxy
);
if (store.state.normalProxies.length === 0) {
store.state.optimizedProxiesEnabled = true;
}
}
// Add new Chromium optimized proxy.
const newChromiumProxy = "chromium.api.cdn-perfprod.com:2023";
if (
isChromium &&
!store.state.optimizedProxies.includes(
"chromium.api.cdn-perfprod.com:2023"
)
!store.state.optimizedProxies.includes(newChromiumProxy)
) {
store.state.optimizedProxies.push("chromium.api.cdn-perfprod.com:2023");
store.state.optimizedProxies.push(newChromiumProxy);
}
}
}

View File

@ -26,8 +26,14 @@ export default async function onProxyRequest(
const documentHost = details.documentUrl
? getHostFromUrl(details.documentUrl)
: null;
const isFromTwitchTvHost =
documentHost != null && documentHost.endsWith(".twitch.tv");
// Twitch requests from non-Twitch hosts are not supported.
if (
documentHost != null && // Twitch webpage requests have no document URL.
!passportHostRegex.test(documentHost) && // Passport requests have a `passport.twitch.tv` document URL.
!twitchTvHostRegex.test(documentHost)
) {
return { type: "direct" };
}
// Wait for the store to be ready.
if (store.readyState !== "complete") {
@ -74,12 +80,6 @@ export default async function onProxyRequest(
// Passport requests.
if (proxyPassportRequest && passportHostRegex.test(host)) {
if (!isFromTwitchTvHost) {
console.log(
`✋ '${details.url}' from host '${documentHost}' is not supported.`
);
return { type: "direct" };
}
console.log(
`⌛ Proxying ${details.url} through one of: ${
proxies.toString() || "<empty>"
@ -90,12 +90,6 @@ export default async function onProxyRequest(
// Usher requests.
if (proxyUsherRequest && usherHostRegex.test(host)) {
if (!isFromTwitchTvHost) {
console.log(
`✋ '${details.url}' from host '${documentHost}' is not supported.`
);
return { type: "direct" };
}
if (details.url.includes("/vod/")) {
console.log(`✋ '${details.url}' is a VOD manifest.`);
return { type: "direct" };
@ -115,12 +109,6 @@ export default async function onProxyRequest(
// Video Weaver requests.
if (proxyVideoWeaverRequest && videoWeaverHostRegex.test(host)) {
if (!isFromTwitchTvHost) {
console.log(
`✋ '${details.url}' from host '${documentHost}' is not supported.`
);
return { type: "direct" };
}
const channelName =
findChannelFromVideoWeaverUrl(details.url) ??
findChannelFromTwitchTvUrl(details.documentUrl);
@ -138,12 +126,6 @@ export default async function onProxyRequest(
// Twitch GraphQL requests.
if (proxyGraphQLRequest && twitchGqlHostRegex.test(host)) {
if (!isFromTwitchTvHost) {
console.log(
`✋ '${details.url}' from host '${documentHost}' is not supported.`
);
return { type: "direct" };
}
console.log(
`⌛ Proxying ${details.url} through one of: ${
proxies.toString() || "<empty>"

View File

@ -69,7 +69,8 @@ export default function isRequestTypeProxied(
) {
return true;
}
// Proxy flagged GQL requests when passport is official+.
// Proxy flagged GQL requests when passport is official+ (Chromium) or
// ordinary+ (Firefox).
if (params.isChromium && params.fullModeEnabled === false) {
return false;
}