Fix Kiwi browser issues

- Twitch worker URL on mobile was ignored
- chromiumProxyActive property bugged
This commit is contained in:
younesaassila 2024-01-17 19:22:22 +01:00
parent 8358126130
commit 602e4a9f9b
4 changed files with 7 additions and 19 deletions

View File

@ -7,7 +7,6 @@ import onBeforeTwitchTvRequest from "./handlers/onBeforeTwitchTvRequest";
import onBeforeVideoWeaverRequest from "./handlers/onBeforeVideoWeaverRequest";
import onContentScriptMessage from "./handlers/onContentScriptMessage";
import onProxyRequest from "./handlers/onProxyRequest";
import onProxySettingsChange from "./handlers/onProxySettingsChanged";
import onResponseStarted from "./handlers/onResponseStarted";
import onStartupStoreCleanup from "./handlers/onStartupStoreCleanup";
import onTabCreated from "./handlers/onTabCreated";
@ -33,9 +32,6 @@ browser.webRequest.onResponseStarted.addListener(onResponseStarted, {
});
if (isChromium) {
// Listen to whether proxy is set or not.
browser.proxy.settings.onChange.addListener(onProxySettingsChange);
// Listen to messages from the content script.
browser.runtime.onMessage.addListener(onContentScriptMessage);

View File

@ -1,10 +0,0 @@
import { Types } from "webextension-polyfill";
import store from "../../store";
export default function onProxySettingsChange(
details: Types.SettingOnChangeDetailsType
) {
console.log(`⚙️ Proxy settings changed: ${details.levelOfControl}`);
store.state.chromiumProxyActive =
details.levelOfControl == "controlled_by_this_extension";
}

View File

@ -11,7 +11,7 @@ import {
import updateDnsResponses from "./updateDnsResponses";
export function updateProxySettings(mode?: "limited" | "full") {
const { optimizedProxiesEnabled, passportLevel } = store.state;
const { optimizedProxiesEnabled } = store.state;
mode ??= optimizedProxiesEnabled ? "limited" : "full";
@ -88,6 +88,7 @@ export function updateProxySettings(mode?: "limited" | "full") {
proxies.toString() || "<empty>"
} (${mode})`
);
store.state.chromiumProxyActive = true;
updateDnsResponses();
});
}
@ -105,5 +106,6 @@ function getProxyInfoStringFromUrls(urls: string[]): string {
export function clearProxySettings() {
chrome.proxy.settings.clear({ scope: "regular" }, function () {
console.log("⚙️ Proxy settings cleared");
store.state.chromiumProxyActive = false;
});
}

View File

@ -19,23 +19,23 @@ window.fetch = getFetch(pageState);
window.Worker = class Worker extends NATIVE_WORKER {
constructor(scriptURL: string | URL, options?: WorkerOptions) {
const isTwitchWorker = scriptURL.toString().includes("twitch.tv");
const fullUrl = toAbsoluteUrl(scriptURL.toString());
const isTwitchWorker = fullUrl.includes(".twitch.tv");
if (!isTwitchWorker) {
super(scriptURL, options);
return;
}
const url = scriptURL.toString();
let script = "";
// Fetch Twitch's script, since Firefox Nightly errors out when trying to
// import a blob URL directly.
const xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
xhr.open("GET", fullUrl, false);
xhr.send();
if (200 <= xhr.status && xhr.status < 300) {
script = xhr.responseText;
} else {
console.warn(`[TTV LOL PRO] Failed to fetch script: ${xhr.statusText}`);
script = `importScripts("${url}");`; // Will fail on Firefox Nightly.
script = `importScripts("${fullUrl}");`; // Will fail on Firefox Nightly.
}
// ---------------------------------------
// 🦊 Attention Firefox Addon Reviewer 🦊