mirror of
https://github.com/younesaassila/ttv-lol-pro.git
synced 2025-05-10 11:24:31 +02:00
Improvements
This commit is contained in:
parent
c3924c17b1
commit
832fb16251
@ -20,6 +20,17 @@ import { ProxyInfo, ProxyRequestType } from "../../types";
|
|||||||
export default async function onProxyRequest(
|
export default async function onProxyRequest(
|
||||||
details: Proxy.OnRequestDetailsType
|
details: Proxy.OnRequestDetailsType
|
||||||
): Promise<ProxyInfo | ProxyInfo[]> {
|
): 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);
|
const host = getHostFromUrl(details.url);
|
||||||
if (!host) return { type: "direct" };
|
if (!host) return { type: "direct" };
|
||||||
|
|
||||||
@ -35,17 +46,6 @@ export default async function onProxyRequest(
|
|||||||
return { type: "direct" };
|
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
|
const proxies = store.state.optimizedProxiesEnabled
|
||||||
? store.state.optimizedProxies
|
? store.state.optimizedProxies
|
||||||
: store.state.normalProxies;
|
: store.state.normalProxies;
|
||||||
@ -136,7 +136,6 @@ export default async function onProxyRequest(
|
|||||||
|
|
||||||
// Twitch webpage requests.
|
// Twitch webpage requests.
|
||||||
if (proxyTwitchWebpageRequest && twitchTvHostRegex.test(host)) {
|
if (proxyTwitchWebpageRequest && twitchTvHostRegex.test(host)) {
|
||||||
// No check for `isFromTwitchTvHost` here because `documentHost` is null.
|
|
||||||
console.log(
|
console.log(
|
||||||
`⌛ Proxying ${details.url} through one of: ${
|
`⌛ Proxying ${details.url} through one of: ${
|
||||||
proxies.toString() || "<empty>"
|
proxies.toString() || "<empty>"
|
||||||
|
@ -54,7 +54,7 @@ export default function isRequestTypeProxied(
|
|||||||
|
|
||||||
if (type === ProxyRequestType.GraphQL) {
|
if (type === ProxyRequestType.GraphQL) {
|
||||||
// Proxy all GQL requests when passport is unoptimized official+ (Chromium)
|
// Proxy all GQL requests when passport is unoptimized official+ (Chromium)
|
||||||
// or unoptimized diplomatic (Firefox).
|
// or unoptimized diplomatic+ (Firefox).
|
||||||
if (
|
if (
|
||||||
params.isChromium &&
|
params.isChromium &&
|
||||||
!params.optimizedProxiesEnabled &&
|
!params.optimizedProxiesEnabled &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user