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") { if (details.reason === "update") {
// Remove old Chromium normal proxy. // Remove old Chromium normal proxy.
if ( const oldChromiumProxy = "chrome.api.cdn-perfprod.com:4023";
store.state.normalProxies.includes("chrome.api.cdn-perfprod.com:4023") if (store.state.normalProxies.includes(oldChromiumProxy)) {
) {
store.state.normalProxies = store.state.normalProxies.filter( store.state.normalProxies = store.state.normalProxies.filter(
proxy => proxy !== "chrome.api.cdn-perfprod.com:4023" proxy => proxy !== oldChromiumProxy
); );
if (store.state.normalProxies.length === 0) { if (store.state.normalProxies.length === 0) {
store.state.optimizedProxiesEnabled = true; store.state.optimizedProxiesEnabled = true;
} }
} }
// Add new Chromium optimized proxy. // Add new Chromium optimized proxy.
const newChromiumProxy = "chromium.api.cdn-perfprod.com:2023";
if ( if (
isChromium && isChromium &&
!store.state.optimizedProxies.includes( !store.state.optimizedProxies.includes(newChromiumProxy)
"chromium.api.cdn-perfprod.com:2023"
)
) { ) {
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 const documentHost = details.documentUrl
? getHostFromUrl(details.documentUrl) ? getHostFromUrl(details.documentUrl)
: null; : null;
const isFromTwitchTvHost = // Twitch requests from non-Twitch hosts are not supported.
documentHost != null && documentHost.endsWith(".twitch.tv"); 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. // Wait for the store to be ready.
if (store.readyState !== "complete") { if (store.readyState !== "complete") {
@ -74,12 +80,6 @@ export default async function onProxyRequest(
// Passport requests. // Passport requests.
if (proxyPassportRequest && passportHostRegex.test(host)) { if (proxyPassportRequest && passportHostRegex.test(host)) {
if (!isFromTwitchTvHost) {
console.log(
`✋ '${details.url}' from host '${documentHost}' is not supported.`
);
return { type: "direct" };
}
console.log( console.log(
`⌛ Proxying ${details.url} through one of: ${ `⌛ Proxying ${details.url} through one of: ${
proxies.toString() || "<empty>" proxies.toString() || "<empty>"
@ -90,12 +90,6 @@ export default async function onProxyRequest(
// Usher requests. // Usher requests.
if (proxyUsherRequest && usherHostRegex.test(host)) { 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/")) { if (details.url.includes("/vod/")) {
console.log(`✋ '${details.url}' is a VOD manifest.`); console.log(`✋ '${details.url}' is a VOD manifest.`);
return { type: "direct" }; return { type: "direct" };
@ -115,12 +109,6 @@ export default async function onProxyRequest(
// Video Weaver requests. // Video Weaver requests.
if (proxyVideoWeaverRequest && videoWeaverHostRegex.test(host)) { if (proxyVideoWeaverRequest && videoWeaverHostRegex.test(host)) {
if (!isFromTwitchTvHost) {
console.log(
`✋ '${details.url}' from host '${documentHost}' is not supported.`
);
return { type: "direct" };
}
const channelName = const channelName =
findChannelFromVideoWeaverUrl(details.url) ?? findChannelFromVideoWeaverUrl(details.url) ??
findChannelFromTwitchTvUrl(details.documentUrl); findChannelFromTwitchTvUrl(details.documentUrl);
@ -138,12 +126,6 @@ export default async function onProxyRequest(
// Twitch GraphQL requests. // Twitch GraphQL requests.
if (proxyGraphQLRequest && twitchGqlHostRegex.test(host)) { if (proxyGraphQLRequest && twitchGqlHostRegex.test(host)) {
if (!isFromTwitchTvHost) {
console.log(
`✋ '${details.url}' from host '${documentHost}' is not supported.`
);
return { type: "direct" };
}
console.log( console.log(
`⌛ Proxying ${details.url} through one of: ${ `⌛ Proxying ${details.url} through one of: ${
proxies.toString() || "<empty>" proxies.toString() || "<empty>"

View File

@ -69,7 +69,8 @@ export default function isRequestTypeProxied(
) { ) {
return true; 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) { if (params.isChromium && params.fullModeEnabled === false) {
return false; return false;
} }