From 1f31153cd0f6710f933a3a835f54b39f5b427daa Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 10 Sep 2023 19:52:51 +0200 Subject: [PATCH 01/42] =?UTF-8?q?=E2=9C=A8=20Add=20"Anonymous=20mode"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content/content.ts | 18 +++++++++++-- src/options/options.ts | 7 +++++ src/options/page.html | 12 +++++++++ src/page/getFetch.ts | 50 +++++++++++++++++++++++++++++++++++- src/page/page.ts | 15 ++++++++--- src/store/getDefaultState.ts | 1 + src/store/types.ts | 1 + 7 files changed, 98 insertions(+), 6 deletions(-) diff --git a/src/content/content.ts b/src/content/content.ts index 005bfb55..204a7def 100644 --- a/src/content/content.ts +++ b/src/content/content.ts @@ -8,8 +8,8 @@ console.info("[TTV LOL PRO] πŸš€ Content script running."); injectPageScript(); -if (store.readyState === "complete") clearStats(); -else store.addEventListener("load", clearStats); +if (store.readyState === "complete") onStoreReady(); +else store.addEventListener("load", onStoreReady); window.addEventListener("message", onMessage); @@ -30,6 +30,20 @@ function injectPageScript() { (document.head || document.documentElement).append(script); // Note: Despite what the TS types say, `document.head` can be `null`. } +function onStoreReady() { + // Send store state to page script. + const message = { + type: "StoreReady", + state: JSON.parse(JSON.stringify(store.state)), + }; + window.postMessage({ + type: "PageScriptMessage", + message: message, + }); + // Clear stats for stream on page load/reload. + clearStats(); +} + /** * Clear stats for stream on page load/reload. * @returns diff --git a/src/options/options.ts b/src/options/options.ts index 257b427e..c8790d6f 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -35,6 +35,9 @@ const proxyUsherRequestsCheckboxElement = $( const proxyTwitchWebpageCheckboxElement = $( "#proxy-twitch-webpage-checkbox" ) as HTMLInputElement; +const anonymousModeCheckboxElement = $( + "#anonymous-mode-checkbox" +) as HTMLInputElement; // Whitelisted channels const whitelistedChannelsSectionElement = $( "#whitelisted-channels-section" @@ -102,6 +105,10 @@ function main() { updateProxySettings(); } }); + anonymousModeCheckboxElement.checked = store.state.anonymousMode; + anonymousModeCheckboxElement.addEventListener("change", () => { + store.state.anonymousMode = anonymousModeCheckboxElement.checked; + }); // Whitelisted channels if (isChromium) { whitelistedChannelsSectionElement.style.display = "none"; diff --git a/src/options/page.html b/src/options/page.html index d9675d69..752f3b3a 100644 --- a/src/options/page.html +++ b/src/options/page.html @@ -83,6 +83,18 @@

Passport

+
  • + + +
    + Browse Twitch as if you were logged out. +
  • Expiration date: 2038-01-19T03:14:07.000Z diff --git a/src/page/getFetch.ts b/src/page/getFetch.ts index 1dc4233e..a24b9f9f 100644 --- a/src/page/getFetch.ts +++ b/src/page/getFetch.ts @@ -1,5 +1,6 @@ import acceptFlag from "../common/ts/acceptFlag"; import findChannelFromUsherUrl from "../common/ts/findChannelFromUsherUrl"; +import generateRandomString from "../common/ts/generateRandomString"; import getHostFromUrl from "../common/ts/getHostFromUrl"; import { twitchGqlHostRegex, @@ -7,12 +8,14 @@ import { videoWeaverHostRegex, videoWeaverUrlRegex, } from "../common/ts/regexes"; +import { State } from "../store/types"; const NATIVE_FETCH = self.fetch; const IS_CHROMIUM = !!self.chrome; export interface FetchOptions { scope: "page" | "worker"; + state?: State; } export function getFetch(options: FetchOptions): typeof fetch { @@ -21,6 +24,26 @@ export function getFetch(options: FetchOptions): typeof fetch { const videoWeaverUrlsToFlag = new Map(); // Video Weaver URLs to flag -> number of times flagged. const videoWeaverUrlsToIgnore = new Set(); // No response check. + let shouldWaitForStore = true; + setTimeout(() => { + shouldWaitForStore = false; + }, 3000); + + if (options.scope === "page") { + window.addEventListener("message", event => { + if (event.data?.type === "PageScriptMessage") { + const message = event.data.message; + if (message.type === "StoreReady") { + console.info( + "[TTV LOL PRO] πŸ“¦ Received store state from content script." + ); + options.state = message.state; + shouldWaitForStore = false; + } + } + }); + } + return async function fetch( input: RequestInfo | URL, init?: RequestInit @@ -70,7 +93,28 @@ export function getFetch(options: FetchOptions): typeof fetch { flagRequest(headersMap); } // PlaybackAccessToken requests. - if (requestBody != null && requestBody.includes("PlaybackAccessToken")) { + if ( + requestBody != null && + requestBody.includes("PlaybackAccessToken_Template") + ) { + console.debug( + "[TTV LOL PRO] πŸ₯… Caught GraphQL PlaybackAccessToken_Template request. Flagging…" + ); + while (shouldWaitForStore) await sleep(100); + if (options.state?.anonymousMode) { + console.debug("[TTV LOL PRO] ❓ Acting as anonymous user"); + setHeaderToMap(headersMap, "Authorization", "undefined"); + removeHeaderFromMap(headersMap, "Client-Session-Id"); + removeHeaderFromMap(headersMap, "Client-Version"); + setHeaderToMap(headersMap, "Device-ID", generateRandomString(32)); + removeHeaderFromMap(headersMap, "Sec-GPC"); + removeHeaderFromMap(headersMap, "X-Device-Id"); + } + flagRequest(headersMap); + } else if ( + requestBody != null && + requestBody.includes("PlaybackAccessToken") + ) { console.debug( "[TTV LOL PRO] πŸ₯… Caught GraphQL PlaybackAccessToken request. Flagging…" ); @@ -290,3 +334,7 @@ function flagRequest(headersMap: Map) { function cancelRequest(): never { throw new Error(); } + +async function sleep(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); +} diff --git a/src/page/page.ts b/src/page/page.ts index cefaffd2..e2e465de 100644 --- a/src/page/page.ts +++ b/src/page/page.ts @@ -1,10 +1,11 @@ -import { getFetch } from "./getFetch"; +import { FetchOptions, getFetch } from "./getFetch"; console.info("[TTV LOL PRO] πŸš€ Page script running."); const params = JSON.parse(document.currentScript!.dataset.params!); +const fetchOptions: FetchOptions = { scope: "page" }; -window.fetch = getFetch({ scope: "page" }); +window.fetch = getFetch(fetchOptions); window.Worker = class Worker extends window.Worker { constructor(scriptURL: string | URL, options?: WorkerOptions) { @@ -41,10 +42,18 @@ window.Worker = class Worker extends window.Worker { ); super(newScriptURL, options); this.addEventListener("message", event => { - if (event.data?.type === "ContentScriptMessage") { + if ( + event.data?.type === "ContentScriptMessage" || + event.data?.type === "PageScriptMessage" + ) { window.postMessage(event.data.message); } }); + window.addEventListener("message", event => { + if (event.data?.type === "WorkerScriptMessage") { + this.postMessage(event.data.message); + } + }); } }; diff --git a/src/store/getDefaultState.ts b/src/store/getDefaultState.ts index 9b22532d..8ce82b18 100644 --- a/src/store/getDefaultState.ts +++ b/src/store/getDefaultState.ts @@ -6,6 +6,7 @@ export default function getDefaultState() { adLog: [], adLogEnabled: true, adLogLastSent: 0, + anonymousMode: false, dnsResponses: [], normalProxies: ["chrome.api.cdn-perfprod.com:4023"], openedTwitchTabs: [], diff --git a/src/store/types.ts b/src/store/types.ts index 8062c83f..1ca2f8b2 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -8,6 +8,7 @@ export interface State { adLog: AdLogEntry[]; adLogEnabled: boolean; adLogLastSent: number; + anonymousMode: boolean; dnsResponses: DnsResponse[]; normalProxies: string[]; openedTwitchTabs: number[]; From 3739743faf9e93ebcd0571dd00f80794bc1da335 Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 10 Sep 2023 19:54:59 +0200 Subject: [PATCH 02/42] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20dependenci?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 523 +++++++++++++++++++++++++++++----------------- package.json | 8 +- 2 files changed, 339 insertions(+), 192 deletions(-) diff --git a/package-lock.json b/package-lock.json index 40a42594..ab582387 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,50 +14,113 @@ }, "devDependencies": { "@parcel/config-webextension": "^2.9.3", - "@types/chrome": "^0.0.243", + "@types/chrome": "^0.0.245", "@types/ip": "^1.1.0", - "@types/webextension-polyfill": "^0.10.1", + "@types/webextension-polyfill": "^0.10.2", "buffer": "^6.0.3", "os-browserify": "^0.3.0", "parcel": "^2.9.3", - "postcss": "^8.4.27", + "postcss": "^8.4.29", "prettier": "2.8.8", "prettier-plugin-css-order": "^1.3.1", "prettier-plugin-organize-imports": "^3.2.3", "shx": "^0.3.4", - "typescript": "^5.1.6", + "typescript": "^5.2.2", "webextension-polyfill": "^0.10.0" } }, "node_modules/@babel/code-frame": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", - "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "dev": true, "dependencies": { - "@babel/highlight": "^7.22.5" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.15.tgz", + "integrity": "sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", - "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.13.tgz", + "integrity": "sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==", "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.22.5", - "chalk": "^2.0.0", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -1579,9 +1642,9 @@ } }, "node_modules/@parcel/watcher": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.2.0.tgz", - "integrity": "sha512-71S4TF+IMyAn24PK4KSkdKtqJDR3zRzb0HE3yXpacItqTM7XfF2f5q9NEGLEVl0dAaBAGfNwDCjH120y25F6Tg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.3.0.tgz", + "integrity": "sha512-pW7QaFiL11O0BphO+bq3MgqeX/INAk9jgBldVDYjlQPO4VddoZnF22TcF9onMhnLVHuNqBJeRf+Fj7eezi/+rQ==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -1598,22 +1661,24 @@ "url": "https://opencollective.com/parcel" }, "optionalDependencies": { - "@parcel/watcher-android-arm64": "2.2.0", - "@parcel/watcher-darwin-arm64": "2.2.0", - "@parcel/watcher-darwin-x64": "2.2.0", - "@parcel/watcher-linux-arm-glibc": "2.2.0", - "@parcel/watcher-linux-arm64-glibc": "2.2.0", - "@parcel/watcher-linux-arm64-musl": "2.2.0", - "@parcel/watcher-linux-x64-glibc": "2.2.0", - "@parcel/watcher-linux-x64-musl": "2.2.0", - "@parcel/watcher-win32-arm64": "2.2.0", - "@parcel/watcher-win32-x64": "2.2.0" + "@parcel/watcher-android-arm64": "2.3.0", + "@parcel/watcher-darwin-arm64": "2.3.0", + "@parcel/watcher-darwin-x64": "2.3.0", + "@parcel/watcher-freebsd-x64": "2.3.0", + "@parcel/watcher-linux-arm-glibc": "2.3.0", + "@parcel/watcher-linux-arm64-glibc": "2.3.0", + "@parcel/watcher-linux-arm64-musl": "2.3.0", + "@parcel/watcher-linux-x64-glibc": "2.3.0", + "@parcel/watcher-linux-x64-musl": "2.3.0", + "@parcel/watcher-win32-arm64": "2.3.0", + "@parcel/watcher-win32-ia32": "2.3.0", + "@parcel/watcher-win32-x64": "2.3.0" } }, "node_modules/@parcel/watcher-android-arm64": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.2.0.tgz", - "integrity": "sha512-nU2wh00CTQT9rr1TIKTjdQ9lAGYpmz6XuKw0nAwAN+S2A5YiD55BK1u+E5WMCT8YOIDe/n6gaj4o/Bi9294SSQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.3.0.tgz", + "integrity": "sha512-f4o9eA3dgk0XRT3XhB0UWpWpLnKgrh1IwNJKJ7UJek7eTYccQ8LR7XUWFKqw6aEq5KUNlCcGvSzKqSX/vtWVVA==", "cpu": [ "arm64" ], @@ -1631,9 +1696,9 @@ } }, "node_modules/@parcel/watcher-darwin-arm64": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.2.0.tgz", - "integrity": "sha512-cJl0UZDcodciy3TDMomoK/Huxpjlkkim3SyMgWzjovHGOZKNce9guLz2dzuFwfObBFCjfznbFMIvAZ5syXotYw==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.3.0.tgz", + "integrity": "sha512-mKY+oijI4ahBMc/GygVGvEdOq0L4DxhYgwQqYAz/7yPzuGi79oXrZG52WdpGA1wLBPrYb0T8uBaGFo7I6rvSKw==", "cpu": [ "arm64" ], @@ -1651,9 +1716,9 @@ } }, "node_modules/@parcel/watcher-darwin-x64": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.2.0.tgz", - "integrity": "sha512-QI77zxaGrCV1StKcoRYfsUfmUmvPMPfQrubkBBy5XujV2fwaLgZivQOTQMBgp5K2+E19u1ufpspKXAPqSzpbyg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.3.0.tgz", + "integrity": "sha512-20oBj8LcEOnLE3mgpy6zuOq8AplPu9NcSSSfyVKgfOhNAc4eF4ob3ldj0xWjGGbOF7Dcy1Tvm6ytvgdjlfUeow==", "cpu": [ "x64" ], @@ -1670,10 +1735,30 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.3.0.tgz", + "integrity": "sha512-7LftKlaHunueAEiojhCn+Ef2CTXWsLgTl4hq0pkhkTBFI3ssj2bJXmH2L67mKpiAD5dz66JYk4zS66qzdnIOgw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, "node_modules/@parcel/watcher-linux-arm-glibc": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.2.0.tgz", - "integrity": "sha512-I2GPBcAXazPzabCmfsa3HRRW+MGlqxYd8g8RIueJU+a4o5nyNZDz0CR1cu0INT0QSQXEZV7w6UE8Hz9CF8u3Pg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.3.0.tgz", + "integrity": "sha512-1apPw5cD2xBv1XIHPUlq0cO6iAaEUQ3BcY0ysSyD9Kuyw4MoWm1DV+W9mneWI+1g6OeP6dhikiFE6BlU+AToTQ==", "cpu": [ "arm" ], @@ -1691,9 +1776,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-glibc": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.2.0.tgz", - "integrity": "sha512-St5mlfp+2lS9AmgixUqfwJa/DwVmTCJxC1HcOubUTz6YFOKIlkHCeUa1Bxi4E/tR/HSez8+heXHL8HQkJ4Bd8g==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.3.0.tgz", + "integrity": "sha512-mQ0gBSQEiq1k/MMkgcSB0Ic47UORZBmWoAWlMrTW6nbAGoLZP+h7AtUM7H3oDu34TBFFvjy4JCGP43JlylkTQA==", "cpu": [ "arm64" ], @@ -1711,9 +1796,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-musl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.2.0.tgz", - "integrity": "sha512-jS+qfhhoOBVWwMLP65MaG8xdInMK30pPW8wqTCg2AAuVJh5xepMbzkhHJ4zURqHiyY3EiIRuYu4ONJKCxt8iqA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.3.0.tgz", + "integrity": "sha512-LXZAExpepJew0Gp8ZkJ+xDZaTQjLHv48h0p0Vw2VMFQ8A+RKrAvpFuPVCVwKJCr5SE+zvaG+Etg56qXvTDIedw==", "cpu": [ "arm64" ], @@ -1731,9 +1816,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-glibc": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.2.0.tgz", - "integrity": "sha512-xJvJ7R2wJdi47WZBFS691RDOWvP1j/IAs3EXaWVhDI8FFITbWrWaln7KoNcR0Y3T+ZwimFY/cfb0PNht1q895g==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.3.0.tgz", + "integrity": "sha512-P7Wo91lKSeSgMTtG7CnBS6WrA5otr1K7shhSjKHNePVmfBHDoAOHYRXgUmhiNfbcGk0uMCHVcdbfxtuiZCHVow==", "cpu": [ "x64" ], @@ -1751,9 +1836,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-musl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.2.0.tgz", - "integrity": "sha512-D+NMpgr23a+RI5mu8ZPKWy7AqjBOkURFDgP5iIXXEf/K3hm0jJ3ogzi0Ed2237B/CdYREimCgXyeiAlE/FtwyA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.3.0.tgz", + "integrity": "sha512-+kiRE1JIq8QdxzwoYY+wzBs9YbJ34guBweTK8nlzLKimn5EQ2b2FSC+tAOpq302BuIMjyuUGvBiUhEcLIGMQ5g==", "cpu": [ "x64" ], @@ -1771,9 +1856,9 @@ } }, "node_modules/@parcel/watcher-win32-arm64": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.2.0.tgz", - "integrity": "sha512-z225cPn3aygJsyVUOWwfyW+fY0Tvk7N3XCOl66qUPFxpbuXeZuiuuJemmtm8vxyqa3Ur7peU/qJxrpC64aeI7Q==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.3.0.tgz", + "integrity": "sha512-35gXCnaz1AqIXpG42evcoP2+sNL62gZTMZne3IackM+6QlfMcJLy3DrjuL6Iks7Czpd3j4xRBzez3ADCj1l7Aw==", "cpu": [ "arm64" ], @@ -1790,10 +1875,30 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.3.0.tgz", + "integrity": "sha512-FJS/IBQHhRpZ6PiCjFt1UAcPr0YmCLHRbTc00IBTrelEjlmmgIVLeOx4MSXzx2HFEy5Jo5YdhGpxCuqCyDJ5ow==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, "node_modules/@parcel/watcher-win32-x64": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.2.0.tgz", - "integrity": "sha512-JqGW0RJ61BkKx+yYzIURt9s53P7xMVbv0uxYPzAXLBINGaFmkIKSuUPyBVfy8TMbvp93lvF4SPBNDzVRJfvgOw==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.3.0.tgz", + "integrity": "sha512-dLx+0XRdMnVI62kU3wbXvbIRhLck4aE28bIGKbRGS7BJNt54IIj9+c/Dkqb+7DJEbHUZAX1bwaoM8PqVlHJmCA==", "cpu": [ "x64" ], @@ -1835,11 +1940,14 @@ } }, "node_modules/@swc/core": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.74.tgz", - "integrity": "sha512-P+MIExOTdWlfq8Heb1/NhBAke6UTckd4cRDuJoFcFMGBRvgoCMNWhnfP3FRRXPLI7GGg27dRZS+xHiqYyQmSrA==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.83.tgz", + "integrity": "sha512-PccHDgGQlFjpExgJxH91qA3a4aifR+axCFJ4RieCoiI0m5gURE4nBhxzTBY5YU/YKTBmPO8Gc5Q6inE3+NquWg==", "dev": true, "hasInstallScript": true, + "dependencies": { + "@swc/types": "^0.1.4" + }, "engines": { "node": ">=10" }, @@ -1848,16 +1956,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.74", - "@swc/core-darwin-x64": "1.3.74", - "@swc/core-linux-arm-gnueabihf": "1.3.74", - "@swc/core-linux-arm64-gnu": "1.3.74", - "@swc/core-linux-arm64-musl": "1.3.74", - "@swc/core-linux-x64-gnu": "1.3.74", - "@swc/core-linux-x64-musl": "1.3.74", - "@swc/core-win32-arm64-msvc": "1.3.74", - "@swc/core-win32-ia32-msvc": "1.3.74", - "@swc/core-win32-x64-msvc": "1.3.74" + "@swc/core-darwin-arm64": "1.3.83", + "@swc/core-darwin-x64": "1.3.83", + "@swc/core-linux-arm-gnueabihf": "1.3.83", + "@swc/core-linux-arm64-gnu": "1.3.83", + "@swc/core-linux-arm64-musl": "1.3.83", + "@swc/core-linux-x64-gnu": "1.3.83", + "@swc/core-linux-x64-musl": "1.3.83", + "@swc/core-win32-arm64-msvc": "1.3.83", + "@swc/core-win32-ia32-msvc": "1.3.83", + "@swc/core-win32-x64-msvc": "1.3.83" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -1869,9 +1977,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.74.tgz", - "integrity": "sha512-2rMV4QxM583jXcREfo0MhV3Oj5pgRSfSh/kVrB1twL2rQxOrbzkAPT/8flmygdVoL4f2F7o1EY5lKlYxEBiIKQ==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.83.tgz", + "integrity": "sha512-Plz2IKeveVLivbXTSCC3OZjD2MojyKYllhPrn9RotkDIZEFRYJZtW5/Ik1tJW/2rzu5HVKuGYrDKdScVVTbOxQ==", "cpu": [ "arm64" ], @@ -1885,9 +1993,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.74.tgz", - "integrity": "sha512-KKEGE1wXneYXe15fWDRM8/oekd/Q4yAuccA0vWY/7i6nOSPqWYcSDR0nRtR030ltDxWt0rk/eCTmNkrOWrKs3A==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.83.tgz", + "integrity": "sha512-FBGVg5IPF/8jQ6FbK60iDUHjv0H5+LwfpJHKH6wZnRaYWFtm7+pzYgreLu3NTsm3m7/1a7t0+7KURwBGUaJCCw==", "cpu": [ "x64" ], @@ -1901,9 +2009,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.74.tgz", - "integrity": "sha512-HehH5DR6r/5fIVu7tu8ZqgrHkhSCQNewf1ztFQJgcmaQWn+H4AJERBjwkjosqh4TvUJucZv8vyRTvrFeBXaCSA==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.83.tgz", + "integrity": "sha512-EZcsuRYhGkzofXtzwDjuuBC/suiX9s7zeg2YYXOVjWwyebb6BUhB1yad3mcykFQ20rTLO9JUyIaiaMYDHGobqw==", "cpu": [ "arm" ], @@ -1917,9 +2025,9 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.74.tgz", - "integrity": "sha512-+xkbCRz/wczgdknoV4NwYxbRI2dD7x/qkIFcVM2buzLCq8oWLweuV8+aL4pRqu0qDh7ZSb1jcaVTUIsySCJznA==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.83.tgz", + "integrity": "sha512-khI41szLHrCD/cFOcN4p2SYvZgHjhhHlcMHz5BksRrDyteSJKu0qtWRZITVom0N/9jWoAleoFhMnFTUs0H8IWA==", "cpu": [ "arm64" ], @@ -1933,9 +2041,9 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.74.tgz", - "integrity": "sha512-maKFZSCD3tQznzPV7T3V+TtiWZFEFM8YrnSS5fQNNb+K9J65sL+170uTb3M7H4cFkG+9Sm5k5yCrCIutlvV48g==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.83.tgz", + "integrity": "sha512-zgT7yNOdbjHcGAwvys79mbfNLK65KBlPJWzeig+Yk7I8TVzmaQge7B6ZS/gwF9/p+8TiLYo/tZ5aF2lqlgdSVw==", "cpu": [ "arm64" ], @@ -1949,9 +2057,9 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.74.tgz", - "integrity": "sha512-LEXpcShF6DLTWJSiBhMSYZkLQ27UvaQ24fCFhoIV/R3dhYaUpHmIyLPPBNC82T03lB3ONUFVwrRw6fxDJ/f00A==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.83.tgz", + "integrity": "sha512-x+mH0Y3NC/G0YNlFmGi3vGD4VOm7IPDhh+tGrx6WtJp0BsShAbOpxtfU885rp1QweZe4qYoEmGqiEjE2WrPIdA==", "cpu": [ "x64" ], @@ -1965,9 +2073,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.74.tgz", - "integrity": "sha512-sxsFctbFMZEFmDE7CmYljG0dMumH8XBTwwtGr8s6z0fYAzXBGNq2AFPcmEh2np9rPWkt7pE1m0ByESD+dMkbxQ==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.83.tgz", + "integrity": "sha512-s5AYhAOmetUwUZwS5g9qb92IYgNHHBGiY2mTLImtEgpAeBwe0LPDj6WrujxCBuZnaS55mKRLLOuiMZE5TpjBNA==", "cpu": [ "x64" ], @@ -1981,9 +2089,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.74.tgz", - "integrity": "sha512-F7hY9/BjFCozA4YPFYFH5FGCyWwa44vIXHqG66F5cDwXDGFn8ZtBsYIsiPfUYcx0AeAo1ojnVWKPxokZhYNYqA==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.83.tgz", + "integrity": "sha512-yw2rd/KVOGs95lRRB+killLWNaO1dy4uVa8Q3/4wb5txlLru07W1m041fZLzwOg/1Sh0TMjJgGxj0XHGR3ZXhQ==", "cpu": [ "arm64" ], @@ -1997,9 +2105,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.74.tgz", - "integrity": "sha512-qBAsiD1AlIdqED6wy3UNRHyAys9pWMUidX0LJ6mj24r/vfrzzTBAUrLJe5m7bzE+F1Rgi001avYJeEW1DLEJ+Q==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.83.tgz", + "integrity": "sha512-POW+rgZ6KWqBpwPGIRd2/3pcf46P+UrKBm4HLt5IwbHvekJ4avIM8ixJa9kK0muJNVJcDpaZgxaU1ELxtJ1j8w==", "cpu": [ "ia32" ], @@ -2013,9 +2121,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.3.74", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.74.tgz", - "integrity": "sha512-S3YAvvLprTnPRwQuy9Dkwubb5SRLpVK3JJsqYDbGfgj8PGQyKHZcVJ5X3nfFsoWLy3j9B/3Os2nawprRSzeC5A==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.83.tgz", + "integrity": "sha512-CiWQtkFnZElXQUalaHp+Wacw0Jd+24ncRYhqaJ9YKnEQP1H82CxIIuQqLM8IFaLpn5dpY6SgzaeubWF46hjcLA==", "cpu": [ "x64" ], @@ -2029,14 +2137,20 @@ } }, "node_modules/@swc/helpers": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz", - "integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", + "integrity": "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==", "dev": true, "dependencies": { "tslib": "^2.4.0" } }, + "node_modules/@swc/types": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.4.tgz", + "integrity": "sha512-z/G02d+59gyyUb7KYhKi9jOhicek6QD2oMaotUyG+lUkybpXoV49dY9bj7Ah5Q+y7knK2jU67UTX9FyfGzaxQg==", + "dev": true + }, "node_modules/@trysound/sax": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", @@ -2047,9 +2161,9 @@ } }, "node_modules/@types/chrome": { - "version": "0.0.243", - "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.243.tgz", - "integrity": "sha512-4PHv0kxxxpZFHWPBiJJ9TWH8kbx0567j1b2djnhpJjpiSGNI7UKkz7dSEECBtQ0B3N5nQTMwSB/5IopkWGAbEA==", + "version": "0.0.245", + "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.245.tgz", + "integrity": "sha512-bBdONkLO8wMbJK6iG0Q8ShFuh67Grnod+5OpClJaa8MuKJXP/Kjl3f8wRYeMOnQ0Q8HDgpUlopu8bvl9siR8/A==", "dev": true, "dependencies": { "@types/filesystem": "*", @@ -2072,9 +2186,9 @@ "dev": true }, "node_modules/@types/har-format": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.11.tgz", - "integrity": "sha512-T232/TneofqK30AD1LRrrf8KnjLvzrjWDp7eWST5KoiSzrBfRsLrWDPk4STQPW4NZG6v2MltnduBVmakbZOBIQ==", + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.12.tgz", + "integrity": "sha512-P20p/YBrqUBmzD6KhIQ8EiY4/RRzlekL4eCvfQnulFPfjmiGxKIoyCeI7qam5I7oKH3P8EU4ptEi0EfyGoLysw==", "dev": true }, "node_modules/@types/ip": { @@ -2087,15 +2201,15 @@ } }, "node_modules/@types/node": { - "version": "20.4.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.6.tgz", - "integrity": "sha512-q0RkvNgMweWWIvSMDiXhflGUKMdIxBo2M2tYM/0kEGDueQByFzK4KZAgu5YHGFNxziTlppNpTIBcqHQAxlfHdA==", + "version": "20.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", + "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==", "dev": true }, "node_modules/@types/webextension-polyfill": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.1.tgz", - "integrity": "sha512-Sdg+E2F5JUbhkE1qX15QUxpyhfMFKRGJqND9nb1C0gNN4NR7kCV31/1GvNbg6Xe+m/JElJ9/lG5kepMzjGPuQw==", + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.2.tgz", + "integrity": "sha512-L+T72DVTi/1azY6gw7PRmL49kvobLKQQWfOmHDBRSCkAvaCV4wk222J3ZODYA9Gf/UqUvtItu8FPJgWX5ktO9g==", "dev": true }, "node_modules/abortcontroller-polyfill": { @@ -2259,9 +2373,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001519", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001519.tgz", - "integrity": "sha512-0QHgqR+Jv4bxHMp8kZ1Kn8CH55OikjKJ6JmKkZYP1F3D7w+lnFXF70nG5eNfsZS89jadi5Ywy5UCSKLAglIRkg==", + "version": "1.0.30001532", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001532.tgz", + "integrity": "sha512-FbDFnNat3nMnrROzqrsg314zhqN5LGQ1kyyMk2opcrwGbVGpHRhgCWtAgD5YJUqNAiQ+dklreil/c3Qf1dfCTw==", "dev": true, "funding": [ { @@ -2355,14 +2469,14 @@ } }, "node_modules/cosmiconfig": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.2.0.tgz", - "integrity": "sha512-3rTMnFJA1tCOPwRxtgF4wd7Ab2qvDbL8jX+3smjIbS4HlZBagTlpERbdN7iAbWlrfxE3M8c27kTwTawQ7st+OQ==", + "version": "8.3.5", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.5.tgz", + "integrity": "sha512-A5Xry3xfS96wy2qbiLkQLAg4JUrR2wvfybxj6yqLmrUfMAvhS3MZxIP2oQn0grgYIvJqzpeTEWu4vK0t+12NNw==", "dev": true, "dependencies": { - "import-fresh": "^3.2.1", + "import-fresh": "^3.3.0", "js-yaml": "^4.1.0", - "parse-json": "^5.0.0", + "parse-json": "^5.2.0", "path-type": "^4.0.0" }, "engines": { @@ -2370,6 +2484,14 @@ }, "funding": { "url": "https://github.com/sponsors/d-fischer" + }, + "peerDependencies": { + "typescript": ">=4.9.5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/css-declaration-sorter": { @@ -2623,9 +2745,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.482", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.482.tgz", - "integrity": "sha512-h+UqpfmEr1Qkk0zp7ej/jid7CXoq4m4QzW6wNTb0ELJ/BZCpA4wgUylBIMGCe621tnr4l5VmoHjdoSx2lbnNJA==", + "version": "1.4.513", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.513.tgz", + "integrity": "sha512-cOB0xcInjm+E5qIssHeXJ29BaUyWpMyFKT5RB3bsLENDheCja0wMkHJyiPl0NBE/VzDI7JDuNEQWhe6RitEUcw==", "dev": true }, "node_modules/entities": { @@ -2721,9 +2843,9 @@ } }, "node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", + "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -2895,9 +3017,9 @@ "dev": true }, "node_modules/is-core-module": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", - "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", + "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", "dev": true, "dependencies": { "has": "^1.0.3" @@ -2979,9 +3101,9 @@ } }, "node_modules/lightningcss": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.21.5.tgz", - "integrity": "sha512-/pEUPeih2EwIx9n4T82aOG6CInN83tl/mWlw6B5gWLf36UplQi1L+5p3FUHsdt4fXVfOkkh9KIaM3owoq7ss8A==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.21.7.tgz", + "integrity": "sha512-xITZyh5sLFwRPYUSw15T00Rm7gcQ1qOPuQwNOcvHsTm6nLWTQ723w7zl42wrC5t+xtdg6FPmnXHml1nZxxvp1w==", "dev": true, "dependencies": { "detect-libc": "^1.0.3" @@ -2994,20 +3116,21 @@ "url": "https://opencollective.com/parcel" }, "optionalDependencies": { - "lightningcss-darwin-arm64": "1.21.5", - "lightningcss-darwin-x64": "1.21.5", - "lightningcss-linux-arm-gnueabihf": "1.21.5", - "lightningcss-linux-arm64-gnu": "1.21.5", - "lightningcss-linux-arm64-musl": "1.21.5", - "lightningcss-linux-x64-gnu": "1.21.5", - "lightningcss-linux-x64-musl": "1.21.5", - "lightningcss-win32-x64-msvc": "1.21.5" + "lightningcss-darwin-arm64": "1.21.7", + "lightningcss-darwin-x64": "1.21.7", + "lightningcss-freebsd-x64": "1.21.7", + "lightningcss-linux-arm-gnueabihf": "1.21.7", + "lightningcss-linux-arm64-gnu": "1.21.7", + "lightningcss-linux-arm64-musl": "1.21.7", + "lightningcss-linux-x64-gnu": "1.21.7", + "lightningcss-linux-x64-musl": "1.21.7", + "lightningcss-win32-x64-msvc": "1.21.7" } }, "node_modules/lightningcss-darwin-arm64": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.21.5.tgz", - "integrity": "sha512-z05hyLX85WY0UfhkFUOrWEFqD69lpVAmgl3aDzMKlIZJGygbhbegqb4PV8qfUrKKNBauut/qVNPKZglhTaDDxA==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.21.7.tgz", + "integrity": "sha512-tt7hIsFio9jZofTVHtCACz6rB6c9RyABMXfA9A/VcKOjS3sq+koX/QkRJWY06utwOImbJIXBC5hbg9t3RkPUAQ==", "cpu": [ "arm64" ], @@ -3025,9 +3148,9 @@ } }, "node_modules/lightningcss-darwin-x64": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.21.5.tgz", - "integrity": "sha512-MSJhmej/U9MrdPxDk7+FWhO8+UqVoZUHG4VvKT5RQ4RJtqtANTiWiI97LvoVNMtdMnHaKs1Pkji6wHUFxjJsHQ==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.21.7.tgz", + "integrity": "sha512-F4gS4bf7eWekfPT+TxJNm/pF+QRgZiTrTkQH6cw4/UWfdeZISfuhD5El2dm16giFnY0K5ylIwO+ZusgYNkGSXA==", "cpu": [ "x64" ], @@ -3044,10 +3167,30 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.21.7.tgz", + "integrity": "sha512-RMfNzJWXCSfPnL55fcLWEAadcY6QUFT0S8NceNKYzp1KiCZtkJIy6RQ5SaVxPzRqd3iMsahUf5sfnG8N1UQSNQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, "node_modules/lightningcss-linux-arm-gnueabihf": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.21.5.tgz", - "integrity": "sha512-xN6+5/JsMrbZHL1lPl+MiNJ3Xza12ueBKPepiyDCFQzlhFRTj7D0LG+cfNTzPBTO8KcYQynLpl1iBB8LGp3Xtw==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.21.7.tgz", + "integrity": "sha512-biSRUDZNx7vubWP1jArw/qqfZKPGpkV/qzunasZzxmqijbZ43sW9faDQYxWNcxPWljJJdF/qs6qcurYFovWtrQ==", "cpu": [ "arm" ], @@ -3065,9 +3208,9 @@ } }, "node_modules/lightningcss-linux-arm64-gnu": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.21.5.tgz", - "integrity": "sha512-KfzFNhC4XTbmG3ma/xcTs/IhCwieW89XALIusKmnV0N618ZDXEB0XjWOYQRCXeK9mfqPdbTBpurEHV/XZtkniQ==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.21.7.tgz", + "integrity": "sha512-PENY8QekqL9TG3AY/A7rkUBb5ymefGxea7Oe7+x7Hbw4Bz4Hpj5cec5OoMypMqFbURPmpi0fTWx4vSWUPzpDcA==", "cpu": [ "arm64" ], @@ -3085,9 +3228,9 @@ } }, "node_modules/lightningcss-linux-arm64-musl": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.21.5.tgz", - "integrity": "sha512-bc0GytQO5Mn9QM6szaZ+31fQHNdidgpM1sSCwzPItz8hg3wOvKl8039rU0veMJV3ZgC9z0ypNRceLrSHeRHmXw==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.21.7.tgz", + "integrity": "sha512-pfOipKvA/0X1OjRaZt3870vnV9UGBSjayIqHh0fGx/+aRz3O0MVFHE/60P2UWXpM3YGJEw/hMWtNkrFwqOge8A==", "cpu": [ "arm64" ], @@ -3105,9 +3248,9 @@ } }, "node_modules/lightningcss-linux-x64-gnu": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.21.5.tgz", - "integrity": "sha512-JwMbgypPQgc2kW2av3OwzZ8cbrEuIiDiXPJdXRE6aVxu67yHauJawQLqJKTGUhiAhy6iLDG8Wg0a3/ziL+m+Kw==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.21.7.tgz", + "integrity": "sha512-dgcsis4TAA7s0ia4f31QHX+G4PWPwxk+wJaEQLaV0NdJs09O5hHoA8DpLEr8nrvc/tsRTyVNBP1rDtgzySjpXg==", "cpu": [ "x64" ], @@ -3125,9 +3268,9 @@ } }, "node_modules/lightningcss-linux-x64-musl": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.21.5.tgz", - "integrity": "sha512-Ib8b6IQ/OR/VrPU6YBgy4T3QnuHY7DUa95O+nz+cwrTkMSN6fuHcTcIaz4t8TJ6HI5pl3uxUOZjmtls2pyQWow==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.21.7.tgz", + "integrity": "sha512-A+9dXpxld3p4Cd6fxev2eqEvaauYtrgNpXV3t7ioCJy30Oj9nYiNGwiGusM+4MJVcEpUPGUGiuAqY4sWilRDwA==", "cpu": [ "x64" ], @@ -3145,9 +3288,9 @@ } }, "node_modules/lightningcss-win32-x64-msvc": { - "version": "1.21.5", - "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.21.5.tgz", - "integrity": "sha512-A8cSi8lUpBeVmoF+DqqW7cd0FemDbCuKr490IXdjyeI+KL8adpSKUs8tcqO0OXPh1EoDqK7JNkD/dELmd4Iz5g==", + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.21.7.tgz", + "integrity": "sha512-07/8vogEq+C/mF99pdMhh/f19/xreq8N9Ca6AWeVHZIdODyF/pt6KdKSCWDZWIn+3CUxI8gCJWuUWyOc3xymvw==", "cpu": [ "x64" ], @@ -3265,9 +3408,9 @@ } }, "node_modules/msgpackr": { - "version": "1.9.6", - "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.9.6.tgz", - "integrity": "sha512-50rmb6+ZWvEm0vJn8R8CwI1Eavss3h5rgtKrcdUal3EkZcpqw82+xsmc7RoHb8fYB5V4EOU2NDaOitDAdO0t+w==", + "version": "1.9.9", + "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.9.9.tgz", + "integrity": "sha512-sbn6mioS2w0lq1O6PpGtsv6Gy8roWM+o3o4Sqjd6DudrL/nOugY+KyJUimoWzHnf9OkO0T6broHFnYE/R05t9A==", "dev": true, "optionalDependencies": { "msgpackr-extract": "^3.0.2" @@ -3492,9 +3635,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", - "integrity": "sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==", + "version": "8.4.29", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", + "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", "dev": true, "funding": [ { @@ -3532,9 +3675,9 @@ } }, "node_modules/postcss-scss": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/postcss-scss/-/postcss-scss-4.0.6.tgz", - "integrity": "sha512-rLDPhJY4z/i4nVFZ27j9GqLxj1pwxE80eAzUNRMXtcpipFYIeowerzBgG3yJhMtObGEXidtIgbUpQ3eLDsf5OQ==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/postcss-scss/-/postcss-scss-4.0.8.tgz", + "integrity": "sha512-Cr0X8Eu7xMhE96PJck6ses/uVVXDtE5ghUTKNUYgm8ozgP2TkgV3LWs3WgLV1xaSSLq8ZFiXaUrj0LVgG1fGEA==", "dev": true, "funding": [ { @@ -3544,13 +3687,17 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/postcss-scss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "engines": { "node": ">=12.0" }, "peerDependencies": { - "postcss": "^8.4.19" + "postcss": "^8.4.29" } }, "node_modules/postcss-value-parser": { @@ -3695,12 +3842,12 @@ "dev": true }, "node_modules/resolve": { - "version": "1.22.2", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", - "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", + "version": "1.22.4", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", + "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", "dev": true, "dependencies": { - "is-core-module": "^2.11.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -3912,9 +4059,9 @@ } }, "node_modules/tslib": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz", - "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", "dev": true }, "node_modules/type-fest": { @@ -3930,9 +4077,9 @@ } }, "node_modules/typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 9f8380b5..c66df2e0 100644 --- a/package.json +++ b/package.json @@ -46,18 +46,18 @@ }, "devDependencies": { "@parcel/config-webextension": "^2.9.3", - "@types/chrome": "^0.0.243", + "@types/chrome": "^0.0.245", "@types/ip": "^1.1.0", - "@types/webextension-polyfill": "^0.10.1", + "@types/webextension-polyfill": "^0.10.2", "buffer": "^6.0.3", "os-browserify": "^0.3.0", "parcel": "^2.9.3", - "postcss": "^8.4.27", + "postcss": "^8.4.29", "prettier": "2.8.8", "prettier-plugin-css-order": "^1.3.1", "prettier-plugin-organize-imports": "^3.2.3", "shx": "^0.3.4", - "typescript": "^5.1.6", + "typescript": "^5.2.2", "webextension-polyfill": "^0.10.0" }, "private": true From e593f9a32e0f80ebbe85edbba4d8ce177d31e4d3 Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 10 Sep 2023 19:55:39 +0200 Subject: [PATCH 03/42] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Bump=20version=20num?= =?UTF-8?q?ber=20to=202.2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 ++-- package.json | 2 +- src/manifest.chromium.json | 2 +- src/manifest.firefox.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab582387..9ce0c56b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ttv-lol-pro", - "version": "2.1.6", + "version": "2.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ttv-lol-pro", - "version": "2.1.6", + "version": "2.2.0", "license": "GPL-3.0", "dependencies": { "bowser": "^2.11.0", diff --git a/package.json b/package.json index c66df2e0..de62bfa8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ttv-lol-pro", - "version": "2.1.6", + "version": "2.2.0", "description": "TTV LOL PRO removes most livestream ads from Twitch.", "@parcel/bundler-default": { "minBundles": 10000000, diff --git a/src/manifest.chromium.json b/src/manifest.chromium.json index 365e8aa5..7b0d9d7d 100644 --- a/src/manifest.chromium.json +++ b/src/manifest.chromium.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "TTV LOL PRO", "description": "TTV LOL PRO removes most livestream ads from Twitch.", - "version": "2.1.6", + "version": "2.2.0", "background": { "service_worker": "background/background.ts", "type": "module" diff --git a/src/manifest.firefox.json b/src/manifest.firefox.json index 556b21a5..5ecd3e30 100644 --- a/src/manifest.firefox.json +++ b/src/manifest.firefox.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "TTV LOL PRO", "description": "TTV LOL PRO removes most livestream ads from Twitch.", - "version": "2.1.6", + "version": "2.2.0", "background": { "scripts": ["background/background.ts"], "persistent": false From 3d38244498a8c5095770f5be72964e7d03621fbc Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 10 Sep 2023 20:10:47 +0200 Subject: [PATCH 04/42] =?UTF-8?q?=F0=9F=8E=A8=20Little=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/getFetch.ts | 29 +++++++++++++++-------------- src/page/page.ts | 5 ++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/page/getFetch.ts b/src/page/getFetch.ts index a24b9f9f..e85b142d 100644 --- a/src/page/getFetch.ts +++ b/src/page/getFetch.ts @@ -29,20 +29,21 @@ export function getFetch(options: FetchOptions): typeof fetch { shouldWaitForStore = false; }, 3000); - if (options.scope === "page") { - window.addEventListener("message", event => { - if (event.data?.type === "PageScriptMessage") { - const message = event.data.message; - if (message.type === "StoreReady") { - console.info( - "[TTV LOL PRO] πŸ“¦ Received store state from content script." - ); - options.state = message.state; - shouldWaitForStore = false; - } + self.addEventListener("message", event => { + if ( + (event.data?.type === "PageScriptMessage" && options.scope === "page") || + (event.data?.type === "WorkerScriptMessage" && options.scope === "worker") + ) { + const message = event.data.message; + if (message.type === "StoreReady") { + console.log( + "[TTV LOL PRO] πŸ“¦ Received store state from content script." + ); + options.state = message.state; + shouldWaitForStore = false; } - }); - } + } + }); return async function fetch( input: RequestInfo | URL, @@ -102,7 +103,7 @@ export function getFetch(options: FetchOptions): typeof fetch { ); while (shouldWaitForStore) await sleep(100); if (options.state?.anonymousMode) { - console.debug("[TTV LOL PRO] ❓ Acting as anonymous user"); + console.log("[TTV LOL PRO] ❓ Acting as anonymous user"); setHeaderToMap(headersMap, "Authorization", "undefined"); removeHeaderFromMap(headersMap, "Client-Session-Id"); removeHeaderFromMap(headersMap, "Client-Version"); diff --git a/src/page/page.ts b/src/page/page.ts index e2e465de..9aa24ddc 100644 --- a/src/page/page.ts +++ b/src/page/page.ts @@ -1,11 +1,10 @@ -import { FetchOptions, getFetch } from "./getFetch"; +import { getFetch } from "./getFetch"; console.info("[TTV LOL PRO] πŸš€ Page script running."); const params = JSON.parse(document.currentScript!.dataset.params!); -const fetchOptions: FetchOptions = { scope: "page" }; -window.fetch = getFetch(fetchOptions); +window.fetch = getFetch({ scope: "page" }); window.Worker = class Worker extends window.Worker { constructor(scriptURL: string | URL, options?: WorkerOptions) { From b1de61c1b9d182c5895c2ae0e99788b495cefdef Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 10 Sep 2023 20:59:52 +0200 Subject: [PATCH 05/42] Remove "Anonymous mode" from Chromium --- src/options/options.ts | 14 ++++++++++---- src/options/page.html | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/options/options.ts b/src/options/options.ts index c8790d6f..4eae1565 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -35,6 +35,7 @@ const proxyUsherRequestsCheckboxElement = $( const proxyTwitchWebpageCheckboxElement = $( "#proxy-twitch-webpage-checkbox" ) as HTMLInputElement; +const anonymousModeLiElement = $("#anonymous-mode-li") as HTMLLIElement; const anonymousModeCheckboxElement = $( "#anonymous-mode-checkbox" ) as HTMLInputElement; @@ -105,10 +106,15 @@ function main() { updateProxySettings(); } }); - anonymousModeCheckboxElement.checked = store.state.anonymousMode; - anonymousModeCheckboxElement.addEventListener("change", () => { - store.state.anonymousMode = anonymousModeCheckboxElement.checked; - }); + // TODO: Figure out why this feature doesn't work in Chromium. + if (isChromium) { + anonymousModeLiElement.style.display = "none"; + } else { + anonymousModeCheckboxElement.checked = store.state.anonymousMode; + anonymousModeCheckboxElement.addEventListener("change", () => { + store.state.anonymousMode = anonymousModeCheckboxElement.checked; + }); + } // Whitelisted channels if (isChromium) { whitelistedChannelsSectionElement.style.display = "none"; diff --git a/src/options/page.html b/src/options/page.html index 752f3b3a..2a1d666a 100644 --- a/src/options/page.html +++ b/src/options/page.html @@ -83,7 +83,7 @@

    Passport

    -
  • +
  • Date: Sun, 24 Sep 2023 12:34:31 +0100 Subject: [PATCH 06/42] Whitelisting via tab analysis for chromium --- src/background/background.ts | 4 ++ .../handlers/onProxySettingsChanged.ts | 6 +++ .../handlers/onStartupStoreCleanup.ts | 1 + src/background/handlers/onTabCreated.ts | 10 +++- src/background/handlers/onTabRemoved.ts | 22 +++++++- src/background/handlers/onTabUpdated.ts | 50 +++++++++++++++++-- src/options/options.ts | 4 -- src/popup/popup.ts | 3 -- src/store/types.ts | 1 + 9 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 src/background/handlers/onProxySettingsChanged.ts diff --git a/src/background/background.ts b/src/background/background.ts index abcde524..30ac6ffd 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -10,6 +10,7 @@ import onStartupStoreCleanup from "./handlers/onStartupStoreCleanup"; import onTabCreated from "./handlers/onTabCreated"; import onTabRemoved from "./handlers/onTabRemoved"; import onTabUpdated from "./handlers/onTabUpdated"; +import onProxySettingsChange from "./handlers/onProxySettingsChanged"; console.info("πŸš€ Background script loaded."); @@ -36,6 +37,9 @@ if (isChromium) { browser.tabs.onCreated.addListener(onTabCreated); browser.tabs.onUpdated.addListener(onTabUpdated); browser.tabs.onRemoved.addListener(onTabRemoved); + + // Listen to whether proxy is set or not + chrome.proxy.settings.onChange.addListener(onProxySettingsChange); } else { // Block tracking pixels. browser.webRequest.onBeforeRequest.addListener( diff --git a/src/background/handlers/onProxySettingsChanged.ts b/src/background/handlers/onProxySettingsChanged.ts new file mode 100644 index 00000000..0dfe524d --- /dev/null +++ b/src/background/handlers/onProxySettingsChanged.ts @@ -0,0 +1,6 @@ +import store from "../../store"; + +export default function onProxySettingsChange(details: chrome.types.ChromeSettingGetResultDetails) { + console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); + store.state.chromiumProxyActive = details.levelOfControl == "controlled_by_this_extension"; +} \ No newline at end of file diff --git a/src/background/handlers/onStartupStoreCleanup.ts b/src/background/handlers/onStartupStoreCleanup.ts index 15c88c1e..3e92d4c7 100644 --- a/src/background/handlers/onStartupStoreCleanup.ts +++ b/src/background/handlers/onStartupStoreCleanup.ts @@ -16,4 +16,5 @@ export default function onStartupStoreCleanup(): void { store.state.openedTwitchTabs = []; store.state.streamStatuses = {}; store.state.videoWeaverUrlsByChannel = {}; + store.state.chromiumProxyActive = false; } diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index 9cb7e94b..1d8633f9 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -3,6 +3,7 @@ import getHostFromUrl from "../../common/ts/getHostFromUrl"; import isChromium from "../../common/ts/isChromium"; import { updateProxySettings } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabCreated(tab: Tabs.Tab): void { @@ -10,8 +11,13 @@ export default function onTabCreated(tab: Tabs.Tab): void { const host = getHostFromUrl(tab.url); if (host != null && twitchTvHostRegex.test(host)) { console.log(`βž• Opened Twitch tab: ${tab.id}`); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - updateProxySettings(); + if (isChromium) { + var isNonWhitelistedChannel = true; + const url = new URL(tab.url); + if (url.pathname && url.pathname.length > 0) { + isNonWhitelistedChannel = !isChannelWhitelisted(url.pathname.substring(1)); + } + if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) updateProxySettings(); } store.state.openedTwitchTabs.push(tab.id); } diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 26c81d66..74c40cb4 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -1,5 +1,7 @@ +import browser from "webextension-polyfill"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings } from "../../common/ts/proxySettings"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabRemoved(tabId: number): void { @@ -7,8 +9,24 @@ export default function onTabRemoved(tabId: number): void { if (index !== -1) { console.log(`βž– Closed Twitch tab: ${tabId}`); store.state.openedTwitchTabs.splice(index, 1); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - clearProxySettings(); + if (isChromium) { + if (store.state.openedTwitchTabs.length === 0) { + clearProxySettings(); + return; + } + + Promise.all(store.state.openedTwitchTabs.map(tabId => { + return browser.tabs.get(tabId).then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == '/') return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }).catch(() => false); + })).then(res => { + if (!res.includes(false) && store.state.chromiumProxyActive) { + clearProxySettings(); + } + }); } } } diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index c08aec9b..8ff7fff1 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -1,3 +1,4 @@ +import browser from "webextension-polyfill"; import { Tabs } from "webextension-polyfill"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; import isChromium from "../../common/ts/isChromium"; @@ -6,6 +7,7 @@ import { updateProxySettings, } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabUpdated( @@ -25,8 +27,13 @@ export default function onTabUpdated( if (isTwitchTab && !wasTwitchTab) { console.log(`βž• Opened Twitch tab: ${tabId}`); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - updateProxySettings(); + if (isChromium) { + var isNonWhitelistedPage = true; + const urlObj = new URL(url); + if (urlObj.pathname && urlObj.pathname.length > 0) { + isNonWhitelistedPage = !isChannelWhitelisted(urlObj.pathname.substring(1)); + } + if (isNonWhitelistedPage) updateProxySettings(); } store.state.openedTwitchTabs.push(tabId); } @@ -35,9 +42,44 @@ export default function onTabUpdated( if (index !== -1) { console.log(`βž– Closed Twitch tab: ${tabId}`); store.state.openedTwitchTabs.splice(index, 1); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - clearProxySettings(); + if (isChromium) { + if (store.state.openedTwitchTabs.length === 0) { + clearProxySettings(); + return; + } + + Promise.all(store.state.openedTwitchTabs.map(tabId => { + return browser.tabs.get(tabId).then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == '/') return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }).catch(() => false); + })).then(res => { + if (!res.includes(false) && store.state.chromiumProxyActive) { + clearProxySettings(); + } + }); } } } + if (isTwitchTab && wasTwitchTab) { + console.log(`Changed Twitch tab: ${tabId}`); + if (isChromium) { + Promise.all(store.state.openedTwitchTabs.map(tabId => { + return browser.tabs.get(tabId).then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == '/') return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }).catch(() => false); + })).then(res => { + if (!res.includes(false) && store.state.chromiumProxyActive) { + clearProxySettings(); + } else if (res.includes(false) && !store.state.chromiumProxyActive) { + updateProxySettings(); + } + }); + } + } } diff --git a/src/options/options.ts b/src/options/options.ts index 257b427e..0406c575 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -103,15 +103,11 @@ function main() { } }); // Whitelisted channels - if (isChromium) { - whitelistedChannelsSectionElement.style.display = "none"; - } else { listInit(whitelistedChannelsListElement, "whitelistedChannels", { getAlreadyExistsAlertMessage: channelName => `'${channelName}' is already whitelisted`, getPromptPlaceholder: () => "Enter a channel name…", }); - } // Proxies if (isChromium) { optimizedProxiesDivElement.style.display = "none"; diff --git a/src/popup/popup.ts b/src/popup/popup.ts index 4930262a..c5ae8abf 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -67,9 +67,6 @@ function setStreamStatusElement(channelName: string) { setProxyStatus(channelNameLower, status); setWhitelistStatus(channelNameLower); streamStatusElement.style.display = "flex"; - if (isChromium) { - whitelistStatusElement.style.display = "none"; - } } else { streamStatusElement.style.display = "none"; } diff --git a/src/store/types.ts b/src/store/types.ts index 8062c83f..a81bd528 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -8,6 +8,7 @@ export interface State { adLog: AdLogEntry[]; adLogEnabled: boolean; adLogLastSent: number; + chromiumProxyActive: boolean; dnsResponses: DnsResponse[]; normalProxies: string[]; openedTwitchTabs: number[]; From 2bd130f8a0346cef7ace77efb5ebc1be533e9bdf Mon Sep 17 00:00:00 2001 From: Luke Fanning Date: Sun, 24 Sep 2023 12:47:35 +0100 Subject: [PATCH 07/42] Linting fix --- src/background/background.ts | 2 +- .../handlers/onProxySettingsChanged.ts | 11 ++-- src/background/handlers/onTabCreated.ts | 9 ++-- src/background/handlers/onTabRemoved.ts | 23 ++++---- src/background/handlers/onTabUpdated.ts | 53 +++++++++++-------- src/options/options.ts | 10 ++-- 6 files changed, 65 insertions(+), 43 deletions(-) diff --git a/src/background/background.ts b/src/background/background.ts index 30ac6ffd..55397d63 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -5,12 +5,12 @@ import onAuthRequired from "./handlers/onAuthRequired"; import onBeforeSendHeaders from "./handlers/onBeforeSendHeaders"; import onBeforeVideoWeaverRequest from "./handlers/onBeforeVideoWeaverRequest"; 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"; import onTabRemoved from "./handlers/onTabRemoved"; import onTabUpdated from "./handlers/onTabUpdated"; -import onProxySettingsChange from "./handlers/onProxySettingsChanged"; console.info("πŸš€ Background script loaded."); diff --git a/src/background/handlers/onProxySettingsChanged.ts b/src/background/handlers/onProxySettingsChanged.ts index 0dfe524d..56820405 100644 --- a/src/background/handlers/onProxySettingsChanged.ts +++ b/src/background/handlers/onProxySettingsChanged.ts @@ -1,6 +1,9 @@ import store from "../../store"; -export default function onProxySettingsChange(details: chrome.types.ChromeSettingGetResultDetails) { - console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); - store.state.chromiumProxyActive = details.levelOfControl == "controlled_by_this_extension"; -} \ No newline at end of file +export default function onProxySettingsChange( + details: chrome.types.ChromeSettingGetResultDetails +) { + console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); + store.state.chromiumProxyActive = + details.levelOfControl == "controlled_by_this_extension"; +} diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index 1d8633f9..71be2b8c 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -1,9 +1,9 @@ import { Tabs } from "webextension-polyfill"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { updateProxySettings } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabCreated(tab: Tabs.Tab): void { @@ -15,9 +15,12 @@ export default function onTabCreated(tab: Tabs.Tab): void { var isNonWhitelistedChannel = true; const url = new URL(tab.url); if (url.pathname && url.pathname.length > 0) { - isNonWhitelistedChannel = !isChannelWhitelisted(url.pathname.substring(1)); + isNonWhitelistedChannel = !isChannelWhitelisted( + url.pathname.substring(1) + ); } - if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) updateProxySettings(); + if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) + updateProxySettings(); } store.state.openedTwitchTabs.push(tab.id); } diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 74c40cb4..1a36c954 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -1,7 +1,7 @@ import browser from "webextension-polyfill"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings } from "../../common/ts/proxySettings"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabRemoved(tabId: number): void { @@ -15,14 +15,19 @@ export default function onTabRemoved(tabId: number): void { return; } - Promise.all(store.state.openedTwitchTabs.map(tabId => { - return browser.tabs.get(tabId).then(tab => { - if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == '/') return false; - return isChannelWhitelisted(url.pathname.substring(1)); - }).catch(() => false); - })).then(res => { + Promise.all( + store.state.openedTwitchTabs.map(tabId => { + return browser.tabs + .get(tabId) + .then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == "/") return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }) + .catch(() => false); + }) + ).then(res => { if (!res.includes(false) && store.state.chromiumProxyActive) { clearProxySettings(); } diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index 8ff7fff1..ee151061 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -1,13 +1,12 @@ -import browser from "webextension-polyfill"; -import { Tabs } from "webextension-polyfill"; +import browser, { Tabs } from "webextension-polyfill"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings, updateProxySettings, } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabUpdated( @@ -31,7 +30,9 @@ export default function onTabUpdated( var isNonWhitelistedPage = true; const urlObj = new URL(url); if (urlObj.pathname && urlObj.pathname.length > 0) { - isNonWhitelistedPage = !isChannelWhitelisted(urlObj.pathname.substring(1)); + isNonWhitelistedPage = !isChannelWhitelisted( + urlObj.pathname.substring(1) + ); } if (isNonWhitelistedPage) updateProxySettings(); } @@ -47,15 +48,20 @@ export default function onTabUpdated( clearProxySettings(); return; } - - Promise.all(store.state.openedTwitchTabs.map(tabId => { - return browser.tabs.get(tabId).then(tab => { - if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == '/') return false; - return isChannelWhitelisted(url.pathname.substring(1)); - }).catch(() => false); - })).then(res => { + + Promise.all( + store.state.openedTwitchTabs.map(tabId => { + return browser.tabs + .get(tabId) + .then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == "/") return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }) + .catch(() => false); + }) + ).then(res => { if (!res.includes(false) && store.state.chromiumProxyActive) { clearProxySettings(); } @@ -66,14 +72,19 @@ export default function onTabUpdated( if (isTwitchTab && wasTwitchTab) { console.log(`Changed Twitch tab: ${tabId}`); if (isChromium) { - Promise.all(store.state.openedTwitchTabs.map(tabId => { - return browser.tabs.get(tabId).then(tab => { - if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == '/') return false; - return isChannelWhitelisted(url.pathname.substring(1)); - }).catch(() => false); - })).then(res => { + Promise.all( + store.state.openedTwitchTabs.map(tabId => { + return browser.tabs + .get(tabId) + .then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == "/") return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }) + .catch(() => false); + }) + ).then(res => { if (!res.includes(false) && store.state.chromiumProxyActive) { clearProxySettings(); } else if (res.includes(false) && !store.state.chromiumProxyActive) { diff --git a/src/options/options.ts b/src/options/options.ts index 0406c575..b237acf8 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -103,11 +103,11 @@ function main() { } }); // Whitelisted channels - listInit(whitelistedChannelsListElement, "whitelistedChannels", { - getAlreadyExistsAlertMessage: channelName => - `'${channelName}' is already whitelisted`, - getPromptPlaceholder: () => "Enter a channel name…", - }); + listInit(whitelistedChannelsListElement, "whitelistedChannels", { + getAlreadyExistsAlertMessage: channelName => + `'${channelName}' is already whitelisted`, + getPromptPlaceholder: () => "Enter a channel name…", + }); // Proxies if (isChromium) { optimizedProxiesDivElement.style.display = "none"; From a42219c9f4ad8a2d32e7158bdfdd462cc89e24a0 Mon Sep 17 00:00:00 2001 From: Luke Fanning Date: Sun, 24 Sep 2023 12:50:26 +0100 Subject: [PATCH 08/42] Updated default state with chromiumProxyActive --- src/store/getDefaultState.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/getDefaultState.ts b/src/store/getDefaultState.ts index 9b22532d..e163c911 100644 --- a/src/store/getDefaultState.ts +++ b/src/store/getDefaultState.ts @@ -6,6 +6,7 @@ export default function getDefaultState() { adLog: [], adLogEnabled: true, adLogLastSent: 0, + chromiumProxyActive: false, dnsResponses: [], normalProxies: ["chrome.api.cdn-perfprod.com:4023"], openedTwitchTabs: [], From aedf2e8feb011e1ae287e0a0f7baa4d466071af5 Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:42:41 +0200 Subject: [PATCH 09/42] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20dependenci?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- package-lock.json | 319 ++++++++++++++++++------------------ package.json | 7 +- 3 files changed, 168 insertions(+), 160 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00082a10..85da2758 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Run linter run: npm run lint - name: Run type checker - run: npx tsc --noEmit + run: npm run type-check # - name: Run tests # run: npm run test - name: Build for Firefox diff --git a/package-lock.json b/package-lock.json index 9ce0c56b..02dd6f27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,13 +14,13 @@ }, "devDependencies": { "@parcel/config-webextension": "^2.9.3", - "@types/chrome": "^0.0.245", + "@types/chrome": "^0.0.246", "@types/ip": "^1.1.0", - "@types/webextension-polyfill": "^0.10.2", + "@types/webextension-polyfill": "^0.10.3", "buffer": "^6.0.3", "os-browserify": "^0.3.0", "parcel": "^2.9.3", - "postcss": "^8.4.29", + "postcss": "^8.4.30", "prettier": "2.8.8", "prettier-plugin-css-order": "^1.3.1", "prettier-plugin-organize-imports": "^3.2.3", @@ -105,21 +105,21 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.15.tgz", - "integrity": "sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.13.tgz", - "integrity": "sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, @@ -190,18 +190,18 @@ } }, "node_modules/@lezer/common": { - "version": "0.15.12", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-0.15.12.tgz", - "integrity": "sha512-edfwCxNLnzq5pBA/yaIhwJ3U3Kz8VAUOTRg0hhxaizaI1N+qxV7EXDv/kLCkLeq2RzSFvxexlaj5Mzfn2kY0Ig==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.1.0.tgz", + "integrity": "sha512-XPIN3cYDXsoJI/oDWoR2tD++juVrhgIago9xyKhZ7IhGlzdDM9QgC8D8saKNCz5pindGcznFr2HBSsEQSWnSjw==", "dev": true }, "node_modules/@lezer/lr": { - "version": "0.15.8", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-0.15.8.tgz", - "integrity": "sha512-bM6oE6VQZ6hIFxDNKk8bKPa14hqFrV07J/vHGOeiAbJReIaQXmkVb6xQu4MR+JBTLa5arGRyAAjJe1qaQt3Uvg==", + "version": "1.3.12", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.3.12.tgz", + "integrity": "sha512-5nwY1JzCueUdRtlMBnlf1SUi69iGCq2ABq7WQFQMkn/kxPvoACAEnTp4P17CtXxYr7WCwtYPLL2AEvxKPuF1OQ==", "dev": true, "dependencies": { - "@lezer/common": "^0.15.0" + "@lezer/common": "^1.0.0" } }, "node_modules/@lmdb/lmdb-darwin-arm64": { @@ -283,13 +283,13 @@ ] }, "node_modules/@mischnic/json-sourcemap": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@mischnic/json-sourcemap/-/json-sourcemap-0.1.0.tgz", - "integrity": "sha512-dQb3QnfNqmQNYA4nFSN/uLaByIic58gOXq4Y4XqLOWmOrw73KmJPt/HLyG0wvn1bnR6mBKs/Uwvkh+Hns1T0XA==", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@mischnic/json-sourcemap/-/json-sourcemap-0.1.1.tgz", + "integrity": "sha512-iA7+tyVqfrATAIsIRWQG+a7ZLLD0VaOCKV2Wd/v4mqIU3J9c4jx9p7S0nw1XH3gJCKNBOOwACOPYYSUu9pgT+w==", "dev": true, "dependencies": { - "@lezer/common": "^0.15.7", - "@lezer/lr": "^0.15.4", + "@lezer/common": "^1.0.0", + "@lezer/lr": "^1.0.0", "json5": "^2.2.1" }, "engines": { @@ -1940,13 +1940,14 @@ } }, "node_modules/@swc/core": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.83.tgz", - "integrity": "sha512-PccHDgGQlFjpExgJxH91qA3a4aifR+axCFJ4RieCoiI0m5gURE4nBhxzTBY5YU/YKTBmPO8Gc5Q6inE3+NquWg==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.88.tgz", + "integrity": "sha512-kaJ5t6Fg/DmJPNeI+jdtCEt7NVKxhUYToq7PF2fMRPFPLKSJzJCZajcp6/gZNcEUCVWaK6pWi/XL79Tzz1FqzQ==", "dev": true, "hasInstallScript": true, "dependencies": { - "@swc/types": "^0.1.4" + "@swc/counter": "^0.1.1", + "@swc/types": "^0.1.5" }, "engines": { "node": ">=10" @@ -1956,16 +1957,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.83", - "@swc/core-darwin-x64": "1.3.83", - "@swc/core-linux-arm-gnueabihf": "1.3.83", - "@swc/core-linux-arm64-gnu": "1.3.83", - "@swc/core-linux-arm64-musl": "1.3.83", - "@swc/core-linux-x64-gnu": "1.3.83", - "@swc/core-linux-x64-musl": "1.3.83", - "@swc/core-win32-arm64-msvc": "1.3.83", - "@swc/core-win32-ia32-msvc": "1.3.83", - "@swc/core-win32-x64-msvc": "1.3.83" + "@swc/core-darwin-arm64": "1.3.88", + "@swc/core-darwin-x64": "1.3.88", + "@swc/core-linux-arm-gnueabihf": "1.3.88", + "@swc/core-linux-arm64-gnu": "1.3.88", + "@swc/core-linux-arm64-musl": "1.3.88", + "@swc/core-linux-x64-gnu": "1.3.88", + "@swc/core-linux-x64-musl": "1.3.88", + "@swc/core-win32-arm64-msvc": "1.3.88", + "@swc/core-win32-ia32-msvc": "1.3.88", + "@swc/core-win32-x64-msvc": "1.3.88" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -1977,9 +1978,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.83.tgz", - "integrity": "sha512-Plz2IKeveVLivbXTSCC3OZjD2MojyKYllhPrn9RotkDIZEFRYJZtW5/Ik1tJW/2rzu5HVKuGYrDKdScVVTbOxQ==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.88.tgz", + "integrity": "sha512-Nb7kKydSQK3FE90pw/GPRFmAkquDQcTixLijNcki2xFBXh/DcGdFUPE/GShQjk8gtQelj2vqZrsGs/GZPGA1mA==", "cpu": [ "arm64" ], @@ -1993,9 +1994,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.83.tgz", - "integrity": "sha512-FBGVg5IPF/8jQ6FbK60iDUHjv0H5+LwfpJHKH6wZnRaYWFtm7+pzYgreLu3NTsm3m7/1a7t0+7KURwBGUaJCCw==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.88.tgz", + "integrity": "sha512-RcCrnjkmLXL1izSHPYLaJKVaxwd64LYiYLqjX2jXG4U50D6LOlmuLeqTJ8aAnENZP19gNpsY9ggY9jD5UQqHAw==", "cpu": [ "x64" ], @@ -2009,9 +2010,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.83.tgz", - "integrity": "sha512-EZcsuRYhGkzofXtzwDjuuBC/suiX9s7zeg2YYXOVjWwyebb6BUhB1yad3mcykFQ20rTLO9JUyIaiaMYDHGobqw==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.88.tgz", + "integrity": "sha512-/H7QhpgbWX4xe6jbkgPrhjY543oCCmbPRvBMvZ3iuLb81bEtOFiEp9LYe/95ZW/BTz2z9a6fQtQMqkhAjcrV5w==", "cpu": [ "arm" ], @@ -2025,9 +2026,9 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.83.tgz", - "integrity": "sha512-khI41szLHrCD/cFOcN4p2SYvZgHjhhHlcMHz5BksRrDyteSJKu0qtWRZITVom0N/9jWoAleoFhMnFTUs0H8IWA==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.88.tgz", + "integrity": "sha512-ar/oQJxisjn/Su9rsg+XcBqA54Ylh1SyrZiLslv37OnGr785Xw+C//rw+JGoFmCZSjhGAU5hriOiHJd2S8mtqA==", "cpu": [ "arm64" ], @@ -2041,9 +2042,9 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.83.tgz", - "integrity": "sha512-zgT7yNOdbjHcGAwvys79mbfNLK65KBlPJWzeig+Yk7I8TVzmaQge7B6ZS/gwF9/p+8TiLYo/tZ5aF2lqlgdSVw==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.88.tgz", + "integrity": "sha512-ZyUtCk1Y4GpOajbHcnm2JwkFm/m8M/wP3I8iaAm/0yAPIYwQInVdD0Hn++eig2Y+nLJ7gT0QI82fFUDPEIP6Jw==", "cpu": [ "arm64" ], @@ -2057,9 +2058,9 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.83.tgz", - "integrity": "sha512-x+mH0Y3NC/G0YNlFmGi3vGD4VOm7IPDhh+tGrx6WtJp0BsShAbOpxtfU885rp1QweZe4qYoEmGqiEjE2WrPIdA==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.88.tgz", + "integrity": "sha512-VrwGCzKLwimL0Js1yWRQNpcJCLGYkETku9mEI9sM4yF6kzT/jwfOe94udBe9O4GGUv24QkzHXRk+EnGR2LFSOQ==", "cpu": [ "x64" ], @@ -2073,9 +2074,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.83.tgz", - "integrity": "sha512-s5AYhAOmetUwUZwS5g9qb92IYgNHHBGiY2mTLImtEgpAeBwe0LPDj6WrujxCBuZnaS55mKRLLOuiMZE5TpjBNA==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.88.tgz", + "integrity": "sha512-cur5h0JmNfF4ZHb+FBPLePX86lu3FUjxltObWUhqO4QiXzHxWfde6g+pgdqfUAer0cd9VEEjEKGA5OQncXqyCQ==", "cpu": [ "x64" ], @@ -2089,9 +2090,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.83.tgz", - "integrity": "sha512-yw2rd/KVOGs95lRRB+killLWNaO1dy4uVa8Q3/4wb5txlLru07W1m041fZLzwOg/1Sh0TMjJgGxj0XHGR3ZXhQ==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.88.tgz", + "integrity": "sha512-f9OVuWrey7X0gjCZlVD4d5/9/d0yyxu8KFUOEjyjJ2Kd+pvzRys1U3E0FE1PiiDOng3qrfdOt4HQxyAy2jts9Q==", "cpu": [ "arm64" ], @@ -2105,9 +2106,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.83.tgz", - "integrity": "sha512-POW+rgZ6KWqBpwPGIRd2/3pcf46P+UrKBm4HLt5IwbHvekJ4avIM8ixJa9kK0muJNVJcDpaZgxaU1ELxtJ1j8w==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.88.tgz", + "integrity": "sha512-7KCeTVe8wWRbuiuAwXoHKBkr9nugCAHQe/JGxoevHXxn2h+WwBuWHog1AbS6PvRWSKK8dVhKAAPDNWwdEltA5A==", "cpu": [ "ia32" ], @@ -2121,9 +2122,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.3.83", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.83.tgz", - "integrity": "sha512-CiWQtkFnZElXQUalaHp+Wacw0Jd+24ncRYhqaJ9YKnEQP1H82CxIIuQqLM8IFaLpn5dpY6SgzaeubWF46hjcLA==", + "version": "1.3.88", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.88.tgz", + "integrity": "sha512-x0wr9kCS2Hmpx7H6gvJHA17G0DnvwToqWDSO1VmePt5hQZZfLzxiHHDHKFv4YYsVPbAU283q4Wa39QSPZeJbTA==", "cpu": [ "x64" ], @@ -2136,6 +2137,12 @@ "node": ">=10" } }, + "node_modules/@swc/counter": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.1.tgz", + "integrity": "sha512-xVRaR4u9hcYjFvcSg71Lz5Bo4//CyjAAfMxa7UsaDSYxAshflUkVJWiyVWrfxC59z2kP1IzI4/1BEpnhI9o3Mw==", + "dev": true + }, "node_modules/@swc/helpers": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", @@ -2146,9 +2153,9 @@ } }, "node_modules/@swc/types": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.4.tgz", - "integrity": "sha512-z/G02d+59gyyUb7KYhKi9jOhicek6QD2oMaotUyG+lUkybpXoV49dY9bj7Ah5Q+y7knK2jU67UTX9FyfGzaxQg==", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.5.tgz", + "integrity": "sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==", "dev": true }, "node_modules/@trysound/sax": { @@ -2161,9 +2168,9 @@ } }, "node_modules/@types/chrome": { - "version": "0.0.245", - "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.245.tgz", - "integrity": "sha512-bBdONkLO8wMbJK6iG0Q8ShFuh67Grnod+5OpClJaa8MuKJXP/Kjl3f8wRYeMOnQ0Q8HDgpUlopu8bvl9siR8/A==", + "version": "0.0.246", + "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.246.tgz", + "integrity": "sha512-MxGxEomGxsJiL9xe/7ZwVgwdn8XVKWbPvxpVQl3nWOjrS0Ce63JsfzxUc4aU3GvRcUPYsfufHmJ17BFyKxeA4g==", "dev": true, "dependencies": { "@types/filesystem": "*", @@ -2171,24 +2178,24 @@ } }, "node_modules/@types/filesystem": { - "version": "0.0.32", - "resolved": "https://registry.npmjs.org/@types/filesystem/-/filesystem-0.0.32.tgz", - "integrity": "sha512-Yuf4jR5YYMR2DVgwuCiP11s0xuVRyPKmz8vo6HBY3CGdeMj8af93CFZX+T82+VD1+UqHOxTq31lO7MI7lepBtQ==", + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/filesystem/-/filesystem-0.0.33.tgz", + "integrity": "sha512-2KedRPzwu2K528vFkoXnnWdsG0MtUwPjuA7pRy4vKxlxHEe8qUDZibYHXJKZZr2Cl/ELdCWYqyb/MKwsUuzBWw==", "dev": true, "dependencies": { "@types/filewriter": "*" } }, "node_modules/@types/filewriter": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/filewriter/-/filewriter-0.0.29.tgz", - "integrity": "sha512-BsPXH/irW0ht0Ji6iw/jJaK8Lj3FJemon2gvEqHKpCdDCeemHa+rI3WBGq5z7cDMZgoLjY40oninGxqk+8NzNQ==", + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/@types/filewriter/-/filewriter-0.0.30.tgz", + "integrity": "sha512-lB98tui0uxc7erbj0serZfJlHKLNJHwBltPnbmO1WRpL5T325GOHRiQfr2E29V2q+S1brDO63Fpdt6vb3bES9Q==", "dev": true }, "node_modules/@types/har-format": { - "version": "1.2.12", - "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.12.tgz", - "integrity": "sha512-P20p/YBrqUBmzD6KhIQ8EiY4/RRzlekL4eCvfQnulFPfjmiGxKIoyCeI7qam5I7oKH3P8EU4ptEi0EfyGoLysw==", + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.13.tgz", + "integrity": "sha512-PwBsCBD3lDODn4xpje3Y1di0aDJp4Ww7aSfMRVw6ysnxD4I7Wmq2mBkSKaDtN403hqH5sp6c9xQUvFYY3+lkBg==", "dev": true }, "node_modules/@types/ip": { @@ -2201,15 +2208,15 @@ } }, "node_modules/@types/node": { - "version": "20.6.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", - "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==", + "version": "20.6.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.4.tgz", + "integrity": "sha512-nU6d9MPY0NBUMiE/nXd2IIoC4OLvsLpwAjheoAeuzgvDZA1Cb10QYg+91AF6zQiKWRN5i1m07x6sMe0niBznoQ==", "dev": true }, "node_modules/@types/webextension-polyfill": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.2.tgz", - "integrity": "sha512-L+T72DVTi/1azY6gw7PRmL49kvobLKQQWfOmHDBRSCkAvaCV4wk222J3ZODYA9Gf/UqUvtItu8FPJgWX5ktO9g==", + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.3.tgz", + "integrity": "sha512-7RqGPhr+Ib7IKrOIeXRTB2TVojq/bMRieoYVfgHoicQ+VvI6OOzBNF0fZXA+5JVJIEtfE/o426S+bMgg/XhvXg==", "dev": true }, "node_modules/abortcontroller-polyfill": { @@ -2308,9 +2315,9 @@ } }, "node_modules/browserslist": { - "version": "4.21.10", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.10.tgz", - "integrity": "sha512-bipEBdZfVH5/pwrvqc+Ub0kUPVfGUhlKxbvfD+z1BDnPEO/X98ruXGA1WP5ASpAFKan7Qr6j736IacbZQuAlKQ==", + "version": "4.21.11", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.11.tgz", + "integrity": "sha512-xn1UXOKUz7DjdGlg9RrUr0GGiWzI97UQJnugHtH0OLDfJB7jMgoIkYvRIEO1l9EeEERVqeqLYOcFBW9ldjypbQ==", "dev": true, "funding": [ { @@ -2327,10 +2334,10 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001517", - "electron-to-chromium": "^1.4.477", + "caniuse-lite": "^1.0.30001538", + "electron-to-chromium": "^1.4.526", "node-releases": "^2.0.13", - "update-browserslist-db": "^1.0.11" + "update-browserslist-db": "^1.0.13" }, "bin": { "browserslist": "cli.js" @@ -2373,9 +2380,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001532", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001532.tgz", - "integrity": "sha512-FbDFnNat3nMnrROzqrsg314zhqN5LGQ1kyyMk2opcrwGbVGpHRhgCWtAgD5YJUqNAiQ+dklreil/c3Qf1dfCTw==", + "version": "1.0.30001538", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", + "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==", "dev": true, "funding": [ { @@ -2469,9 +2476,9 @@ } }, "node_modules/cosmiconfig": { - "version": "8.3.5", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.5.tgz", - "integrity": "sha512-A5Xry3xfS96wy2qbiLkQLAg4JUrR2wvfybxj6yqLmrUfMAvhS3MZxIP2oQn0grgYIvJqzpeTEWu4vK0t+12NNw==", + "version": "8.3.6", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz", + "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", "dev": true, "dependencies": { "import-fresh": "^3.3.0", @@ -2495,9 +2502,9 @@ } }, "node_modules/css-declaration-sorter": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-7.0.3.tgz", - "integrity": "sha512-/PHObPdiAXf0H3LOZCyXgBLt5fiS5XGCml/Ylpkmr7ADgq94GffvdGxJEmsSLDo0XGzItJY79dusRka0e4UVLw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-7.1.0.tgz", + "integrity": "sha512-suZ/qn6r4iXWLGOlD34EfYCCZxq18KXC/OYIyPHUnV3MHl3JO9LmcaVFHpgbHwfg+SayGOpXURJIs3aJpxcjyA==", "dev": true, "engines": { "node": "^14 || ^16 || >=18" @@ -2745,9 +2752,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.513", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.513.tgz", - "integrity": "sha512-cOB0xcInjm+E5qIssHeXJ29BaUyWpMyFKT5RB3bsLENDheCja0wMkHJyiPl0NBE/VzDI7JDuNEQWhe6RitEUcw==", + "version": "1.4.528", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.528.tgz", + "integrity": "sha512-UdREXMXzLkREF4jA8t89FQjA8WHI6ssP38PMY4/4KhXFQbtImnghh4GkCgrtiZwLKUKVD2iTVXvDVQjfomEQuA==", "dev": true }, "node_modules/entities": { @@ -2843,9 +2850,9 @@ } }, "node_modules/globals": { - "version": "13.21.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", - "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", + "version": "13.22.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.22.0.tgz", + "integrity": "sha512-H1Ddc/PbZHTDVJSnj8kWptIRSD6AM3pK+mKytuIVF4uoBV7rshFlhhvA58ceJ5wp3Er58w6zj7bykMpYXt3ETw==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -3101,9 +3108,9 @@ } }, "node_modules/lightningcss": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.21.7.tgz", - "integrity": "sha512-xITZyh5sLFwRPYUSw15T00Rm7gcQ1qOPuQwNOcvHsTm6nLWTQ723w7zl42wrC5t+xtdg6FPmnXHml1nZxxvp1w==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.22.0.tgz", + "integrity": "sha512-+z0qvwRVzs4XGRXelnWRNwqsXUx8k3bSkbP8vD42kYKSk3z9OM2P3e/gagT7ei/gwh8DTS80LZOFZV6lm8Z8Fg==", "dev": true, "dependencies": { "detect-libc": "^1.0.3" @@ -3116,21 +3123,21 @@ "url": "https://opencollective.com/parcel" }, "optionalDependencies": { - "lightningcss-darwin-arm64": "1.21.7", - "lightningcss-darwin-x64": "1.21.7", - "lightningcss-freebsd-x64": "1.21.7", - "lightningcss-linux-arm-gnueabihf": "1.21.7", - "lightningcss-linux-arm64-gnu": "1.21.7", - "lightningcss-linux-arm64-musl": "1.21.7", - "lightningcss-linux-x64-gnu": "1.21.7", - "lightningcss-linux-x64-musl": "1.21.7", - "lightningcss-win32-x64-msvc": "1.21.7" + "lightningcss-darwin-arm64": "1.22.0", + "lightningcss-darwin-x64": "1.22.0", + "lightningcss-freebsd-x64": "1.22.0", + "lightningcss-linux-arm-gnueabihf": "1.22.0", + "lightningcss-linux-arm64-gnu": "1.22.0", + "lightningcss-linux-arm64-musl": "1.22.0", + "lightningcss-linux-x64-gnu": "1.22.0", + "lightningcss-linux-x64-musl": "1.22.0", + "lightningcss-win32-x64-msvc": "1.22.0" } }, "node_modules/lightningcss-darwin-arm64": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.21.7.tgz", - "integrity": "sha512-tt7hIsFio9jZofTVHtCACz6rB6c9RyABMXfA9A/VcKOjS3sq+koX/QkRJWY06utwOImbJIXBC5hbg9t3RkPUAQ==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.22.0.tgz", + "integrity": "sha512-aH2be3nNny+It5YEVm8tBSSdRlBVWQV8m2oJ7dESiYRzyY/E/bQUe2xlw5caaMuhlM9aoTMtOH25yzMhir0qPg==", "cpu": [ "arm64" ], @@ -3148,9 +3155,9 @@ } }, "node_modules/lightningcss-darwin-x64": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.21.7.tgz", - "integrity": "sha512-F4gS4bf7eWekfPT+TxJNm/pF+QRgZiTrTkQH6cw4/UWfdeZISfuhD5El2dm16giFnY0K5ylIwO+ZusgYNkGSXA==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.22.0.tgz", + "integrity": "sha512-9KHRFA0Y6mNxRHeoQMp0YaI0R0O2kOgUlYPRjuasU4d+pI8NRhVn9bt0yX9VPs5ibWX1RbDViSPtGJvYYrfVAQ==", "cpu": [ "x64" ], @@ -3168,9 +3175,9 @@ } }, "node_modules/lightningcss-freebsd-x64": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.21.7.tgz", - "integrity": "sha512-RMfNzJWXCSfPnL55fcLWEAadcY6QUFT0S8NceNKYzp1KiCZtkJIy6RQ5SaVxPzRqd3iMsahUf5sfnG8N1UQSNQ==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.22.0.tgz", + "integrity": "sha512-xaYL3xperGwD85rQioDb52ozF3NAJb+9wrge3jD9lxGffplu0Mn35rXMptB8Uc2N9Mw1i3Bvl7+z1evlqVl7ww==", "cpu": [ "x64" ], @@ -3188,9 +3195,9 @@ } }, "node_modules/lightningcss-linux-arm-gnueabihf": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.21.7.tgz", - "integrity": "sha512-biSRUDZNx7vubWP1jArw/qqfZKPGpkV/qzunasZzxmqijbZ43sW9faDQYxWNcxPWljJJdF/qs6qcurYFovWtrQ==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.22.0.tgz", + "integrity": "sha512-epQGvXIjOuxrZpMpMnRjK54ZqzhiHhCPLtHvw2fb6NeK2kK9YtF0wqmeTBiQ1AkbWfnnXGTstYaFNiadNK+StQ==", "cpu": [ "arm" ], @@ -3208,9 +3215,9 @@ } }, "node_modules/lightningcss-linux-arm64-gnu": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.21.7.tgz", - "integrity": "sha512-PENY8QekqL9TG3AY/A7rkUBb5ymefGxea7Oe7+x7Hbw4Bz4Hpj5cec5OoMypMqFbURPmpi0fTWx4vSWUPzpDcA==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.22.0.tgz", + "integrity": "sha512-AArGtKSY4DGTA8xP8SDyNyKtpsUl1Rzq6FW4JomeyUQ4nBrR71uPChksTpj3gmWuGhZeRKLeCUI1DBid/zhChg==", "cpu": [ "arm64" ], @@ -3228,9 +3235,9 @@ } }, "node_modules/lightningcss-linux-arm64-musl": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.21.7.tgz", - "integrity": "sha512-pfOipKvA/0X1OjRaZt3870vnV9UGBSjayIqHh0fGx/+aRz3O0MVFHE/60P2UWXpM3YGJEw/hMWtNkrFwqOge8A==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.22.0.tgz", + "integrity": "sha512-RRraNgP8hnBPhInTTUdlFm+z16C/ghbxBG51Sw00hd7HUyKmEUKRozyc5od+/N6pOrX/bIh5vIbtMXIxsos0lg==", "cpu": [ "arm64" ], @@ -3248,9 +3255,9 @@ } }, "node_modules/lightningcss-linux-x64-gnu": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.21.7.tgz", - "integrity": "sha512-dgcsis4TAA7s0ia4f31QHX+G4PWPwxk+wJaEQLaV0NdJs09O5hHoA8DpLEr8nrvc/tsRTyVNBP1rDtgzySjpXg==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.22.0.tgz", + "integrity": "sha512-grdrhYGRi2KrR+bsXJVI0myRADqyA7ekprGxiuK5QRNkv7kj3Yq1fERDNyzZvjisHwKUi29sYMClscbtl+/Zpw==", "cpu": [ "x64" ], @@ -3268,9 +3275,9 @@ } }, "node_modules/lightningcss-linux-x64-musl": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.21.7.tgz", - "integrity": "sha512-A+9dXpxld3p4Cd6fxev2eqEvaauYtrgNpXV3t7ioCJy30Oj9nYiNGwiGusM+4MJVcEpUPGUGiuAqY4sWilRDwA==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.22.0.tgz", + "integrity": "sha512-t5f90X+iQUtIyR56oXIHMBUyQFX/zwmPt72E6Dane3P8KNGlkijTg2I75XVQS860gNoEFzV7Mm5ArRRA7u5CAQ==", "cpu": [ "x64" ], @@ -3288,9 +3295,9 @@ } }, "node_modules/lightningcss-win32-x64-msvc": { - "version": "1.21.7", - "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.21.7.tgz", - "integrity": "sha512-07/8vogEq+C/mF99pdMhh/f19/xreq8N9Ca6AWeVHZIdODyF/pt6KdKSCWDZWIn+3CUxI8gCJWuUWyOc3xymvw==", + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.22.0.tgz", + "integrity": "sha512-64HTDtOOZE9PUCZJiZZQpyqXBbdby1lnztBccnqh+NtbKxjnGzP92R2ngcgeuqMPecMNqNWxgoWgTGpC+yN5Sw==", "cpu": [ "x64" ], @@ -3635,9 +3642,9 @@ } }, "node_modules/postcss": { - "version": "8.4.29", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", - "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", + "version": "8.4.30", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.30.tgz", + "integrity": "sha512-7ZEao1g4kd68l97aWG/etQKPKq07us0ieSZ2TnFDk11i0ZfDW2AwKHYU8qv4MZKqN2fdBfg+7q0ES06UA73C1g==", "dev": true, "funding": [ { @@ -3842,9 +3849,9 @@ "dev": true }, "node_modules/resolve": { - "version": "1.22.4", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", - "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", + "version": "1.22.6", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.6.tgz", + "integrity": "sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw==", "dev": true, "dependencies": { "is-core-module": "^2.13.0", @@ -4090,9 +4097,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", - "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", "dev": true, "funding": [ { diff --git a/package.json b/package.json index de62bfa8..2d64a8f8 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "dev:chromium": "parcel src/manifest.json --host localhost --target webext-dev --no-hmr", "lint": "prettier --check .", "lint:fix": "prettier --write .", + "type-check": "tsc --noEmit", "prebuild:firefox": "npm run clean && shx cp src/manifest.firefox.json src/manifest.json", "prebuild:chromium": "npm run clean && shx cp src/manifest.chromium.json src/manifest.json", "build:firefox": "parcel build src/manifest.json --target webext-prod --no-source-maps", @@ -46,13 +47,13 @@ }, "devDependencies": { "@parcel/config-webextension": "^2.9.3", - "@types/chrome": "^0.0.245", + "@types/chrome": "^0.0.246", "@types/ip": "^1.1.0", - "@types/webextension-polyfill": "^0.10.2", + "@types/webextension-polyfill": "^0.10.3", "buffer": "^6.0.3", "os-browserify": "^0.3.0", "parcel": "^2.9.3", - "postcss": "^8.4.29", + "postcss": "^8.4.30", "prettier": "2.8.8", "prettier-plugin-css-order": "^1.3.1", "prettier-plugin-organize-imports": "^3.2.3", From 75f59471f1cb00a0ccb76da436a72ea7a20fc359 Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:01:43 +0200 Subject: [PATCH 10/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content/content.ts | 2 +- src/options/options.ts | 4 ++-- src/options/page.html | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/content/content.ts b/src/content/content.ts index 204a7def..933f4252 100644 --- a/src/content/content.ts +++ b/src/content/content.ts @@ -38,7 +38,7 @@ function onStoreReady() { }; window.postMessage({ type: "PageScriptMessage", - message: message, + message, }); // Clear stats for stream on page load/reload. clearStats(); diff --git a/src/options/options.ts b/src/options/options.ts index 4eae1565..12592801 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -28,7 +28,7 @@ type ListOptions = { //#endregion //#region HTML Elements -// Proxy Usher requests +// Proxy settings const proxyUsherRequestsCheckboxElement = $( "#proxy-usher-requests-checkbox" ) as HTMLInputElement; @@ -90,7 +90,7 @@ if (store.readyState === "complete") main(); else store.addEventListener("load", main); function main() { - // Proxy Usher requests + // Proxy settings proxyUsherRequestsCheckboxElement.checked = store.state.proxyUsherRequests; proxyUsherRequestsCheckboxElement.addEventListener("change", () => { const checked = proxyUsherRequestsCheckboxElement.checked; diff --git a/src/options/page.html b/src/options/page.html index 2a1d666a..1dd6baf1 100644 --- a/src/options/page.html +++ b/src/options/page.html @@ -90,10 +90,13 @@

    Passport

    id="anonymous-mode-checkbox" />
    - Browse Twitch as if you were logged out. + + Watch streams as if you were logged out. This option removes + authentication headers from requests to Twitch. +
  • Expiration date: 2038-01-19T03:14:07.000Z @@ -127,8 +130,8 @@

    Proxies

    @@ -136,7 +139,7 @@

    Proxies

      - +
        From 0e62db4f3ab805c8e037788957645530ca59cea0 Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:56:43 +0200 Subject: [PATCH 11/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content/content.ts | 4 +++- src/page/getFetch.ts | 28 +++++++--------------------- src/page/page.ts | 27 ++++++++++++++++++++------- src/page/worker.ts | 9 +++++++-- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/content/content.ts b/src/content/content.ts index 933f4252..cf88d258 100644 --- a/src/content/content.ts +++ b/src/content/content.ts @@ -1,5 +1,6 @@ import pageScriptURL from "url:../page/page.ts"; import workerScriptURL from "url:../page/worker.ts"; +import isChromium from "../common/ts/isChromium"; import { twitchChannelNameRegex } from "../common/ts/regexes"; import { getStreamStatus, setStreamStatus } from "../common/ts/streamStatus"; import store from "../store"; @@ -18,7 +19,8 @@ function injectPageScript() { const script = document.createElement("script"); script.src = pageScriptURL; // src/page/page.ts script.dataset.params = JSON.stringify({ - workerScriptURL: workerScriptURL, // src/page/worker.ts + isChromium, + workerScriptURL, // src/page/worker.ts }); script.onload = () => script.remove(); // --------------------------------------- diff --git a/src/page/getFetch.ts b/src/page/getFetch.ts index e85b142d..f4e67a02 100644 --- a/src/page/getFetch.ts +++ b/src/page/getFetch.ts @@ -15,6 +15,7 @@ const IS_CHROMIUM = !!self.chrome; export interface FetchOptions { scope: "page" | "worker"; + shouldWaitForStore: boolean; state?: State; } @@ -24,26 +25,11 @@ export function getFetch(options: FetchOptions): typeof fetch { const videoWeaverUrlsToFlag = new Map(); // Video Weaver URLs to flag -> number of times flagged. const videoWeaverUrlsToIgnore = new Set(); // No response check. - let shouldWaitForStore = true; - setTimeout(() => { - shouldWaitForStore = false; - }, 3000); - - self.addEventListener("message", event => { - if ( - (event.data?.type === "PageScriptMessage" && options.scope === "page") || - (event.data?.type === "WorkerScriptMessage" && options.scope === "worker") - ) { - const message = event.data.message; - if (message.type === "StoreReady") { - console.log( - "[TTV LOL PRO] πŸ“¦ Received store state from content script." - ); - options.state = message.state; - shouldWaitForStore = false; - } - } - }); + if (options.shouldWaitForStore) { + setTimeout(() => { + options.shouldWaitForStore = false; + }, 3000); + } return async function fetch( input: RequestInfo | URL, @@ -101,7 +87,7 @@ export function getFetch(options: FetchOptions): typeof fetch { console.debug( "[TTV LOL PRO] πŸ₯… Caught GraphQL PlaybackAccessToken_Template request. Flagging…" ); - while (shouldWaitForStore) await sleep(100); + while (options.shouldWaitForStore) await sleep(100); if (options.state?.anonymousMode) { console.log("[TTV LOL PRO] ❓ Acting as anonymous user"); setHeaderToMap(headersMap, "Authorization", "undefined"); diff --git a/src/page/page.ts b/src/page/page.ts index 9aa24ddc..6e005f42 100644 --- a/src/page/page.ts +++ b/src/page/page.ts @@ -1,10 +1,14 @@ -import { getFetch } from "./getFetch"; +import { FetchOptions, getFetch } from "./getFetch"; console.info("[TTV LOL PRO] πŸš€ Page script running."); const params = JSON.parse(document.currentScript!.dataset.params!); +const options: FetchOptions = { + scope: "page", + shouldWaitForStore: params.isChromium === false, +}; -window.fetch = getFetch({ scope: "page" }); +window.fetch = getFetch(options); window.Worker = class Worker extends window.Worker { constructor(scriptURL: string | URL, options?: WorkerOptions) { @@ -48,12 +52,21 @@ window.Worker = class Worker extends window.Worker { window.postMessage(event.data.message); } }); - window.addEventListener("message", event => { - if (event.data?.type === "WorkerScriptMessage") { - this.postMessage(event.data.message); - } - }); } }; +window.addEventListener("message", event => { + if (event.data?.type === "PageScriptMessage") { + const message = event.data.message; + if (message.type === "StoreReady") { + console.log( + "[TTV LOL PRO] πŸ“¦ Page received store state from content script." + ); + // Mutate the options object. + options.state = message.state; + options.shouldWaitForStore = false; + } + } +}); + document.currentScript!.remove(); diff --git a/src/page/worker.ts b/src/page/worker.ts index ceab7053..5ea2287b 100644 --- a/src/page/worker.ts +++ b/src/page/worker.ts @@ -1,5 +1,10 @@ -import { getFetch } from "./getFetch"; +import { FetchOptions, getFetch } from "./getFetch"; console.info("[TTV LOL PRO] πŸš€ Worker script running."); -self.fetch = getFetch({ scope: "worker" }); +const options: FetchOptions = { + scope: "worker", + shouldWaitForStore: false, +}; + +self.fetch = getFetch(options); From 74851623b23a7bbd9f0c2e3b5ad4525049bdbaa8 Mon Sep 17 00:00:00 2001 From: Younes Aassila <47226184+younesaassila@users.noreply.github.com> Date: Sun, 24 Sep 2023 16:26:29 +0200 Subject: [PATCH 12/42] =?UTF-8?q?=E2=9C=A8=20Add=20#240?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/popup/menu.html | 10 +++++++-- src/popup/popup.ts | 49 +++++++++++++++++++++++++++++++-------------- src/popup/style.css | 12 +++++------ 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/popup/menu.html b/src/popup/menu.html index b4b2cf38..c870de57 100644 --- a/src/popup/menu.html +++ b/src/popup/menu.html @@ -9,14 +9,20 @@ - -
        + +

        Twitch ads are not being blocked!

        No proxies have been added to the extension. Add proxies in the options page.
        +
        +

        You are using a limited proxy!

        + The proxy you are using has a limited number of simultaneous connections. + This means that you may experience buffering issues. Consider donating to + get access to unlimited proxies. +
        diff --git a/src/popup/popup.ts b/src/popup/popup.ts index 4930262a..4119324c 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -5,13 +5,21 @@ import { anonymizeIpAddress, anonymizeIpAddresses, } from "../common/ts/anonymizeIpAddress"; +import getProxyInfoFromUrl from "../common/ts/getProxyInfoFromUrl"; import isChromium from "../common/ts/isChromium"; import { twitchChannelNameRegex } from "../common/ts/regexes"; import store from "../store"; import type { StreamStatus } from "../types"; +type WarningBannerType = "noProxies" | "limitedProxy"; + //#region HTML Elements -const warningBannerElement = $("#warning-banner") as HTMLDivElement; +const warningBannerNoProxiesElement = $( + "#warning-banner-no-proxies" +) as HTMLDivElement; +const warningBannerLimitedProxyElement = $( + "#warning-banner-limited-proxy" +) as HTMLDivElement; const streamStatusElement = $("#stream-status") as HTMLDivElement; const proxiedElement = $("#proxied") as HTMLDivElement; const channelNameElement = $("#channel-name") as HTMLHeadingElement; @@ -31,20 +39,21 @@ if (store.readyState === "complete") main(); else store.addEventListener("load", main); async function main() { - if (isChromium && store.state.normalProxies.length === 0) { - warningBannerElement.style.display = "block"; - } else if ( - !isChromium && - store.state.optimizedProxiesEnabled && - store.state.optimizedProxies.length === 0 - ) { - warningBannerElement.style.display = "block"; - } else if ( - !isChromium && - !store.state.optimizedProxiesEnabled && - store.state.normalProxies.length === 0 - ) { - warningBannerElement.style.display = "block"; + let proxies: string[]; + if (isChromium) { + proxies = store.state.normalProxies; + } else { + proxies = store.state.optimizedProxiesEnabled + ? store.state.optimizedProxies + : store.state.normalProxies; + } + const isLimitedProxy = + proxies.length > 0 && + getProxyInfoFromUrl(proxies[0]).host === "chrome.api.cdn-perfprod.com"; + if (proxies.length === 0) { + setWarningBanner("noProxies"); + } else if (isLimitedProxy) { + setWarningBanner("limitedProxy"); } const tabs = await browser.tabs.query({ active: true, currentWindow: true }); @@ -60,6 +69,16 @@ async function main() { store.addEventListener("change", () => setStreamStatusElement(channelName)); } +function setWarningBanner(type: WarningBannerType) { + if (type === "noProxies") { + warningBannerNoProxiesElement.style.display = "block"; + warningBannerLimitedProxyElement.style.display = "none"; + } else if (type === "limitedProxy") { + warningBannerNoProxiesElement.style.display = "none"; + warningBannerLimitedProxyElement.style.display = "block"; + } +} + function setStreamStatusElement(channelName: string) { const channelNameLower = channelName.toLowerCase(); const status = store.state.streamStatuses[channelNameLower]; diff --git a/src/popup/style.css b/src/popup/style.css index a1db56f0..a77e90c4 100644 --- a/src/popup/style.css +++ b/src/popup/style.css @@ -48,7 +48,7 @@ main > * { /* Warning banner */ -#warning-banner { +.warning-banner { display: none; margin: 3px 3px 0 3px; padding: 15px; @@ -59,20 +59,20 @@ main > * { font-size: 9pt; } -#warning-banner .warning-banner-title { +.warning-banner .warning-banner-title { margin: 0 0 2px 0; font-weight: bold; font-size: 11pt; } -#warning-banner .warning-banner-link, -#warning-banner .warning-banner-link:visited { +.warning-banner .warning-banner-link, +.warning-banner .warning-banner-link:visited { color: currentColor; transition: opacity 100ms ease-in-out; } -#warning-banner .warning-banner-link:hover, -#warning-banner .warning-banner-link:hover:visited { +.warning-banner .warning-banner-link:hover, +.warning-banner .warning-banner-link:hover:visited { color: currentColor; opacity: 0.8; } From b4f65bba5ccbba529b6c00cf748f6b9b6104b011 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:35:21 +0200 Subject: [PATCH 13/42] =?UTF-8?q?=E2=9C=A8=20Add=20#257?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onBeforeVideoWeaverRequest.ts | 11 +++++++++-- src/background/handlers/onProxyRequest.ts | 7 ++++++- src/background/handlers/onResponseStarted.ts | 7 ++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/background/handlers/onBeforeVideoWeaverRequest.ts b/src/background/handlers/onBeforeVideoWeaverRequest.ts index 9768f893..6782ecd1 100644 --- a/src/background/handlers/onBeforeVideoWeaverRequest.ts +++ b/src/background/handlers/onBeforeVideoWeaverRequest.ts @@ -2,7 +2,10 @@ import { WebRequest } from "webextension-polyfill"; import filterResponseDataWrapper from "../../common/ts/filterResponseDataWrapper"; import findChannelFromVideoWeaverUrl from "../../common/ts/findChannelFromVideoWeaverUrl"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; -import { videoWeaverHostRegex } from "../../common/ts/regexes"; +import { + twitchChannelNameRegex, + videoWeaverHostRegex, +} from "../../common/ts/regexes"; import store from "../../store"; import { AdType, ProxyInfo } from "../../types"; @@ -26,7 +29,11 @@ export default function onBeforeVideoWeaverRequest( if (isAd || isMidroll) { const adType: AdType = isMidroll ? AdType.MIDROLL : AdType.PREROLL; - const channel = findChannelFromVideoWeaverUrl(details.url); + let channel = findChannelFromVideoWeaverUrl(details.url); + if (!channel && details.documentUrl) { + const match = twitchChannelNameRegex.exec(details.documentUrl); + if (match) channel = match[1]; + } const isPurpleScreen = textLower.includes( "https://help.twitch.tv/s/article/ad-experience-on-twitch" ); diff --git a/src/background/handlers/onProxyRequest.ts b/src/background/handlers/onProxyRequest.ts index a73bf9f2..fb6cbbc1 100644 --- a/src/background/handlers/onProxyRequest.ts +++ b/src/background/handlers/onProxyRequest.ts @@ -7,6 +7,7 @@ import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isFlaggedRequest from "../../common/ts/isFlaggedRequest"; import { passportHostRegex, + twitchChannelNameRegex, twitchGqlHostRegex, twitchTvHostRegex, usherHostRegex, @@ -90,7 +91,11 @@ export default async function onProxyRequest( // Video Weaver requests. if (videoWeaverHostRegex.test(host) && isFlagged) { // Don't proxy whitelisted channels. - const channelName = findChannelFromVideoWeaverUrl(details.url); + let channelName = findChannelFromVideoWeaverUrl(details.url); + if (!channelName && details.documentUrl) { + const match = twitchChannelNameRegex.exec(details.documentUrl); + if (match) channelName = match[1]; + } if (isChannelWhitelisted(channelName)) { console.log(`βœ‹ Channel '${channelName}' is whitelisted.`); return { type: "direct" }; diff --git a/src/background/handlers/onResponseStarted.ts b/src/background/handlers/onResponseStarted.ts index df121a76..94fbab4e 100644 --- a/src/background/handlers/onResponseStarted.ts +++ b/src/background/handlers/onResponseStarted.ts @@ -5,6 +5,7 @@ import getProxyInfoFromUrl from "../../common/ts/getProxyInfoFromUrl"; import isChromium from "../../common/ts/isChromium"; import { passportHostRegex, + twitchChannelNameRegex, twitchGqlHostRegex, twitchTvHostRegex, usherHostRegex, @@ -48,7 +49,11 @@ export default function onResponseStarted( // Video-weaver requests. if (videoWeaverHostRegex.test(host)) { - const channelName = findChannelFromVideoWeaverUrl(details.url); + let channelName = findChannelFromVideoWeaverUrl(details.url); + if (!channelName && details.documentUrl) { + const match = twitchChannelNameRegex.exec(details.documentUrl); + if (match) channelName = match[1]; + } const streamStatus = getStreamStatus(channelName); const stats = streamStatus?.stats ?? { proxied: 0, notProxied: 0 }; if (!proxy) { From 2c9ad866f28c66451062e4fcad825395d7548866 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:37:34 +0200 Subject: [PATCH 14/42] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20dependenci?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 156 +++++++++++++++++++++++----------------------- package.json | 6 +- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/package-lock.json b/package-lock.json index 02dd6f27..82f3d994 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,12 +15,12 @@ "devDependencies": { "@parcel/config-webextension": "^2.9.3", "@types/chrome": "^0.0.246", - "@types/ip": "^1.1.0", - "@types/webextension-polyfill": "^0.10.3", + "@types/ip": "^1.1.1", + "@types/webextension-polyfill": "^0.10.4", "buffer": "^6.0.3", "os-browserify": "^0.3.0", "parcel": "^2.9.3", - "postcss": "^8.4.30", + "postcss": "^8.4.31", "prettier": "2.8.8", "prettier-plugin-css-order": "^1.3.1", "prettier-plugin-organize-imports": "^3.2.3", @@ -1940,9 +1940,9 @@ } }, "node_modules/@swc/core": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.88.tgz", - "integrity": "sha512-kaJ5t6Fg/DmJPNeI+jdtCEt7NVKxhUYToq7PF2fMRPFPLKSJzJCZajcp6/gZNcEUCVWaK6pWi/XL79Tzz1FqzQ==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.91.tgz", + "integrity": "sha512-r950d0fdlZ8qbSDyvApn3HyCojiZE8xpgJzQvypeMi32dalYwugdJKWyLB55JIGMRGJ8+lmVvY4MPGkSR3kXgA==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -1957,16 +1957,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.88", - "@swc/core-darwin-x64": "1.3.88", - "@swc/core-linux-arm-gnueabihf": "1.3.88", - "@swc/core-linux-arm64-gnu": "1.3.88", - "@swc/core-linux-arm64-musl": "1.3.88", - "@swc/core-linux-x64-gnu": "1.3.88", - "@swc/core-linux-x64-musl": "1.3.88", - "@swc/core-win32-arm64-msvc": "1.3.88", - "@swc/core-win32-ia32-msvc": "1.3.88", - "@swc/core-win32-x64-msvc": "1.3.88" + "@swc/core-darwin-arm64": "1.3.91", + "@swc/core-darwin-x64": "1.3.91", + "@swc/core-linux-arm-gnueabihf": "1.3.91", + "@swc/core-linux-arm64-gnu": "1.3.91", + "@swc/core-linux-arm64-musl": "1.3.91", + "@swc/core-linux-x64-gnu": "1.3.91", + "@swc/core-linux-x64-musl": "1.3.91", + "@swc/core-win32-arm64-msvc": "1.3.91", + "@swc/core-win32-ia32-msvc": "1.3.91", + "@swc/core-win32-x64-msvc": "1.3.91" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -1978,9 +1978,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.88.tgz", - "integrity": "sha512-Nb7kKydSQK3FE90pw/GPRFmAkquDQcTixLijNcki2xFBXh/DcGdFUPE/GShQjk8gtQelj2vqZrsGs/GZPGA1mA==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.91.tgz", + "integrity": "sha512-7kHGiQ1he5khcEeJuHDmLZPM3rRL/ith5OTmV6bOPsoHi46kLeixORW+ts1opC3tC9vu6xbk16xgX0QAJchc1w==", "cpu": [ "arm64" ], @@ -1994,9 +1994,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.88.tgz", - "integrity": "sha512-RcCrnjkmLXL1izSHPYLaJKVaxwd64LYiYLqjX2jXG4U50D6LOlmuLeqTJ8aAnENZP19gNpsY9ggY9jD5UQqHAw==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.91.tgz", + "integrity": "sha512-8SpU18FbFpZDVzsHsAwdI1thF/picQGxq9UFxa8W+T9SDnbsqwFJv/6RqKJeJoDV6qFdl2OLjuO0OL7xrp0qnQ==", "cpu": [ "x64" ], @@ -2010,9 +2010,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.88.tgz", - "integrity": "sha512-/H7QhpgbWX4xe6jbkgPrhjY543oCCmbPRvBMvZ3iuLb81bEtOFiEp9LYe/95ZW/BTz2z9a6fQtQMqkhAjcrV5w==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.91.tgz", + "integrity": "sha512-fOq4Cy8UbwX1yf0WB0d8hWZaIKCnPtPGguRqdXGLfwvhjZ9SIErT6PnmGTGRbQCNCIkOZWHKyTU0r8t2dN3haQ==", "cpu": [ "arm" ], @@ -2026,9 +2026,9 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.88.tgz", - "integrity": "sha512-ar/oQJxisjn/Su9rsg+XcBqA54Ylh1SyrZiLslv37OnGr785Xw+C//rw+JGoFmCZSjhGAU5hriOiHJd2S8mtqA==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.91.tgz", + "integrity": "sha512-fki4ioRP/Esy4vdp8T34RCV+V9dqkRmOt763pf74pdiyFV2dPLXa5lnw/XvR1RTfPGknrYgjEQLCfZlReTryRw==", "cpu": [ "arm64" ], @@ -2042,9 +2042,9 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.88.tgz", - "integrity": "sha512-ZyUtCk1Y4GpOajbHcnm2JwkFm/m8M/wP3I8iaAm/0yAPIYwQInVdD0Hn++eig2Y+nLJ7gT0QI82fFUDPEIP6Jw==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.91.tgz", + "integrity": "sha512-XrG+DUUqNtfVLcJ20imby7fpBwQNG5VsEQBzQndSonPyUOa2YkTbBb60YDondfQGDABopuHH8gHN8o2H2/VCnQ==", "cpu": [ "arm64" ], @@ -2058,9 +2058,9 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.88.tgz", - "integrity": "sha512-VrwGCzKLwimL0Js1yWRQNpcJCLGYkETku9mEI9sM4yF6kzT/jwfOe94udBe9O4GGUv24QkzHXRk+EnGR2LFSOQ==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.91.tgz", + "integrity": "sha512-d11bYhX+YPBr/Frcjc6eVn3C0LuS/9U1Li9EmQ+6s9EpYtYRl2ygSlC8eueLbaiazBnCVYFnc8bU4o0kc5B9sw==", "cpu": [ "x64" ], @@ -2074,9 +2074,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.88.tgz", - "integrity": "sha512-cur5h0JmNfF4ZHb+FBPLePX86lu3FUjxltObWUhqO4QiXzHxWfde6g+pgdqfUAer0cd9VEEjEKGA5OQncXqyCQ==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.91.tgz", + "integrity": "sha512-2SRp5Dke2P4jCQePkDx9trkkTstnRpZJVw5r3jvYdk0zeO6iC4+ZPvvoWXJLigqQv/fZnIiSUfJ6ssOoaEqTzQ==", "cpu": [ "x64" ], @@ -2090,9 +2090,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.88.tgz", - "integrity": "sha512-f9OVuWrey7X0gjCZlVD4d5/9/d0yyxu8KFUOEjyjJ2Kd+pvzRys1U3E0FE1PiiDOng3qrfdOt4HQxyAy2jts9Q==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.91.tgz", + "integrity": "sha512-l9qKXikOxj42UIjbeZpz9xtBmr736jOMqInNP8mVF2/U+ws5sI8zJjcOFFtfis4ru7vWCXhB1wtltdlJYO2vGA==", "cpu": [ "arm64" ], @@ -2106,9 +2106,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.88.tgz", - "integrity": "sha512-7KCeTVe8wWRbuiuAwXoHKBkr9nugCAHQe/JGxoevHXxn2h+WwBuWHog1AbS6PvRWSKK8dVhKAAPDNWwdEltA5A==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.91.tgz", + "integrity": "sha512-+s+52O0QVPmzOgjEe/rcb0AK6q/J7EHKwAyJCu/FaYO9df5ovE0HJjSKP6HAF0dGPO5hkENrXuNGujofUH9vtQ==", "cpu": [ "ia32" ], @@ -2122,9 +2122,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.3.88", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.88.tgz", - "integrity": "sha512-x0wr9kCS2Hmpx7H6gvJHA17G0DnvwToqWDSO1VmePt5hQZZfLzxiHHDHKFv4YYsVPbAU283q4Wa39QSPZeJbTA==", + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.91.tgz", + "integrity": "sha512-7u9HDQhjUC3Gv43EFW84dZtduWCSa4MgltK+Sp9zEGti6WXqDPu/ESjvDsQEVYTBEMEvZs/xVAXPgLVHorV5nQ==", "cpu": [ "x64" ], @@ -2138,9 +2138,9 @@ } }, "node_modules/@swc/counter": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.1.tgz", - "integrity": "sha512-xVRaR4u9hcYjFvcSg71Lz5Bo4//CyjAAfMxa7UsaDSYxAshflUkVJWiyVWrfxC59z2kP1IzI4/1BEpnhI9o3Mw==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz", + "integrity": "sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==", "dev": true }, "node_modules/@swc/helpers": { @@ -2199,24 +2199,24 @@ "dev": true }, "node_modules/@types/ip": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@types/ip/-/ip-1.1.0.tgz", - "integrity": "sha512-dwNe8gOoF70VdL6WJBwVHtQmAX4RMd62M+mAB9HQFjG1/qiCLM/meRy95Pd14FYBbEDwCq7jgJs89cHpLBu4HQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/ip/-/ip-1.1.1.tgz", + "integrity": "sha512-/v+XZuKNBQHJi3dKeFt9LySLzWNkgmaYRtnFfg27Ag0MO9tQLzHUuAA8zOhPtbDvDGkcnZGr4pVZQPGNft/WYA==", "dev": true, "dependencies": { "@types/node": "*" } }, "node_modules/@types/node": { - "version": "20.6.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.4.tgz", - "integrity": "sha512-nU6d9MPY0NBUMiE/nXd2IIoC4OLvsLpwAjheoAeuzgvDZA1Cb10QYg+91AF6zQiKWRN5i1m07x6sMe0niBznoQ==", + "version": "20.8.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz", + "integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==", "dev": true }, "node_modules/@types/webextension-polyfill": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.3.tgz", - "integrity": "sha512-7RqGPhr+Ib7IKrOIeXRTB2TVojq/bMRieoYVfgHoicQ+VvI6OOzBNF0fZXA+5JVJIEtfE/o426S+bMgg/XhvXg==", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.10.4.tgz", + "integrity": "sha512-pvEIqAZEbJRzaqTaWq3xlUoMWa3+euZHHz+VZHCzHWW+jOf8qLOq9wXy38U+WiPG3108SJC/wNc1X6vPC5TcjQ==", "dev": true }, "node_modules/abortcontroller-polyfill": { @@ -2315,9 +2315,9 @@ } }, "node_modules/browserslist": { - "version": "4.21.11", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.11.tgz", - "integrity": "sha512-xn1UXOKUz7DjdGlg9RrUr0GGiWzI97UQJnugHtH0OLDfJB7jMgoIkYvRIEO1l9EeEERVqeqLYOcFBW9ldjypbQ==", + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", + "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "dev": true, "funding": [ { @@ -2334,8 +2334,8 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001538", - "electron-to-chromium": "^1.4.526", + "caniuse-lite": "^1.0.30001541", + "electron-to-chromium": "^1.4.535", "node-releases": "^2.0.13", "update-browserslist-db": "^1.0.13" }, @@ -2380,9 +2380,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001538", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", - "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==", + "version": "1.0.30001542", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001542.tgz", + "integrity": "sha512-UrtAXVcj1mvPBFQ4sKd38daP8dEcXXr5sQe6QNNinaPd0iA/cxg9/l3VrSdL73jgw5sKyuQ6jNgiKO12W3SsVA==", "dev": true, "funding": [ { @@ -2502,9 +2502,9 @@ } }, "node_modules/css-declaration-sorter": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-7.1.0.tgz", - "integrity": "sha512-suZ/qn6r4iXWLGOlD34EfYCCZxq18KXC/OYIyPHUnV3MHl3JO9LmcaVFHpgbHwfg+SayGOpXURJIs3aJpxcjyA==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-7.1.1.tgz", + "integrity": "sha512-dZ3bVTEEc1vxr3Bek9vGwfB5Z6ESPULhcRvO472mfjVnj8jRcTnKO8/JTczlvxM10Myb+wBM++1MtdO76eWcaQ==", "dev": true, "engines": { "node": "^14 || ^16 || >=18" @@ -2752,9 +2752,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.528", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.528.tgz", - "integrity": "sha512-UdREXMXzLkREF4jA8t89FQjA8WHI6ssP38PMY4/4KhXFQbtImnghh4GkCgrtiZwLKUKVD2iTVXvDVQjfomEQuA==", + "version": "1.4.539", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.539.tgz", + "integrity": "sha512-wRmWJ8F7rgmINuI32S6r2SLrw/h/bJQsDSvBiq9GBfvc2Lh73qTOwn73r3Cf67mjVgFGJYcYtmERzySa5jIWlg==", "dev": true }, "node_modules/entities": { @@ -3642,9 +3642,9 @@ } }, "node_modules/postcss": { - "version": "8.4.30", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.30.tgz", - "integrity": "sha512-7ZEao1g4kd68l97aWG/etQKPKq07us0ieSZ2TnFDk11i0ZfDW2AwKHYU8qv4MZKqN2fdBfg+7q0ES06UA73C1g==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "dev": true, "funding": [ { @@ -3682,9 +3682,9 @@ } }, "node_modules/postcss-scss": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/postcss-scss/-/postcss-scss-4.0.8.tgz", - "integrity": "sha512-Cr0X8Eu7xMhE96PJck6ses/uVVXDtE5ghUTKNUYgm8ozgP2TkgV3LWs3WgLV1xaSSLq8ZFiXaUrj0LVgG1fGEA==", + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/postcss-scss/-/postcss-scss-4.0.9.tgz", + "integrity": "sha512-AjKOeiwAitL/MXxQW2DliT28EKukvvbEWx3LBmJIRN8KfBGZbRTxNYW0kSqi1COiTZ57nZ9NW06S6ux//N1c9A==", "dev": true, "funding": [ { diff --git a/package.json b/package.json index 2d64a8f8..db0806bb 100644 --- a/package.json +++ b/package.json @@ -48,12 +48,12 @@ "devDependencies": { "@parcel/config-webextension": "^2.9.3", "@types/chrome": "^0.0.246", - "@types/ip": "^1.1.0", - "@types/webextension-polyfill": "^0.10.3", + "@types/ip": "^1.1.1", + "@types/webextension-polyfill": "^0.10.4", "buffer": "^6.0.3", "os-browserify": "^0.3.0", "parcel": "^2.9.3", - "postcss": "^8.4.30", + "postcss": "^8.4.31", "prettier": "2.8.8", "prettier-plugin-css-order": "^1.3.1", "prettier-plugin-organize-imports": "^3.2.3", From 08148c99052ec574bfe06af0b5333b6bbb35f421 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:25:15 +0200 Subject: [PATCH 15/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/onBeforeVideoWeaverRequest.ts | 14 +++++--------- src/background/handlers/onProxyRequest.ts | 19 +++++++++++++------ src/background/handlers/onResponseStarted.ts | 10 ++++------ src/common/ts/findChannelFromTwitchTvUrl.ts | 17 +++++++++++++++++ src/content/content.ts | 12 +++++------- src/popup/popup.ts | 6 ++---- 6 files changed, 46 insertions(+), 32 deletions(-) create mode 100644 src/common/ts/findChannelFromTwitchTvUrl.ts diff --git a/src/background/handlers/onBeforeVideoWeaverRequest.ts b/src/background/handlers/onBeforeVideoWeaverRequest.ts index 6782ecd1..122bf3b5 100644 --- a/src/background/handlers/onBeforeVideoWeaverRequest.ts +++ b/src/background/handlers/onBeforeVideoWeaverRequest.ts @@ -1,11 +1,9 @@ import { WebRequest } from "webextension-polyfill"; import filterResponseDataWrapper from "../../common/ts/filterResponseDataWrapper"; +import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; import findChannelFromVideoWeaverUrl from "../../common/ts/findChannelFromVideoWeaverUrl"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; -import { - twitchChannelNameRegex, - videoWeaverHostRegex, -} from "../../common/ts/regexes"; +import { videoWeaverHostRegex } from "../../common/ts/regexes"; import store from "../../store"; import { AdType, ProxyInfo } from "../../types"; @@ -29,11 +27,9 @@ export default function onBeforeVideoWeaverRequest( if (isAd || isMidroll) { const adType: AdType = isMidroll ? AdType.MIDROLL : AdType.PREROLL; - let channel = findChannelFromVideoWeaverUrl(details.url); - if (!channel && details.documentUrl) { - const match = twitchChannelNameRegex.exec(details.documentUrl); - if (match) channel = match[1]; - } + const channel = + findChannelFromVideoWeaverUrl(details.url) ?? + findChannelFromTwitchTvUrl(details.documentUrl); const isPurpleScreen = textLower.includes( "https://help.twitch.tv/s/article/ad-experience-on-twitch" ); diff --git a/src/background/handlers/onProxyRequest.ts b/src/background/handlers/onProxyRequest.ts index fb6cbbc1..dd51ac32 100644 --- a/src/background/handlers/onProxyRequest.ts +++ b/src/background/handlers/onProxyRequest.ts @@ -1,4 +1,5 @@ import { Proxy } from "webextension-polyfill"; +import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; import findChannelFromUsherUrl from "../../common/ts/findChannelFromUsherUrl"; import findChannelFromVideoWeaverUrl from "../../common/ts/findChannelFromVideoWeaverUrl"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; @@ -7,7 +8,6 @@ import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isFlaggedRequest from "../../common/ts/isFlaggedRequest"; import { passportHostRegex, - twitchChannelNameRegex, twitchGqlHostRegex, twitchTvHostRegex, usherHostRegex, @@ -72,6 +72,15 @@ export default async function onProxyRequest( return proxyInfoArray; } + const documentHost = details.documentUrl + ? getHostFromUrl(details.documentUrl) + : null; + if (documentHost && !twitchTvHostRegex.test(documentHost)) { + // Don't proxy Usher and Video Weaver requests from non-supported websites. + console.log(`βœ‹ '${documentHost}' is not supported.`); + return { type: "direct" }; + } + // Usher requests. if (store.state.proxyUsherRequests && usherHostRegex.test(host)) { // Don't proxy whitelisted channels. @@ -91,11 +100,9 @@ export default async function onProxyRequest( // Video Weaver requests. if (videoWeaverHostRegex.test(host) && isFlagged) { // Don't proxy whitelisted channels. - let channelName = findChannelFromVideoWeaverUrl(details.url); - if (!channelName && details.documentUrl) { - const match = twitchChannelNameRegex.exec(details.documentUrl); - if (match) channelName = match[1]; - } + const channelName = + findChannelFromVideoWeaverUrl(details.url) ?? + findChannelFromTwitchTvUrl(details.documentUrl); if (isChannelWhitelisted(channelName)) { console.log(`βœ‹ Channel '${channelName}' is whitelisted.`); return { type: "direct" }; diff --git a/src/background/handlers/onResponseStarted.ts b/src/background/handlers/onResponseStarted.ts index 94fbab4e..f70a2c51 100644 --- a/src/background/handlers/onResponseStarted.ts +++ b/src/background/handlers/onResponseStarted.ts @@ -1,11 +1,11 @@ import { WebRequest } from "webextension-polyfill"; +import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; import findChannelFromVideoWeaverUrl from "../../common/ts/findChannelFromVideoWeaverUrl"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; import getProxyInfoFromUrl from "../../common/ts/getProxyInfoFromUrl"; import isChromium from "../../common/ts/isChromium"; import { passportHostRegex, - twitchChannelNameRegex, twitchGqlHostRegex, twitchTvHostRegex, usherHostRegex, @@ -49,11 +49,9 @@ export default function onResponseStarted( // Video-weaver requests. if (videoWeaverHostRegex.test(host)) { - let channelName = findChannelFromVideoWeaverUrl(details.url); - if (!channelName && details.documentUrl) { - const match = twitchChannelNameRegex.exec(details.documentUrl); - if (match) channelName = match[1]; - } + const channelName = + findChannelFromVideoWeaverUrl(details.url) ?? + findChannelFromTwitchTvUrl(details.documentUrl); const streamStatus = getStreamStatus(channelName); const stats = streamStatus?.stats ?? { proxied: 0, notProxied: 0 }; if (!proxy) { diff --git a/src/common/ts/findChannelFromTwitchTvUrl.ts b/src/common/ts/findChannelFromTwitchTvUrl.ts new file mode 100644 index 00000000..dba40715 --- /dev/null +++ b/src/common/ts/findChannelFromTwitchTvUrl.ts @@ -0,0 +1,17 @@ +import { twitchChannelNameRegex } from "./regexes"; + +/** + * Returns the channel name from a Twitch.tv URL. + * Returns `null` if the URL is not a valid Twitch.tv URL. + * @param twitchTvUrl + * @returns + */ +export default function findChannelFromTwitchTvUrl( + twitchTvUrl: string | undefined +): string | null { + if (!twitchTvUrl) return null; + const match = twitchChannelNameRegex.exec(twitchTvUrl); + if (!match) return null; + const [, channelName] = match; + return channelName; +} diff --git a/src/content/content.ts b/src/content/content.ts index cf88d258..d19bb7e7 100644 --- a/src/content/content.ts +++ b/src/content/content.ts @@ -1,7 +1,7 @@ import pageScriptURL from "url:../page/page.ts"; import workerScriptURL from "url:../page/worker.ts"; +import findChannelFromTwitchTvUrl from "../common/ts/findChannelFromTwitchTvUrl"; import isChromium from "../common/ts/isChromium"; -import { twitchChannelNameRegex } from "../common/ts/regexes"; import { getStreamStatus, setStreamStatus } from "../common/ts/streamStatus"; import store from "../store"; @@ -52,13 +52,11 @@ function onStoreReady() { */ function clearStats() { // TODO: Clear stats on navigation. - const match = twitchChannelNameRegex.exec(location.href); - if (!match) return; - const [, streamId] = match; - if (!streamId) return; + const channelName = findChannelFromTwitchTvUrl(location.href); + if (!channelName) return; - if (store.state.streamStatuses.hasOwnProperty(streamId)) { - store.state.streamStatuses[streamId].stats = { + if (store.state.streamStatuses.hasOwnProperty(channelName)) { + store.state.streamStatuses[channelName].stats = { proxied: 0, notProxied: 0, }; diff --git a/src/popup/popup.ts b/src/popup/popup.ts index 4119324c..bcb531d8 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -5,9 +5,9 @@ import { anonymizeIpAddress, anonymizeIpAddresses, } from "../common/ts/anonymizeIpAddress"; +import findChannelFromTwitchTvUrl from "../common/ts/findChannelFromTwitchTvUrl"; import getProxyInfoFromUrl from "../common/ts/getProxyInfoFromUrl"; import isChromium from "../common/ts/isChromium"; -import { twitchChannelNameRegex } from "../common/ts/regexes"; import store from "../store"; import type { StreamStatus } from "../types"; @@ -60,9 +60,7 @@ async function main() { const activeTab = tabs[0]; if (!activeTab || !activeTab.url) return; - const match = twitchChannelNameRegex.exec(activeTab.url); - if (!match) return; - const [, channelName] = match; + const channelName = findChannelFromTwitchTvUrl(activeTab.url); if (!channelName) return; setStreamStatusElement(channelName); From 14a09ed75d4114417de8f3fd3ab10c63c218b7fa Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:38:12 +0200 Subject: [PATCH 16/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onProxyRequest.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/background/handlers/onProxyRequest.ts b/src/background/handlers/onProxyRequest.ts index dd51ac32..0279d814 100644 --- a/src/background/handlers/onProxyRequest.ts +++ b/src/background/handlers/onProxyRequest.ts @@ -75,14 +75,17 @@ export default async function onProxyRequest( const documentHost = details.documentUrl ? getHostFromUrl(details.documentUrl) : null; - if (documentHost && !twitchTvHostRegex.test(documentHost)) { - // Don't proxy Usher and Video Weaver requests from non-supported websites. - console.log(`βœ‹ '${documentHost}' is not supported.`); - return { type: "direct" }; - } + const isTwitchTvHost = documentHost && twitchTvHostRegex.test(documentHost); // Usher requests. if (store.state.proxyUsherRequests && usherHostRegex.test(host)) { + // Don't proxy Usher requests from non-supported hosts. + if (!isTwitchTvHost) { + console.log( + `βœ‹ '${details.url}' from host '${documentHost}' is not supported.` + ); + return { type: "direct" }; + } // Don't proxy whitelisted channels. const channelName = findChannelFromUsherUrl(details.url); if (isChannelWhitelisted(channelName)) { @@ -99,6 +102,13 @@ export default async function onProxyRequest( // Video Weaver requests. if (videoWeaverHostRegex.test(host) && isFlagged) { + // Don't proxy Video Weaver requests from non-supported hosts. + if (!isTwitchTvHost) { + console.log( + `βœ‹ '${details.url}' from host '${documentHost}' is not supported.` + ); + return { type: "direct" }; + } // Don't proxy whitelisted channels. const channelName = findChannelFromVideoWeaverUrl(details.url) ?? From 5a01157f5b089be5825706ea72283979ed0df07a Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:48:47 +0200 Subject: [PATCH 17/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onProxyRequest.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/background/handlers/onProxyRequest.ts b/src/background/handlers/onProxyRequest.ts index 0279d814..670713ac 100644 --- a/src/background/handlers/onProxyRequest.ts +++ b/src/background/handlers/onProxyRequest.ts @@ -75,12 +75,13 @@ export default async function onProxyRequest( const documentHost = details.documentUrl ? getHostFromUrl(details.documentUrl) : null; - const isTwitchTvHost = documentHost && twitchTvHostRegex.test(documentHost); + const isFromTwitchTvHost = + documentHost && twitchTvHostRegex.test(documentHost); // Usher requests. if (store.state.proxyUsherRequests && usherHostRegex.test(host)) { // Don't proxy Usher requests from non-supported hosts. - if (!isTwitchTvHost) { + if (!isFromTwitchTvHost) { console.log( `βœ‹ '${details.url}' from host '${documentHost}' is not supported.` ); @@ -103,7 +104,7 @@ export default async function onProxyRequest( // Video Weaver requests. if (videoWeaverHostRegex.test(host) && isFlagged) { // Don't proxy Video Weaver requests from non-supported hosts. - if (!isTwitchTvHost) { + if (!isFromTwitchTvHost) { console.log( `βœ‹ '${details.url}' from host '${documentHost}' is not supported.` ); From f372764c92c08479103552c8a78c9549e6e4745c Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:45:44 +0200 Subject: [PATCH 18/42] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20nitpicks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/background.ts | 6 ++--- .../handlers/onProxySettingsChanged.ts | 5 +++-- .../handlers/onStartupStoreCleanup.ts | 2 +- src/background/handlers/onTabCreated.ts | 8 +++---- src/background/handlers/onTabRemoved.ts | 6 ++--- src/background/handlers/onTabUpdated.ts | 22 +++++++++---------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/background/background.ts b/src/background/background.ts index 55397d63..8db61947 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -30,6 +30,9 @@ browser.webRequest.onResponseStarted.addListener(onResponseStarted, { }); if (isChromium) { + // Listen to whether proxy is set or not. + browser.proxy.settings.onChange.addListener(onProxySettingsChange); + // Check if there are any opened Twitch tabs on startup. checkForOpenedTwitchTabs(); @@ -37,9 +40,6 @@ if (isChromium) { browser.tabs.onCreated.addListener(onTabCreated); browser.tabs.onUpdated.addListener(onTabUpdated); browser.tabs.onRemoved.addListener(onTabRemoved); - - // Listen to whether proxy is set or not - chrome.proxy.settings.onChange.addListener(onProxySettingsChange); } else { // Block tracking pixels. browser.webRequest.onBeforeRequest.addListener( diff --git a/src/background/handlers/onProxySettingsChanged.ts b/src/background/handlers/onProxySettingsChanged.ts index 56820405..49735710 100644 --- a/src/background/handlers/onProxySettingsChanged.ts +++ b/src/background/handlers/onProxySettingsChanged.ts @@ -1,9 +1,10 @@ +import { Types } from "webextension-polyfill"; import store from "../../store"; export default function onProxySettingsChange( - details: chrome.types.ChromeSettingGetResultDetails + details: Types.SettingOnChangeDetailsType ) { - console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); + console.log(`βš™οΈ Proxy settings changed: ${details.levelOfControl}`); store.state.chromiumProxyActive = details.levelOfControl == "controlled_by_this_extension"; } diff --git a/src/background/handlers/onStartupStoreCleanup.ts b/src/background/handlers/onStartupStoreCleanup.ts index 3e92d4c7..af1d2c2b 100644 --- a/src/background/handlers/onStartupStoreCleanup.ts +++ b/src/background/handlers/onStartupStoreCleanup.ts @@ -12,9 +12,9 @@ export default function onStartupStoreCleanup(): void { if (store.readyState !== "complete") return store.addEventListener("load", onStartupStoreCleanup); + store.state.chromiumProxyActive = false; store.state.dnsResponses = []; store.state.openedTwitchTabs = []; store.state.streamStatuses = {}; store.state.videoWeaverUrlsByChannel = {}; - store.state.chromiumProxyActive = false; } diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index 71be2b8c..231a6790 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -12,11 +12,11 @@ export default function onTabCreated(tab: Tabs.Tab): void { if (host != null && twitchTvHostRegex.test(host)) { console.log(`βž• Opened Twitch tab: ${tab.id}`); if (isChromium) { - var isNonWhitelistedChannel = true; - const url = new URL(tab.url); - if (url.pathname && url.pathname.length > 0) { + let isNonWhitelistedChannel = true; + const Url = new URL(tab.url); + if (Url.pathname && Url.pathname.length > 0) { isNonWhitelistedChannel = !isChannelWhitelisted( - url.pathname.substring(1) + Url.pathname.substring(1) ); } if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 1a36c954..4da91531 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -21,9 +21,9 @@ export default function onTabRemoved(tabId: number): void { .get(tabId) .then(tab => { if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == "/") return false; - return isChannelWhitelisted(url.pathname.substring(1)); + const Url = new URL(tab.url); + if (!Url.pathname || Url.pathname == "/") return false; + return isChannelWhitelisted(Url.pathname.substring(1)); }) .catch(() => false); }) diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index ee151061..99b3fc50 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -27,12 +27,10 @@ export default function onTabUpdated( if (isTwitchTab && !wasTwitchTab) { console.log(`βž• Opened Twitch tab: ${tabId}`); if (isChromium) { - var isNonWhitelistedPage = true; - const urlObj = new URL(url); - if (urlObj.pathname && urlObj.pathname.length > 0) { - isNonWhitelistedPage = !isChannelWhitelisted( - urlObj.pathname.substring(1) - ); + let isNonWhitelistedPage = true; + const Url = new URL(url); + if (Url.pathname && Url.pathname.length > 0) { + isNonWhitelistedPage = !isChannelWhitelisted(Url.pathname.substring(1)); } if (isNonWhitelistedPage) updateProxySettings(); } @@ -55,9 +53,9 @@ export default function onTabUpdated( .get(tabId) .then(tab => { if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == "/") return false; - return isChannelWhitelisted(url.pathname.substring(1)); + const Url = new URL(tab.url); + if (!Url.pathname || Url.pathname == "/") return false; + return isChannelWhitelisted(Url.pathname.substring(1)); }) .catch(() => false); }) @@ -78,9 +76,9 @@ export default function onTabUpdated( .get(tabId) .then(tab => { if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == "/") return false; - return isChannelWhitelisted(url.pathname.substring(1)); + const Url = new URL(tab.url); + if (!Url.pathname || Url.pathname == "/") return false; + return isChannelWhitelisted(Url.pathname.substring(1)); }) .catch(() => false); }) From 01bd1259e09b08dd75e8f937e9120027284bfe5a Mon Sep 17 00:00:00 2001 From: Luke Fanning Date: Sun, 24 Sep 2023 12:34:31 +0100 Subject: [PATCH 19/42] Whitelisting via tab analysis for chromium --- src/background/background.ts | 4 ++ .../handlers/onProxySettingsChanged.ts | 6 +++ .../handlers/onStartupStoreCleanup.ts | 1 + src/background/handlers/onTabCreated.ts | 10 +++- src/background/handlers/onTabRemoved.ts | 22 +++++++- src/background/handlers/onTabUpdated.ts | 50 +++++++++++++++++-- src/options/options.ts | 4 -- src/popup/popup.ts | 3 -- src/store/types.ts | 1 + 9 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 src/background/handlers/onProxySettingsChanged.ts diff --git a/src/background/background.ts b/src/background/background.ts index abcde524..30ac6ffd 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -10,6 +10,7 @@ import onStartupStoreCleanup from "./handlers/onStartupStoreCleanup"; import onTabCreated from "./handlers/onTabCreated"; import onTabRemoved from "./handlers/onTabRemoved"; import onTabUpdated from "./handlers/onTabUpdated"; +import onProxySettingsChange from "./handlers/onProxySettingsChanged"; console.info("πŸš€ Background script loaded."); @@ -36,6 +37,9 @@ if (isChromium) { browser.tabs.onCreated.addListener(onTabCreated); browser.tabs.onUpdated.addListener(onTabUpdated); browser.tabs.onRemoved.addListener(onTabRemoved); + + // Listen to whether proxy is set or not + chrome.proxy.settings.onChange.addListener(onProxySettingsChange); } else { // Block tracking pixels. browser.webRequest.onBeforeRequest.addListener( diff --git a/src/background/handlers/onProxySettingsChanged.ts b/src/background/handlers/onProxySettingsChanged.ts new file mode 100644 index 00000000..0dfe524d --- /dev/null +++ b/src/background/handlers/onProxySettingsChanged.ts @@ -0,0 +1,6 @@ +import store from "../../store"; + +export default function onProxySettingsChange(details: chrome.types.ChromeSettingGetResultDetails) { + console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); + store.state.chromiumProxyActive = details.levelOfControl == "controlled_by_this_extension"; +} \ No newline at end of file diff --git a/src/background/handlers/onStartupStoreCleanup.ts b/src/background/handlers/onStartupStoreCleanup.ts index 15c88c1e..3e92d4c7 100644 --- a/src/background/handlers/onStartupStoreCleanup.ts +++ b/src/background/handlers/onStartupStoreCleanup.ts @@ -16,4 +16,5 @@ export default function onStartupStoreCleanup(): void { store.state.openedTwitchTabs = []; store.state.streamStatuses = {}; store.state.videoWeaverUrlsByChannel = {}; + store.state.chromiumProxyActive = false; } diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index 9cb7e94b..1d8633f9 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -3,6 +3,7 @@ import getHostFromUrl from "../../common/ts/getHostFromUrl"; import isChromium from "../../common/ts/isChromium"; import { updateProxySettings } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabCreated(tab: Tabs.Tab): void { @@ -10,8 +11,13 @@ export default function onTabCreated(tab: Tabs.Tab): void { const host = getHostFromUrl(tab.url); if (host != null && twitchTvHostRegex.test(host)) { console.log(`βž• Opened Twitch tab: ${tab.id}`); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - updateProxySettings(); + if (isChromium) { + var isNonWhitelistedChannel = true; + const url = new URL(tab.url); + if (url.pathname && url.pathname.length > 0) { + isNonWhitelistedChannel = !isChannelWhitelisted(url.pathname.substring(1)); + } + if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) updateProxySettings(); } store.state.openedTwitchTabs.push(tab.id); } diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 26c81d66..74c40cb4 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -1,5 +1,7 @@ +import browser from "webextension-polyfill"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings } from "../../common/ts/proxySettings"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabRemoved(tabId: number): void { @@ -7,8 +9,24 @@ export default function onTabRemoved(tabId: number): void { if (index !== -1) { console.log(`βž– Closed Twitch tab: ${tabId}`); store.state.openedTwitchTabs.splice(index, 1); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - clearProxySettings(); + if (isChromium) { + if (store.state.openedTwitchTabs.length === 0) { + clearProxySettings(); + return; + } + + Promise.all(store.state.openedTwitchTabs.map(tabId => { + return browser.tabs.get(tabId).then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == '/') return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }).catch(() => false); + })).then(res => { + if (!res.includes(false) && store.state.chromiumProxyActive) { + clearProxySettings(); + } + }); } } } diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index c08aec9b..8ff7fff1 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -1,3 +1,4 @@ +import browser from "webextension-polyfill"; import { Tabs } from "webextension-polyfill"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; import isChromium from "../../common/ts/isChromium"; @@ -6,6 +7,7 @@ import { updateProxySettings, } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabUpdated( @@ -25,8 +27,13 @@ export default function onTabUpdated( if (isTwitchTab && !wasTwitchTab) { console.log(`βž• Opened Twitch tab: ${tabId}`); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - updateProxySettings(); + if (isChromium) { + var isNonWhitelistedPage = true; + const urlObj = new URL(url); + if (urlObj.pathname && urlObj.pathname.length > 0) { + isNonWhitelistedPage = !isChannelWhitelisted(urlObj.pathname.substring(1)); + } + if (isNonWhitelistedPage) updateProxySettings(); } store.state.openedTwitchTabs.push(tabId); } @@ -35,9 +42,44 @@ export default function onTabUpdated( if (index !== -1) { console.log(`βž– Closed Twitch tab: ${tabId}`); store.state.openedTwitchTabs.splice(index, 1); - if (isChromium && store.state.openedTwitchTabs.length === 0) { - clearProxySettings(); + if (isChromium) { + if (store.state.openedTwitchTabs.length === 0) { + clearProxySettings(); + return; + } + + Promise.all(store.state.openedTwitchTabs.map(tabId => { + return browser.tabs.get(tabId).then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == '/') return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }).catch(() => false); + })).then(res => { + if (!res.includes(false) && store.state.chromiumProxyActive) { + clearProxySettings(); + } + }); } } } + if (isTwitchTab && wasTwitchTab) { + console.log(`Changed Twitch tab: ${tabId}`); + if (isChromium) { + Promise.all(store.state.openedTwitchTabs.map(tabId => { + return browser.tabs.get(tabId).then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == '/') return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }).catch(() => false); + })).then(res => { + if (!res.includes(false) && store.state.chromiumProxyActive) { + clearProxySettings(); + } else if (res.includes(false) && !store.state.chromiumProxyActive) { + updateProxySettings(); + } + }); + } + } } diff --git a/src/options/options.ts b/src/options/options.ts index 12592801..fd9af96b 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -116,15 +116,11 @@ function main() { }); } // Whitelisted channels - if (isChromium) { - whitelistedChannelsSectionElement.style.display = "none"; - } else { listInit(whitelistedChannelsListElement, "whitelistedChannels", { getAlreadyExistsAlertMessage: channelName => `'${channelName}' is already whitelisted`, getPromptPlaceholder: () => "Enter a channel name…", }); - } // Proxies if (isChromium) { optimizedProxiesDivElement.style.display = "none"; diff --git a/src/popup/popup.ts b/src/popup/popup.ts index bcb531d8..14e82d51 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -84,9 +84,6 @@ function setStreamStatusElement(channelName: string) { setProxyStatus(channelNameLower, status); setWhitelistStatus(channelNameLower); streamStatusElement.style.display = "flex"; - if (isChromium) { - whitelistStatusElement.style.display = "none"; - } } else { streamStatusElement.style.display = "none"; } diff --git a/src/store/types.ts b/src/store/types.ts index 1ca2f8b2..33398b9d 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -9,6 +9,7 @@ export interface State { adLogEnabled: boolean; adLogLastSent: number; anonymousMode: boolean; + chromiumProxyActive: boolean; dnsResponses: DnsResponse[]; normalProxies: string[]; openedTwitchTabs: number[]; From 79522805bc558853992118b7875b73101046b671 Mon Sep 17 00:00:00 2001 From: Luke Fanning Date: Sun, 24 Sep 2023 12:47:35 +0100 Subject: [PATCH 20/42] Linting fix --- src/background/background.ts | 2 +- .../handlers/onProxySettingsChanged.ts | 11 ++-- src/background/handlers/onTabCreated.ts | 9 ++-- src/background/handlers/onTabRemoved.ts | 23 ++++---- src/background/handlers/onTabUpdated.ts | 53 +++++++++++-------- src/options/options.ts | 10 ++-- 6 files changed, 65 insertions(+), 43 deletions(-) diff --git a/src/background/background.ts b/src/background/background.ts index 30ac6ffd..55397d63 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -5,12 +5,12 @@ import onAuthRequired from "./handlers/onAuthRequired"; import onBeforeSendHeaders from "./handlers/onBeforeSendHeaders"; import onBeforeVideoWeaverRequest from "./handlers/onBeforeVideoWeaverRequest"; 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"; import onTabRemoved from "./handlers/onTabRemoved"; import onTabUpdated from "./handlers/onTabUpdated"; -import onProxySettingsChange from "./handlers/onProxySettingsChanged"; console.info("πŸš€ Background script loaded."); diff --git a/src/background/handlers/onProxySettingsChanged.ts b/src/background/handlers/onProxySettingsChanged.ts index 0dfe524d..56820405 100644 --- a/src/background/handlers/onProxySettingsChanged.ts +++ b/src/background/handlers/onProxySettingsChanged.ts @@ -1,6 +1,9 @@ import store from "../../store"; -export default function onProxySettingsChange(details: chrome.types.ChromeSettingGetResultDetails) { - console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); - store.state.chromiumProxyActive = details.levelOfControl == "controlled_by_this_extension"; -} \ No newline at end of file +export default function onProxySettingsChange( + details: chrome.types.ChromeSettingGetResultDetails +) { + console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); + store.state.chromiumProxyActive = + details.levelOfControl == "controlled_by_this_extension"; +} diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index 1d8633f9..71be2b8c 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -1,9 +1,9 @@ import { Tabs } from "webextension-polyfill"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { updateProxySettings } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabCreated(tab: Tabs.Tab): void { @@ -15,9 +15,12 @@ export default function onTabCreated(tab: Tabs.Tab): void { var isNonWhitelistedChannel = true; const url = new URL(tab.url); if (url.pathname && url.pathname.length > 0) { - isNonWhitelistedChannel = !isChannelWhitelisted(url.pathname.substring(1)); + isNonWhitelistedChannel = !isChannelWhitelisted( + url.pathname.substring(1) + ); } - if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) updateProxySettings(); + if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) + updateProxySettings(); } store.state.openedTwitchTabs.push(tab.id); } diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 74c40cb4..1a36c954 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -1,7 +1,7 @@ import browser from "webextension-polyfill"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings } from "../../common/ts/proxySettings"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabRemoved(tabId: number): void { @@ -15,14 +15,19 @@ export default function onTabRemoved(tabId: number): void { return; } - Promise.all(store.state.openedTwitchTabs.map(tabId => { - return browser.tabs.get(tabId).then(tab => { - if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == '/') return false; - return isChannelWhitelisted(url.pathname.substring(1)); - }).catch(() => false); - })).then(res => { + Promise.all( + store.state.openedTwitchTabs.map(tabId => { + return browser.tabs + .get(tabId) + .then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == "/") return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }) + .catch(() => false); + }) + ).then(res => { if (!res.includes(false) && store.state.chromiumProxyActive) { clearProxySettings(); } diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index 8ff7fff1..ee151061 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -1,13 +1,12 @@ -import browser from "webextension-polyfill"; -import { Tabs } from "webextension-polyfill"; +import browser, { Tabs } from "webextension-polyfill"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings, updateProxySettings, } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import store from "../../store"; export default function onTabUpdated( @@ -31,7 +30,9 @@ export default function onTabUpdated( var isNonWhitelistedPage = true; const urlObj = new URL(url); if (urlObj.pathname && urlObj.pathname.length > 0) { - isNonWhitelistedPage = !isChannelWhitelisted(urlObj.pathname.substring(1)); + isNonWhitelistedPage = !isChannelWhitelisted( + urlObj.pathname.substring(1) + ); } if (isNonWhitelistedPage) updateProxySettings(); } @@ -47,15 +48,20 @@ export default function onTabUpdated( clearProxySettings(); return; } - - Promise.all(store.state.openedTwitchTabs.map(tabId => { - return browser.tabs.get(tabId).then(tab => { - if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == '/') return false; - return isChannelWhitelisted(url.pathname.substring(1)); - }).catch(() => false); - })).then(res => { + + Promise.all( + store.state.openedTwitchTabs.map(tabId => { + return browser.tabs + .get(tabId) + .then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == "/") return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }) + .catch(() => false); + }) + ).then(res => { if (!res.includes(false) && store.state.chromiumProxyActive) { clearProxySettings(); } @@ -66,14 +72,19 @@ export default function onTabUpdated( if (isTwitchTab && wasTwitchTab) { console.log(`Changed Twitch tab: ${tabId}`); if (isChromium) { - Promise.all(store.state.openedTwitchTabs.map(tabId => { - return browser.tabs.get(tabId).then(tab => { - if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == '/') return false; - return isChannelWhitelisted(url.pathname.substring(1)); - }).catch(() => false); - })).then(res => { + Promise.all( + store.state.openedTwitchTabs.map(tabId => { + return browser.tabs + .get(tabId) + .then(tab => { + if (!tab.url) return false; + const url = new URL(tab.url); + if (!url.pathname || url.pathname == "/") return false; + return isChannelWhitelisted(url.pathname.substring(1)); + }) + .catch(() => false); + }) + ).then(res => { if (!res.includes(false) && store.state.chromiumProxyActive) { clearProxySettings(); } else if (res.includes(false) && !store.state.chromiumProxyActive) { diff --git a/src/options/options.ts b/src/options/options.ts index fd9af96b..6e5040d3 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -116,11 +116,11 @@ function main() { }); } // Whitelisted channels - listInit(whitelistedChannelsListElement, "whitelistedChannels", { - getAlreadyExistsAlertMessage: channelName => - `'${channelName}' is already whitelisted`, - getPromptPlaceholder: () => "Enter a channel name…", - }); + listInit(whitelistedChannelsListElement, "whitelistedChannels", { + getAlreadyExistsAlertMessage: channelName => + `'${channelName}' is already whitelisted`, + getPromptPlaceholder: () => "Enter a channel name…", + }); // Proxies if (isChromium) { optimizedProxiesDivElement.style.display = "none"; From a0f777fe95fffabf81b6b79354291cafff1e86e5 Mon Sep 17 00:00:00 2001 From: Luke Fanning Date: Sun, 24 Sep 2023 12:50:26 +0100 Subject: [PATCH 21/42] Updated default state with chromiumProxyActive --- src/store/getDefaultState.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/getDefaultState.ts b/src/store/getDefaultState.ts index 8ce82b18..4eaa18ef 100644 --- a/src/store/getDefaultState.ts +++ b/src/store/getDefaultState.ts @@ -7,6 +7,7 @@ export default function getDefaultState() { adLogEnabled: true, adLogLastSent: 0, anonymousMode: false, + chromiumProxyActive: false, dnsResponses: [], normalProxies: ["chrome.api.cdn-perfprod.com:4023"], openedTwitchTabs: [], From c48123aebcf2dc4b9502bc07651e6eaabee6e148 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:45:44 +0200 Subject: [PATCH 22/42] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20nitpicks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/background.ts | 6 ++--- .../handlers/onProxySettingsChanged.ts | 5 +++-- .../handlers/onStartupStoreCleanup.ts | 2 +- src/background/handlers/onTabCreated.ts | 8 +++---- src/background/handlers/onTabRemoved.ts | 6 ++--- src/background/handlers/onTabUpdated.ts | 22 +++++++++---------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/background/background.ts b/src/background/background.ts index 55397d63..8db61947 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -30,6 +30,9 @@ browser.webRequest.onResponseStarted.addListener(onResponseStarted, { }); if (isChromium) { + // Listen to whether proxy is set or not. + browser.proxy.settings.onChange.addListener(onProxySettingsChange); + // Check if there are any opened Twitch tabs on startup. checkForOpenedTwitchTabs(); @@ -37,9 +40,6 @@ if (isChromium) { browser.tabs.onCreated.addListener(onTabCreated); browser.tabs.onUpdated.addListener(onTabUpdated); browser.tabs.onRemoved.addListener(onTabRemoved); - - // Listen to whether proxy is set or not - chrome.proxy.settings.onChange.addListener(onProxySettingsChange); } else { // Block tracking pixels. browser.webRequest.onBeforeRequest.addListener( diff --git a/src/background/handlers/onProxySettingsChanged.ts b/src/background/handlers/onProxySettingsChanged.ts index 56820405..49735710 100644 --- a/src/background/handlers/onProxySettingsChanged.ts +++ b/src/background/handlers/onProxySettingsChanged.ts @@ -1,9 +1,10 @@ +import { Types } from "webextension-polyfill"; import store from "../../store"; export default function onProxySettingsChange( - details: chrome.types.ChromeSettingGetResultDetails + details: Types.SettingOnChangeDetailsType ) { - console.log("PROXY SETTINGS CHANGE: " + details.levelOfControl); + console.log(`βš™οΈ Proxy settings changed: ${details.levelOfControl}`); store.state.chromiumProxyActive = details.levelOfControl == "controlled_by_this_extension"; } diff --git a/src/background/handlers/onStartupStoreCleanup.ts b/src/background/handlers/onStartupStoreCleanup.ts index 3e92d4c7..af1d2c2b 100644 --- a/src/background/handlers/onStartupStoreCleanup.ts +++ b/src/background/handlers/onStartupStoreCleanup.ts @@ -12,9 +12,9 @@ export default function onStartupStoreCleanup(): void { if (store.readyState !== "complete") return store.addEventListener("load", onStartupStoreCleanup); + store.state.chromiumProxyActive = false; store.state.dnsResponses = []; store.state.openedTwitchTabs = []; store.state.streamStatuses = {}; store.state.videoWeaverUrlsByChannel = {}; - store.state.chromiumProxyActive = false; } diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index 71be2b8c..231a6790 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -12,11 +12,11 @@ export default function onTabCreated(tab: Tabs.Tab): void { if (host != null && twitchTvHostRegex.test(host)) { console.log(`βž• Opened Twitch tab: ${tab.id}`); if (isChromium) { - var isNonWhitelistedChannel = true; - const url = new URL(tab.url); - if (url.pathname && url.pathname.length > 0) { + let isNonWhitelistedChannel = true; + const Url = new URL(tab.url); + if (Url.pathname && Url.pathname.length > 0) { isNonWhitelistedChannel = !isChannelWhitelisted( - url.pathname.substring(1) + Url.pathname.substring(1) ); } if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 1a36c954..4da91531 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -21,9 +21,9 @@ export default function onTabRemoved(tabId: number): void { .get(tabId) .then(tab => { if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == "/") return false; - return isChannelWhitelisted(url.pathname.substring(1)); + const Url = new URL(tab.url); + if (!Url.pathname || Url.pathname == "/") return false; + return isChannelWhitelisted(Url.pathname.substring(1)); }) .catch(() => false); }) diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index ee151061..99b3fc50 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -27,12 +27,10 @@ export default function onTabUpdated( if (isTwitchTab && !wasTwitchTab) { console.log(`βž• Opened Twitch tab: ${tabId}`); if (isChromium) { - var isNonWhitelistedPage = true; - const urlObj = new URL(url); - if (urlObj.pathname && urlObj.pathname.length > 0) { - isNonWhitelistedPage = !isChannelWhitelisted( - urlObj.pathname.substring(1) - ); + let isNonWhitelistedPage = true; + const Url = new URL(url); + if (Url.pathname && Url.pathname.length > 0) { + isNonWhitelistedPage = !isChannelWhitelisted(Url.pathname.substring(1)); } if (isNonWhitelistedPage) updateProxySettings(); } @@ -55,9 +53,9 @@ export default function onTabUpdated( .get(tabId) .then(tab => { if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == "/") return false; - return isChannelWhitelisted(url.pathname.substring(1)); + const Url = new URL(tab.url); + if (!Url.pathname || Url.pathname == "/") return false; + return isChannelWhitelisted(Url.pathname.substring(1)); }) .catch(() => false); }) @@ -78,9 +76,9 @@ export default function onTabUpdated( .get(tabId) .then(tab => { if (!tab.url) return false; - const url = new URL(tab.url); - if (!url.pathname || url.pathname == "/") return false; - return isChannelWhitelisted(url.pathname.substring(1)); + const Url = new URL(tab.url); + if (!Url.pathname || Url.pathname == "/") return false; + return isChannelWhitelisted(Url.pathname.substring(1)); }) .catch(() => false); }) From 9fffbbc283b9902e4bfdd4bc4bffb02298fe2feb Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:30:26 +0200 Subject: [PATCH 23/42] =?UTF-8?q?=F0=9F=8E=A8=20Cleaner=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onTabCreated.ts | 27 ++++--- src/background/handlers/onTabRemoved.ts | 47 +++++------- src/background/handlers/onTabUpdated.ts | 99 +++++++++---------------- src/options/page.html | 2 + src/store/types.ts | 3 +- 5 files changed, 75 insertions(+), 103 deletions(-) diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index 231a6790..b47eb55f 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -1,4 +1,5 @@ import { Tabs } from "webextension-polyfill"; +import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; @@ -7,21 +8,23 @@ import { twitchTvHostRegex } from "../../common/ts/regexes"; import store from "../../store"; export default function onTabCreated(tab: Tabs.Tab): void { - if (!tab.url || tab.id == null) return; - const host = getHostFromUrl(tab.url); - if (host != null && twitchTvHostRegex.test(host)) { + const url = tab.url || tab.pendingUrl; + if (!url) return; + const host = getHostFromUrl(url); + if (!host) return; + + if (twitchTvHostRegex.test(host)) { console.log(`βž• Opened Twitch tab: ${tab.id}`); + store.state.openedTwitchTabs.push(tab); + if (isChromium) { - let isNonWhitelistedChannel = true; - const Url = new URL(tab.url); - if (Url.pathname && Url.pathname.length > 0) { - isNonWhitelistedChannel = !isChannelWhitelisted( - Url.pathname.substring(1) - ); - } - if (isNonWhitelistedChannel && !store.state.chromiumProxyActive) + const channelName = findChannelFromTwitchTvUrl(url); + const isWhitelisted = channelName + ? isChannelWhitelisted(channelName) + : false; + if (!isWhitelisted && !store.state.chromiumProxyActive) { updateProxySettings(); + } } - store.state.openedTwitchTabs.push(tab.id); } } diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 4da91531..66e21be5 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -1,37 +1,30 @@ -import browser from "webextension-polyfill"; +import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings } from "../../common/ts/proxySettings"; import store from "../../store"; export default function onTabRemoved(tabId: number): void { - const index = store.state.openedTwitchTabs.indexOf(tabId); - if (index !== -1) { - console.log(`βž– Closed Twitch tab: ${tabId}`); - store.state.openedTwitchTabs.splice(index, 1); - if (isChromium) { - if (store.state.openedTwitchTabs.length === 0) { - clearProxySettings(); - return; - } + const index = store.state.openedTwitchTabs.findIndex(tab => tab.id === tabId); + if (index === -1) return; - Promise.all( - store.state.openedTwitchTabs.map(tabId => { - return browser.tabs - .get(tabId) - .then(tab => { - if (!tab.url) return false; - const Url = new URL(tab.url); - if (!Url.pathname || Url.pathname == "/") return false; - return isChannelWhitelisted(Url.pathname.substring(1)); - }) - .catch(() => false); - }) - ).then(res => { - if (!res.includes(false) && store.state.chromiumProxyActive) { - clearProxySettings(); - } - }); + console.log(`βž– Closed Twitch tab: ${tabId}`); + store.state.openedTwitchTabs.splice(index, 1); + + if (isChromium) { + const allTabsAreWhitelisted = store.state.openedTwitchTabs.every(tab => { + if (!tab.url) return false; + const channelName = findChannelFromTwitchTvUrl(tab.url); + const isWhitelisted = channelName + ? isChannelWhitelisted(channelName) + : false; + return isWhitelisted; + }); + if ( + (store.state.openedTwitchTabs.length === 0 || allTabsAreWhitelisted) && + store.state.chromiumProxyActive + ) { + clearProxySettings(); } } } diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index 99b3fc50..342e032b 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -1,4 +1,5 @@ -import browser, { Tabs } from "webextension-polyfill"; +import { Tabs } from "webextension-polyfill"; +import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; @@ -8,6 +9,8 @@ import { } from "../../common/ts/proxySettings"; import { twitchTvHostRegex } from "../../common/ts/regexes"; import store from "../../store"; +import onTabCreated from "./onTabCreated"; +import onTabRemoved from "./onTabRemoved"; export default function onTabUpdated( tabId: number, @@ -16,79 +19,49 @@ export default function onTabUpdated( ): void { // Also check for `changeInfo.status === "complete"` because the `url` property // is not always accurate when navigating to a new page. - if (!(changeInfo.url || changeInfo.status === "complete")) return; + if (!(changeInfo.url || changeInfo.status === "loading")) return; - const url = changeInfo.url || tab.url; + const url = changeInfo.url || tab.url || tab.pendingUrl; if (!url) return; const host = getHostFromUrl(url); - const isTwitchTab = host != null && twitchTvHostRegex.test(host); - const wasTwitchTab = store.state.openedTwitchTabs.includes(tabId); + if (!host) return; + + const isTwitchTab = twitchTvHostRegex.test(host); + const wasTwitchTab = store.state.openedTwitchTabs.findIndex( + tab => tab.id === tabId + ); if (isTwitchTab && !wasTwitchTab) { - console.log(`βž• Opened Twitch tab: ${tabId}`); - if (isChromium) { - let isNonWhitelistedPage = true; - const Url = new URL(url); - if (Url.pathname && Url.pathname.length > 0) { - isNonWhitelistedPage = !isChannelWhitelisted(Url.pathname.substring(1)); - } - if (isNonWhitelistedPage) updateProxySettings(); - } - store.state.openedTwitchTabs.push(tabId); + onTabCreated(tab); } - if (!isTwitchTab && wasTwitchTab) { - const index = store.state.openedTwitchTabs.indexOf(tabId); - if (index !== -1) { - console.log(`βž– Closed Twitch tab: ${tabId}`); - store.state.openedTwitchTabs.splice(index, 1); - if (isChromium) { - if (store.state.openedTwitchTabs.length === 0) { - clearProxySettings(); - return; - } - Promise.all( - store.state.openedTwitchTabs.map(tabId => { - return browser.tabs - .get(tabId) - .then(tab => { - if (!tab.url) return false; - const Url = new URL(tab.url); - if (!Url.pathname || Url.pathname == "/") return false; - return isChannelWhitelisted(Url.pathname.substring(1)); - }) - .catch(() => false); - }) - ).then(res => { - if (!res.includes(false) && store.state.chromiumProxyActive) { - clearProxySettings(); - } - }); - } - } + if (!isTwitchTab && wasTwitchTab) { + onTabRemoved(tabId); } + if (isTwitchTab && wasTwitchTab) { - console.log(`Changed Twitch tab: ${tabId}`); + const index = store.state.openedTwitchTabs.findIndex( + tab => tab.id === tabId + ); + if (index === -1) return; + + console.log(`🟰 Updated Twitch tab: ${tabId}`); + store.state.openedTwitchTabs[index] = tab; + if (isChromium) { - Promise.all( - store.state.openedTwitchTabs.map(tabId => { - return browser.tabs - .get(tabId) - .then(tab => { - if (!tab.url) return false; - const Url = new URL(tab.url); - if (!Url.pathname || Url.pathname == "/") return false; - return isChannelWhitelisted(Url.pathname.substring(1)); - }) - .catch(() => false); - }) - ).then(res => { - if (!res.includes(false) && store.state.chromiumProxyActive) { - clearProxySettings(); - } else if (res.includes(false) && !store.state.chromiumProxyActive) { - updateProxySettings(); - } + const allTabsAreWhitelisted = store.state.openedTwitchTabs.every(tab => { + if (!tab.url) return false; + const channelName = findChannelFromTwitchTvUrl(tab.url); + const isWhitelisted = channelName + ? isChannelWhitelisted(channelName) + : false; + return isWhitelisted; }); + if (!allTabsAreWhitelisted && !store.state.chromiumProxyActive) { + updateProxySettings(); + } else if (allTabsAreWhitelisted && store.state.chromiumProxyActive) { + clearProxySettings(); + } } } } diff --git a/src/options/page.html b/src/options/page.html index 1dd6baf1..517b8813 100644 --- a/src/options/page.html +++ b/src/options/page.html @@ -108,6 +108,8 @@

        Passport

        Whitelisted channels

        Support your favorite content creators by whitelisting their channels. + On Chromium-based browsers, whitelisting only works when all opened + Twitch tabs are whitelisted.
          diff --git a/src/store/types.ts b/src/store/types.ts index 33398b9d..1e56344c 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -1,3 +1,4 @@ +import type { Tabs } from "webextension-polyfill"; import type { AdLogEntry, DnsResponse, StreamStatus } from "../types"; export type EventType = "load" | "change"; @@ -12,7 +13,7 @@ export interface State { chromiumProxyActive: boolean; dnsResponses: DnsResponse[]; normalProxies: string[]; - openedTwitchTabs: number[]; + openedTwitchTabs: Tabs.Tab[]; optimizedProxies: string[]; optimizedProxiesEnabled: boolean; proxyTwitchWebpage: boolean; From 208f9908a449f5018114b4f3c3528016e3e27b99 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:35:27 +0200 Subject: [PATCH 24/42] =?UTF-8?q?=F0=9F=90=9B=20Fix=20type=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/checkForOpenedTwitchTabs.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/background/handlers/checkForOpenedTwitchTabs.ts b/src/background/handlers/checkForOpenedTwitchTabs.ts index 18491c93..46d1a80b 100644 --- a/src/background/handlers/checkForOpenedTwitchTabs.ts +++ b/src/background/handlers/checkForOpenedTwitchTabs.ts @@ -13,17 +13,18 @@ export default function checkForOpenedTwitchTabs() { browser.tabs .query({ url: ["https://www.twitch.tv/*", "https://m.twitch.tv/*"] }) .then(tabs => { - const tabsIds = tabs.filter(tab => tab.id != null).map(tab => tab.id!); - if (tabsIds.length === 0) { + if (tabs.length === 0) { if (isChromium) clearProxySettings(); return; } console.log( - `πŸ” Found ${tabsIds.length} opened Twitch tabs: ${tabsIds.join(", ")}` + `πŸ” Found ${tabs.length} opened Twitch tabs: ${tabs + .map(tab => tab.id) + .join(", ")}` ); if (isChromium) { updateProxySettings(); } - store.state.openedTwitchTabs = tabsIds; + store.state.openedTwitchTabs = tabs; }); } From 9bfcc47eed07d5e87ad2be3a29d0c2bfb7b1bc8f Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:55:22 +0200 Subject: [PATCH 25/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onProxyRequest.ts | 12 ++++++------ src/background/handlers/onTabUpdated.ts | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/background/handlers/onProxyRequest.ts b/src/background/handlers/onProxyRequest.ts index 670713ac..d669d0c6 100644 --- a/src/background/handlers/onProxyRequest.ts +++ b/src/background/handlers/onProxyRequest.ts @@ -33,10 +33,16 @@ export default async function onProxyRequest( }); } + const documentHost = details.documentUrl + ? getHostFromUrl(details.documentUrl) + : null; + const isFromTwitchTvHost = + documentHost && twitchTvHostRegex.test(documentHost); const isFlagged = (store.state.optimizedProxiesEnabled && isFlaggedRequest(details.requestHeaders)) || !store.state.optimizedProxiesEnabled; + const proxies = store.state.optimizedProxiesEnabled ? store.state.optimizedProxies : store.state.normalProxies; @@ -72,12 +78,6 @@ export default async function onProxyRequest( return proxyInfoArray; } - const documentHost = details.documentUrl - ? getHostFromUrl(details.documentUrl) - : null; - const isFromTwitchTvHost = - documentHost && twitchTvHostRegex.test(documentHost); - // Usher requests. if (store.state.proxyUsherRequests && usherHostRegex.test(host)) { // Don't proxy Usher requests from non-supported hosts. diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index 342e032b..cbc5f189 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -17,9 +17,11 @@ export default function onTabUpdated( changeInfo: Tabs.OnUpdatedChangeInfoType, tab: Tabs.Tab ): void { - // Also check for `changeInfo.status === "complete"` because the `url` property - // is not always accurate when navigating to a new page. - if (!(changeInfo.url || changeInfo.status === "loading")) return; + const isPageNavigation = changeInfo.url != null; + // FIXME: changeInfo.status === "loading" is triggered multiple times when + // reloading a page. + const isPageReload = changeInfo.status === "loading"; + if (!isPageNavigation && !isPageReload) return; const url = changeInfo.url || tab.url || tab.pendingUrl; if (!url) return; From bdc983ff331b2158f81c965c329d2d7cdfc1d49c Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:48:41 +0200 Subject: [PATCH 26/42] =?UTF-8?q?=F0=9F=90=9B=20Fix=20openedTwitchTabs=20b?= =?UTF-8?q?ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onTabUpdated.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index cbc5f189..bd9cae6a 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -29,7 +29,7 @@ export default function onTabUpdated( if (!host) return; const isTwitchTab = twitchTvHostRegex.test(host); - const wasTwitchTab = store.state.openedTwitchTabs.findIndex( + const wasTwitchTab = store.state.openedTwitchTabs.some( tab => tab.id === tabId ); From 9a16e1a2f57a6e39bd8c00a09b52b9d3a1a936bd Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:49:21 +0200 Subject: [PATCH 27/42] =?UTF-8?q?=F0=9F=90=9B=20Fix=20checkForOpenedTwitch?= =?UTF-8?q?Tabs=20bug=20-=20Didn't=20take=20into=20account=20whitelisted?= =?UTF-8?q?=20tabs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/checkForOpenedTwitchTabs.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/background/handlers/checkForOpenedTwitchTabs.ts b/src/background/handlers/checkForOpenedTwitchTabs.ts index 46d1a80b..ee2d0cb8 100644 --- a/src/background/handlers/checkForOpenedTwitchTabs.ts +++ b/src/background/handlers/checkForOpenedTwitchTabs.ts @@ -1,4 +1,6 @@ import browser from "webextension-polyfill"; +import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; +import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings, @@ -13,18 +15,27 @@ export default function checkForOpenedTwitchTabs() { browser.tabs .query({ url: ["https://www.twitch.tv/*", "https://m.twitch.tv/*"] }) .then(tabs => { - if (tabs.length === 0) { - if (isChromium) clearProxySettings(); - return; - } console.log( `πŸ” Found ${tabs.length} opened Twitch tabs: ${tabs .map(tab => tab.id) .join(", ")}` ); + store.state.openedTwitchTabs = tabs; + if (isChromium) { - updateProxySettings(); + const allTabsAreWhitelisted = tabs.every(tab => { + if (!tab.url) return false; + const channelName = findChannelFromTwitchTvUrl(tab.url); + const isWhitelisted = channelName + ? isChannelWhitelisted(channelName) + : false; + return isWhitelisted; + }); + if (tabs.length === 0 || allTabsAreWhitelisted) { + clearProxySettings(); + } else { + updateProxySettings(); + } } - store.state.openedTwitchTabs = tabs; }); } From 9d8448eb54d31b654b88e48a83ef3ebc77c4134b Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:32:00 +0200 Subject: [PATCH 28/42] =?UTF-8?q?=F0=9F=8E=A8=20Small=20code=20improvement?= =?UTF-8?q?s=20-=20No=20better=20way=20to=20check=20for=20page=20load=20fo?= =?UTF-8?q?und?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onTabUpdated.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index bd9cae6a..4beac193 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -18,10 +18,11 @@ export default function onTabUpdated( tab: Tabs.Tab ): void { const isPageNavigation = changeInfo.url != null; - // FIXME: changeInfo.status === "loading" is triggered multiple times when - // reloading a page. - const isPageReload = changeInfo.status === "loading"; - if (!isPageNavigation && !isPageReload) return; + // We have to check for `changeInfo.status === "loading"` because + // `changeInfo.url` is incorrect when navigating from Twitch to another + // website. + const isPageLoad = changeInfo.status === "loading"; + if (!isPageNavigation && !isPageLoad) return; const url = changeInfo.url || tab.url || tab.pendingUrl; if (!url) return; @@ -32,15 +33,19 @@ export default function onTabUpdated( const wasTwitchTab = store.state.openedTwitchTabs.some( tab => tab.id === tabId ); + if (!isTwitchTab && !wasTwitchTab) return; + // Tab created if (isTwitchTab && !wasTwitchTab) { onTabCreated(tab); } + // Tab removed if (!isTwitchTab && wasTwitchTab) { onTabRemoved(tabId); } + // Tab updated if (isTwitchTab && wasTwitchTab) { const index = store.state.openedTwitchTabs.findIndex( tab => tab.id === tabId From d4336979c18ba28beb00ecaf30990941df8913f0 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:39:13 +0200 Subject: [PATCH 29/42] =?UTF-8?q?=F0=9F=90=9B=20Fix=20anonymousMode=20back?= =?UTF-8?q?up=20&=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onBeforeVideoWeaverRequest.ts | 2 ++ src/options/options.ts | 1 + src/popup/popup.ts | 1 + src/types.ts | 1 + 4 files changed, 5 insertions(+) diff --git a/src/background/handlers/onBeforeVideoWeaverRequest.ts b/src/background/handlers/onBeforeVideoWeaverRequest.ts index 122bf3b5..4e577113 100644 --- a/src/background/handlers/onBeforeVideoWeaverRequest.ts +++ b/src/background/handlers/onBeforeVideoWeaverRequest.ts @@ -39,6 +39,7 @@ export default function onBeforeVideoWeaverRequest( } const proxyTwitchWebpage = store.state.proxyTwitchWebpage; const proxyUsherRequests = store.state.proxyUsherRequests; + const anonymousMode = store.state.anonymousMode; const timestamp = details.timeStamp; const videoWeaverHost = host; const videoWeaverUrl = details.url; @@ -62,6 +63,7 @@ export default function onBeforeVideoWeaverRequest( proxy, proxyTwitchWebpage, proxyUsherRequests, + anonymousMode, timestamp, videoWeaverHost, videoWeaverUrl, diff --git a/src/options/options.ts b/src/options/options.ts index 6e5040d3..cd44fb4b 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -448,6 +448,7 @@ exportButtonElement.addEventListener("click", () => { "ttv-lol-pro_backup.json", JSON.stringify({ adLogEnabled: store.state.adLogEnabled, + anonymousMode: store.state.anonymousMode, normalProxies: store.state.normalProxies, optimizedProxies: store.state.optimizedProxies, optimizedProxiesEnabled: store.state.optimizedProxiesEnabled, diff --git a/src/popup/popup.ts b/src/popup/popup.ts index 14e82d51..1573cf44 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -170,6 +170,7 @@ copyDebugInfoButtonElement.addEventListener("click", async e => { `- OS: ${userAgentParser.getOSName()} ${userAgentParser.getOSVersion()}`, `- Passport enabled: ${store.state.proxyUsherRequests}`, `- Is laissez-passer: ${store.state.proxyTwitchWebpage}`, + `- Is redacted: ${store.state.anonymousMode}`, `- Optimized proxies enabled: ${store.state.optimizedProxiesEnabled}`, `- Optimized proxies: ${JSON.stringify( e.shiftKey diff --git a/src/types.ts b/src/types.ts index b2d3a7dd..ee34b144 100644 --- a/src/types.ts +++ b/src/types.ts @@ -28,6 +28,7 @@ export interface AdLogEntry { proxy: string | null; proxyTwitchWebpage: boolean; proxyUsherRequests: boolean; + anonymousMode: boolean; timestamp: number; videoWeaverHost: string; videoWeaverUrl: string; From 4ffa3504c58ccf0a4d1997483613b221d54f2310 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:47:07 +0200 Subject: [PATCH 30/42] =?UTF-8?q?=F0=9F=90=9B=20Fix=20popout=20chat=20for?= =?UTF-8?q?=20whitelisted=20channels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ts/regexes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ts/regexes.ts b/src/common/ts/regexes.ts index 5bf2cf3a..99c6131e 100644 --- a/src/common/ts/regexes.ts +++ b/src/common/ts/regexes.ts @@ -1,7 +1,7 @@ export const passportHostRegex = /^passport\.twitch\.tv$/i; export const twitchApiChannelNameRegex = /\/hls\/(.+)\.m3u8/i; export const twitchChannelNameRegex = - /^https?:\/\/(?:www|m)\.twitch\.tv\/(?:videos\/)?(\w+)/i; + /^https?:\/\/(?:www|m)\.twitch\.tv\/(?:videos\/|popout\/)?(\w+)/i; export const twitchGqlHostRegex = /^gql\.twitch\.tv$/i; export const twitchTvHostRegex = /^(?:www|m)\.twitch\.tv$/i; export const usherHostRegex = /^usher\.ttvnw\.net$/i; From 09779a9a9f88eb34f14cb0f50efaff62e815eccf Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:56:58 +0200 Subject: [PATCH 31/42] =?UTF-8?q?=F0=9F=92=AC=20Update=20whitelist=20optio?= =?UTF-8?q?n=20description?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options/page.html b/src/options/page.html index 517b8813..c8b185b3 100644 --- a/src/options/page.html +++ b/src/options/page.html @@ -109,7 +109,7 @@

          Whitelisted channels

          Support your favorite content creators by whitelisting their channels. On Chromium-based browsers, whitelisting only works when all opened - Twitch tabs are whitelisted. + Twitch tabs are whitelisted channels.
            From 67249fad8b06f84848a9987efc345a7e7289d9ba Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:09:04 +0200 Subject: [PATCH 32/42] =?UTF-8?q?=F0=9F=8E=A8=20Tweak=20code=20order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onProxyRequest.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/background/handlers/onProxyRequest.ts b/src/background/handlers/onProxyRequest.ts index d669d0c6..61fd95d2 100644 --- a/src/background/handlers/onProxyRequest.ts +++ b/src/background/handlers/onProxyRequest.ts @@ -22,6 +22,12 @@ export default async function onProxyRequest( const host = getHostFromUrl(details.url); if (!host) return { type: "direct" }; + const documentHost = details.documentUrl + ? getHostFromUrl(details.documentUrl) + : null; + const isFromTwitchTvHost = + documentHost && twitchTvHostRegex.test(documentHost); + // Wait for the store to be ready. if (store.readyState !== "complete") { await new Promise(resolve => { @@ -33,16 +39,10 @@ export default async function onProxyRequest( }); } - const documentHost = details.documentUrl - ? getHostFromUrl(details.documentUrl) - : null; - const isFromTwitchTvHost = - documentHost && twitchTvHostRegex.test(documentHost); const isFlagged = (store.state.optimizedProxiesEnabled && isFlaggedRequest(details.requestHeaders)) || !store.state.optimizedProxiesEnabled; - const proxies = store.state.optimizedProxiesEnabled ? store.state.optimizedProxies : store.state.normalProxies; From 66d4444f459aafe5f399c49c4c23d847bf976716 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:20:24 +0200 Subject: [PATCH 33/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20format=20of=20th?= =?UTF-8?q?e=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/onBeforeVideoWeaverRequest.ts | 82 +++++++++---------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/src/background/handlers/onBeforeVideoWeaverRequest.ts b/src/background/handlers/onBeforeVideoWeaverRequest.ts index 4e577113..f4b4cf0a 100644 --- a/src/background/handlers/onBeforeVideoWeaverRequest.ts +++ b/src/background/handlers/onBeforeVideoWeaverRequest.ts @@ -24,55 +24,47 @@ export default function onBeforeVideoWeaverRequest( const textLower = text.toLowerCase(); const isAd = textLower.includes(adSignifier); const isMidroll = textLower.includes(midrollSignifier); + if (!isAd && !isMidroll) return text; - if (isAd || isMidroll) { - const adType: AdType = isMidroll ? AdType.MIDROLL : AdType.PREROLL; - const channel = - findChannelFromVideoWeaverUrl(details.url) ?? - findChannelFromTwitchTvUrl(details.documentUrl); - const isPurpleScreen = textLower.includes( - "https://help.twitch.tv/s/article/ad-experience-on-twitch" - ); - let proxy: string | null = null; - if (details.proxyInfo && details.proxyInfo.type !== "direct") { - proxy = `${details.proxyInfo.host}:${details.proxyInfo.port}`; - } - const proxyTwitchWebpage = store.state.proxyTwitchWebpage; - const proxyUsherRequests = store.state.proxyUsherRequests; - const anonymousMode = store.state.anonymousMode; - const timestamp = details.timeStamp; - const videoWeaverHost = host; - const videoWeaverUrl = details.url; + const isDuplicate = store.state.adLog.some( + entry => + entry.videoWeaverUrl === details.url && + details.timeStamp - entry.timestamp < 1000 * 30 // 30 seconds + ); + if (isDuplicate) return text; - const isDuplicate = store.state.adLog.some( - entry => - entry.videoWeaverUrl === videoWeaverUrl && - timestamp - entry.timestamp < 1000 * 30 // 30 seconds - ); - if (isDuplicate) return text; - - const adLog = store.state.adLog.filter( - entry => timestamp - entry.timestamp < 1000 * 60 * 60 * 24 * 7 // 7 days - ); - store.state.adLog = [ - ...adLog, - { - adType, - channel, - isPurpleScreen, - proxy, - proxyTwitchWebpage, - proxyUsherRequests, - anonymousMode, - timestamp, - videoWeaverHost, - videoWeaverUrl, - }, - ]; - console.log(`πŸ“ Ad log updated (${adLog.length + 1} entries).`); - console.log(text); + const channelName = + findChannelFromVideoWeaverUrl(details.url) ?? + findChannelFromTwitchTvUrl(details.documentUrl); + const isPurpleScreen = textLower.includes( + "https://help.twitch.tv/s/article/ad-experience-on-twitch" + ); + let proxy: string | null = null; + if (details.proxyInfo && details.proxyInfo.type !== "direct") { + proxy = `${details.proxyInfo.host}:${details.proxyInfo.port}`; } + const adLog = store.state.adLog.filter( + entry => details.timeStamp - entry.timestamp < 1000 * 60 * 60 * 24 * 7 // 7 days + ); + store.state.adLog = [ + ...adLog, + { + adType: isMidroll ? AdType.MIDROLL : AdType.PREROLL, + channel: channelName, + isPurpleScreen, + proxy, + proxyTwitchWebpage: store.state.proxyTwitchWebpage, + proxyUsherRequests: store.state.proxyUsherRequests, + anonymousMode: store.state.anonymousMode, + timestamp: details.timeStamp, + videoWeaverHost: host, + videoWeaverUrl: details.url, + }, + ]; + console.log(`πŸ“ Ad log updated (${store.state.adLog.length} entries).`); + console.log(text); + return text; }); } From 720fa67c125afa433e688de6f7959d2755ff9c18 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:45:00 +0200 Subject: [PATCH 34/42] =?UTF-8?q?=F0=9F=92=AC=20Update=20log=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/checkForOpenedTwitchTabs.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/background/handlers/checkForOpenedTwitchTabs.ts b/src/background/handlers/checkForOpenedTwitchTabs.ts index ee2d0cb8..a9840a64 100644 --- a/src/background/handlers/checkForOpenedTwitchTabs.ts +++ b/src/background/handlers/checkForOpenedTwitchTabs.ts @@ -15,11 +15,7 @@ export default function checkForOpenedTwitchTabs() { browser.tabs .query({ url: ["https://www.twitch.tv/*", "https://m.twitch.tv/*"] }) .then(tabs => { - console.log( - `πŸ” Found ${tabs.length} opened Twitch tabs: ${tabs - .map(tab => tab.id) - .join(", ")}` - ); + console.log(`πŸ” Found ${tabs.length} opened Twitch tabs.`); store.state.openedTwitchTabs = tabs; if (isChromium) { From 284ac26c50e7c27c759edd7f5e5ad001d2711f13 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 13:10:35 +0200 Subject: [PATCH 35/42] =?UTF-8?q?=F0=9F=92=AC=20Update=20limited=20proxy?= =?UTF-8?q?=20warning=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/popup/menu.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/popup/menu.html b/src/popup/menu.html index c870de57..ee88b9ff 100644 --- a/src/popup/menu.html +++ b/src/popup/menu.html @@ -21,7 +21,13 @@

            Twitch ads are not being blocked!

            You are using a limited proxy!

            The proxy you are using has a limited number of simultaneous connections. This means that you may experience buffering issues. Consider donating to - get access to unlimited proxies. + get access to unlimited proxies, or + host your own proxy.
            From cf51e055a71ad60afa6529b6f8509c3b86a400b7 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 13:17:58 +0200 Subject: [PATCH 36/42] =?UTF-8?q?=F0=9F=92=A1=20Add=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onTabCreated.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/background/handlers/onTabCreated.ts b/src/background/handlers/onTabCreated.ts index b47eb55f..31c5c7a1 100644 --- a/src/background/handlers/onTabCreated.ts +++ b/src/background/handlers/onTabCreated.ts @@ -13,6 +13,9 @@ export default function onTabCreated(tab: Tabs.Tab): void { const host = getHostFromUrl(url); if (!host) return; + // TODO: `twitchTvHostRegex` doesn't match `appeals.twitch.tv` and + // `dashboard.twitch.tv` which means that passport requests from those + // subdomains will not be proxied. This could mess up the cookie country. if (twitchTvHostRegex.test(host)) { console.log(`βž• Opened Twitch tab: ${tab.id}`); store.state.openedTwitchTabs.push(tab); From bf489b24f4d7ff8412b7f355d4085a9a162781a4 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 13:28:49 +0200 Subject: [PATCH 37/42] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Reorganize=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/checkForOpenedTwitchTabs.ts | 12 ++---------- src/background/handlers/onTabRemoved.ts | 14 ++++---------- src/background/handlers/onTabUpdated.ts | 14 ++++---------- src/common/ts/areAllTabsWhitelisted.ts | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 30 deletions(-) create mode 100644 src/common/ts/areAllTabsWhitelisted.ts diff --git a/src/background/handlers/checkForOpenedTwitchTabs.ts b/src/background/handlers/checkForOpenedTwitchTabs.ts index a9840a64..25550daf 100644 --- a/src/background/handlers/checkForOpenedTwitchTabs.ts +++ b/src/background/handlers/checkForOpenedTwitchTabs.ts @@ -1,6 +1,5 @@ import browser from "webextension-polyfill"; -import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; +import areAllTabsWhitelisted from "../../common/ts/areAllTabsWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings, @@ -19,14 +18,7 @@ export default function checkForOpenedTwitchTabs() { store.state.openedTwitchTabs = tabs; if (isChromium) { - const allTabsAreWhitelisted = tabs.every(tab => { - if (!tab.url) return false; - const channelName = findChannelFromTwitchTvUrl(tab.url); - const isWhitelisted = channelName - ? isChannelWhitelisted(channelName) - : false; - return isWhitelisted; - }); + const allTabsAreWhitelisted = areAllTabsWhitelisted(tabs); if (tabs.length === 0 || allTabsAreWhitelisted) { clearProxySettings(); } else { diff --git a/src/background/handlers/onTabRemoved.ts b/src/background/handlers/onTabRemoved.ts index 66e21be5..735adf9a 100644 --- a/src/background/handlers/onTabRemoved.ts +++ b/src/background/handlers/onTabRemoved.ts @@ -1,5 +1,4 @@ -import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; +import areAllTabsWhitelisted from "../../common/ts/areAllTabsWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings } from "../../common/ts/proxySettings"; import store from "../../store"; @@ -12,14 +11,9 @@ export default function onTabRemoved(tabId: number): void { store.state.openedTwitchTabs.splice(index, 1); if (isChromium) { - const allTabsAreWhitelisted = store.state.openedTwitchTabs.every(tab => { - if (!tab.url) return false; - const channelName = findChannelFromTwitchTvUrl(tab.url); - const isWhitelisted = channelName - ? isChannelWhitelisted(channelName) - : false; - return isWhitelisted; - }); + const allTabsAreWhitelisted = areAllTabsWhitelisted( + store.state.openedTwitchTabs + ); if ( (store.state.openedTwitchTabs.length === 0 || allTabsAreWhitelisted) && store.state.chromiumProxyActive diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index 4beac193..cc7227a6 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -1,7 +1,6 @@ import { Tabs } from "webextension-polyfill"; -import findChannelFromTwitchTvUrl from "../../common/ts/findChannelFromTwitchTvUrl"; +import areAllTabsWhitelisted from "../../common/ts/areAllTabsWhitelisted"; import getHostFromUrl from "../../common/ts/getHostFromUrl"; -import isChannelWhitelisted from "../../common/ts/isChannelWhitelisted"; import isChromium from "../../common/ts/isChromium"; import { clearProxySettings, @@ -56,14 +55,9 @@ export default function onTabUpdated( store.state.openedTwitchTabs[index] = tab; if (isChromium) { - const allTabsAreWhitelisted = store.state.openedTwitchTabs.every(tab => { - if (!tab.url) return false; - const channelName = findChannelFromTwitchTvUrl(tab.url); - const isWhitelisted = channelName - ? isChannelWhitelisted(channelName) - : false; - return isWhitelisted; - }); + const allTabsAreWhitelisted = areAllTabsWhitelisted( + store.state.openedTwitchTabs + ); if (!allTabsAreWhitelisted && !store.state.chromiumProxyActive) { updateProxySettings(); } else if (allTabsAreWhitelisted && store.state.chromiumProxyActive) { diff --git a/src/common/ts/areAllTabsWhitelisted.ts b/src/common/ts/areAllTabsWhitelisted.ts new file mode 100644 index 00000000..f56bc02b --- /dev/null +++ b/src/common/ts/areAllTabsWhitelisted.ts @@ -0,0 +1,15 @@ +import { Tabs } from "webextension-polyfill"; +import findChannelFromTwitchTvUrl from "./findChannelFromTwitchTvUrl"; +import isChannelWhitelisted from "./isChannelWhitelisted"; + +export default function areAllTabsWhitelisted(tabs: Tabs.Tab[]): boolean { + return tabs.every(tab => { + const url = tab.url || tab.pendingUrl; + if (!url) return false; + const channelName = findChannelFromTwitchTvUrl(url); + const isWhitelisted = channelName + ? isChannelWhitelisted(channelName) + : false; + return isWhitelisted; + }); +} From 88f33829d95fb3da880cac11e30a6f5e6cf90126 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 13:57:32 +0200 Subject: [PATCH 38/42] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/checkForOpenedTwitchTabs.ts | 6 +++--- src/background/handlers/onBeforeVideoWeaverRequest.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/background/handlers/checkForOpenedTwitchTabs.ts b/src/background/handlers/checkForOpenedTwitchTabs.ts index 25550daf..485f9eae 100644 --- a/src/background/handlers/checkForOpenedTwitchTabs.ts +++ b/src/background/handlers/checkForOpenedTwitchTabs.ts @@ -19,10 +19,10 @@ export default function checkForOpenedTwitchTabs() { if (isChromium) { const allTabsAreWhitelisted = areAllTabsWhitelisted(tabs); - if (tabs.length === 0 || allTabsAreWhitelisted) { - clearProxySettings(); - } else { + if (tabs.length > 0 && !allTabsAreWhitelisted) { updateProxySettings(); + } else { + clearProxySettings(); } } }); diff --git a/src/background/handlers/onBeforeVideoWeaverRequest.ts b/src/background/handlers/onBeforeVideoWeaverRequest.ts index f4b4cf0a..30adcbf9 100644 --- a/src/background/handlers/onBeforeVideoWeaverRequest.ts +++ b/src/background/handlers/onBeforeVideoWeaverRequest.ts @@ -39,10 +39,10 @@ export default function onBeforeVideoWeaverRequest( const isPurpleScreen = textLower.includes( "https://help.twitch.tv/s/article/ad-experience-on-twitch" ); - let proxy: string | null = null; - if (details.proxyInfo && details.proxyInfo.type !== "direct") { - proxy = `${details.proxyInfo.host}:${details.proxyInfo.port}`; - } + const proxy = + details.proxyInfo && details.proxyInfo.type !== "direct" + ? `${details.proxyInfo.host}:${details.proxyInfo.port}` + : null; const adLog = store.state.adLog.filter( entry => details.timeStamp - entry.timestamp < 1000 * 60 * 60 * 24 * 7 // 7 days From bcd3fe59c16d5084e8dddc10dd98345b03284fd0 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:19:01 +0200 Subject: [PATCH 39/42] =?UTF-8?q?=F0=9F=93=9D=20Update=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20adeae6..cfcc2458 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ TTV LOL PRO removes _most_ livestream ads from Twitch. This is free, don't expec **TTV LOL PRO:** - removes _most_ livestream ads from Twitch, -- lets you whitelist channels (Firefox only), +- lets you whitelist channels, - improves TTV LOL's popup by showing stream status, - lets you add custom primary/fallback proxies. From e2a0782640ef026650c84292b26bc99ac9d09c75 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:31:57 +0200 Subject: [PATCH 40/42] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bug=20when=20updatin?= =?UTF-8?q?g=20proxies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/options.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/options/options.ts b/src/options/options.ts index cd44fb4b..dd723619 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -95,14 +95,14 @@ function main() { proxyUsherRequestsCheckboxElement.addEventListener("change", () => { const checked = proxyUsherRequestsCheckboxElement.checked; store.state.proxyUsherRequests = checked; - if (isChromium && store.state.openedTwitchTabs.length > 0) { + if (isChromium && store.state.chromiumProxyActive) { updateProxySettings(); } }); proxyTwitchWebpageCheckboxElement.checked = store.state.proxyTwitchWebpage; proxyTwitchWebpageCheckboxElement.addEventListener("change", () => { store.state.proxyTwitchWebpage = proxyTwitchWebpageCheckboxElement.checked; - if (isChromium && store.state.openedTwitchTabs.length > 0) { + if (isChromium && store.state.chromiumProxyActive) { updateProxySettings(); } }); @@ -154,7 +154,7 @@ function main() { isAddAllowed: isNormalProxyUrlAllowed, isEditAllowed: isNormalProxyUrlAllowed, onEdit() { - if (isChromium && store.state.openedTwitchTabs.length > 0) { + if (isChromium && store.state.chromiumProxyActive) { updateProxySettings(); } }, From fd76639aea3c337ee4708ab1698575648c0bb197 Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:32:09 +0200 Subject: [PATCH 41/42] =?UTF-8?q?=F0=9F=92=A1=20Add=20clarifying=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/handlers/onTabUpdated.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/background/handlers/onTabUpdated.ts b/src/background/handlers/onTabUpdated.ts index cc7227a6..8d8e3e66 100644 --- a/src/background/handlers/onTabUpdated.ts +++ b/src/background/handlers/onTabUpdated.ts @@ -58,6 +58,9 @@ export default function onTabUpdated( const allTabsAreWhitelisted = areAllTabsWhitelisted( store.state.openedTwitchTabs ); + // We don't check for `store.state.openedTwitchTabs.length === 0` because + // there is always at least one tab open (the one that triggered this + // event). if (!allTabsAreWhitelisted && !store.state.chromiumProxyActive) { updateProxySettings(); } else if (allTabsAreWhitelisted && store.state.chromiumProxyActive) { From 111f0cbf699dae7bb57a19b5cddac6a62e12497f Mon Sep 17 00:00:00 2001 From: younesaassila <47226184+younesaassila@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:52:42 +0200 Subject: [PATCH 42/42] =?UTF-8?q?=E2=9C=A8=20Add=20"Unset=20PAC=20script"?= =?UTF-8?q?=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/options.ts | 18 +++++++++++++++++- src/options/page.html | 1 + src/options/style.css | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/options/options.ts b/src/options/options.ts index dd723619..070281ad 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -2,7 +2,10 @@ import $ from "../common/ts/$"; import { readFile, saveFile } from "../common/ts/file"; import getProxyInfoFromUrl from "../common/ts/getProxyInfoFromUrl"; import isChromium from "../common/ts/isChromium"; -import { updateProxySettings } from "../common/ts/proxySettings"; +import { + clearProxySettings, + updateProxySettings, +} from "../common/ts/proxySettings"; import sendAdLog from "../common/ts/sendAdLog"; import store from "../store"; import getDefaultState from "../store/getDefaultState"; @@ -71,6 +74,9 @@ const adLogClearButtonElement = $("#ad-log-clear-button") as HTMLButtonElement; const exportButtonElement = $("#export-button") as HTMLButtonElement; const importButtonElement = $("#import-button") as HTMLButtonElement; const resetButtonElement = $("#reset-button") as HTMLButtonElement; +const unsetPacScriptButtonElement = $( + "#unset-pac-script-button" +) as HTMLButtonElement; //#endregion const DEFAULT_STATE = Object.freeze(getDefaultState()); @@ -170,6 +176,9 @@ function main() { store.state.adLogEnabled = adLogEnabledCheckboxElement.checked; }); } + if (!isChromium) { + unsetPacScriptButtonElement.style.display = "none"; + } } function isOptimizedProxyUrlAllowed(url: string): AllowedResult { @@ -503,3 +512,10 @@ resetButtonElement.addEventListener("click", () => { store.clear(); window.location.reload(); // Reload page to update UI. }); + +unsetPacScriptButtonElement.addEventListener("click", () => { + if (isChromium) { + clearProxySettings(); + alert("PAC script unset successfully."); + } +}); diff --git a/src/options/page.html b/src/options/page.html index c8b185b3..02e6183a 100644 --- a/src/options/page.html +++ b/src/options/page.html @@ -186,6 +186,7 @@

            Ad log

            +
            diff --git a/src/options/style.css b/src/options/style.css index 5e24eaf7..98546895 100644 --- a/src/options/style.css +++ b/src/options/style.css @@ -91,6 +91,7 @@ input[type="text"]::placeholder { input[type="button"], button { + margin: 0.125rem 0; padding: 0.5rem 1rem; border: 0; border-radius: 6px;