Improvements

This commit is contained in:
younesaassila 2024-01-26 18:20:09 +01:00
parent c3924c17b1
commit 832fb16251
2 changed files with 12 additions and 13 deletions

View File

@ -20,6 +20,17 @@ import { ProxyInfo, ProxyRequestType } from "../../types";
export default async function onProxyRequest(
details: Proxy.OnRequestDetailsType
): Promise<ProxyInfo | ProxyInfo[]> {
// Wait for the store to be ready.
if (store.readyState !== "complete") {
await new Promise(resolve => {
const listener = () => {
store.removeEventListener("load", listener);
resolve(onProxyRequest(details));
};
store.addEventListener("load", listener);
});
}
const host = getHostFromUrl(details.url);
if (!host) return { type: "direct" };
@ -35,17 +46,6 @@ export default async function onProxyRequest(
return { type: "direct" };
}
// Wait for the store to be ready.
if (store.readyState !== "complete") {
await new Promise(resolve => {
const listener = () => {
store.removeEventListener("load", listener);
resolve(onProxyRequest(details));
};
store.addEventListener("load", listener);
});
}
const proxies = store.state.optimizedProxiesEnabled
? store.state.optimizedProxies
: store.state.normalProxies;
@ -136,7 +136,6 @@ export default async function onProxyRequest(
// Twitch webpage requests.
if (proxyTwitchWebpageRequest && twitchTvHostRegex.test(host)) {
// No check for `isFromTwitchTvHost` here because `documentHost` is null.
console.log(
`⌛ Proxying ${details.url} through one of: ${
proxies.toString() || "<empty>"

View File

@ -54,7 +54,7 @@ export default function isRequestTypeProxied(
if (type === ProxyRequestType.GraphQL) {
// Proxy all GQL requests when passport is unoptimized official+ (Chromium)
// or unoptimized diplomatic (Firefox).
// or unoptimized diplomatic+ (Firefox).
if (
params.isChromium &&
!params.optimizedProxiesEnabled &&