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 onBeforeVideoWeaverRequest from "./handlers/onBeforeVideoWeaverRequest";
import onContentScriptMessage from "./handlers/onContentScriptMessage"; import onContentScriptMessage from "./handlers/onContentScriptMessage";
import onProxyRequest from "./handlers/onProxyRequest"; import onProxyRequest from "./handlers/onProxyRequest";
import onProxySettingsChange from "./handlers/onProxySettingsChanged";
import onResponseStarted from "./handlers/onResponseStarted"; import onResponseStarted from "./handlers/onResponseStarted";
import onStartupStoreCleanup from "./handlers/onStartupStoreCleanup"; import onStartupStoreCleanup from "./handlers/onStartupStoreCleanup";
import onTabCreated from "./handlers/onTabCreated"; import onTabCreated from "./handlers/onTabCreated";
@ -33,9 +32,6 @@ browser.webRequest.onResponseStarted.addListener(onResponseStarted, {
}); });
if (isChromium) { if (isChromium) {
// Listen to whether proxy is set or not.
browser.proxy.settings.onChange.addListener(onProxySettingsChange);
// Listen to messages from the content script. // Listen to messages from the content script.
browser.runtime.onMessage.addListener(onContentScriptMessage); 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"; import updateDnsResponses from "./updateDnsResponses";
export function updateProxySettings(mode?: "limited" | "full") { export function updateProxySettings(mode?: "limited" | "full") {
const { optimizedProxiesEnabled, passportLevel } = store.state; const { optimizedProxiesEnabled } = store.state;
mode ??= optimizedProxiesEnabled ? "limited" : "full"; mode ??= optimizedProxiesEnabled ? "limited" : "full";
@ -88,6 +88,7 @@ export function updateProxySettings(mode?: "limited" | "full") {
proxies.toString() || "<empty>" proxies.toString() || "<empty>"
} (${mode})` } (${mode})`
); );
store.state.chromiumProxyActive = true;
updateDnsResponses(); updateDnsResponses();
}); });
} }
@ -105,5 +106,6 @@ function getProxyInfoStringFromUrls(urls: string[]): string {
export function clearProxySettings() { export function clearProxySettings() {
chrome.proxy.settings.clear({ scope: "regular" }, function () { chrome.proxy.settings.clear({ scope: "regular" }, function () {
console.log("⚙️ Proxy settings cleared"); 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 { window.Worker = class Worker extends NATIVE_WORKER {
constructor(scriptURL: string | URL, options?: WorkerOptions) { 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) { if (!isTwitchWorker) {
super(scriptURL, options); super(scriptURL, options);
return; return;
} }
const url = scriptURL.toString();
let script = ""; let script = "";
// Fetch Twitch's script, since Firefox Nightly errors out when trying to // Fetch Twitch's script, since Firefox Nightly errors out when trying to
// import a blob URL directly. // import a blob URL directly.
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open("GET", url, false); xhr.open("GET", fullUrl, false);
xhr.send(); xhr.send();
if (200 <= xhr.status && xhr.status < 300) { if (200 <= xhr.status && xhr.status < 300) {
script = xhr.responseText; script = xhr.responseText;
} else { } else {
console.warn(`[TTV LOL PRO] Failed to fetch script: ${xhr.statusText}`); 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 🦊 // 🦊 Attention Firefox Addon Reviewer 🦊