This commit is contained in:
younesaassila 2024-08-21 12:56:38 +02:00
parent 1d08f79d6e
commit 2ef38f7a88

View File

@ -41,7 +41,8 @@ const pageState: PageState = {
window.fetch = getFetch(pageState);
window.Worker = class Worker extends window.Worker {
const NATIVE_WORKER = window.Worker;
window.Worker = class Worker extends NATIVE_WORKER {
constructor(scriptURL: string | URL, options?: WorkerOptions) {
const fullUrl = toAbsoluteUrl(scriptURL.toString());
const isTwitchWorker = fullUrl.includes(".twitch.tv");
@ -49,6 +50,13 @@ window.Worker = class Worker extends window.Worker {
super(scriptURL, options);
return;
}
// Required for VAFT (>=12.0.0) compatibility.
const isAlreadyHooked = NATIVE_WORKER.toString().includes("twitch");
if (isAlreadyHooked) {
console.error("[TTV LOL PRO] Twitch worker is already hooked.");
super(scriptURL, options);
return;
}
let script = "";
// Fetch Twitch's script, since Firefox Nightly errors out when trying to
// import a blob URL directly.