From 69f098d882eba30a6466ad99eadf487c0aa68139 Mon Sep 17 00:00:00 2001 From: pixeltris <6952411+pixeltris@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:25:32 +0100 Subject: [PATCH] Fix conflicts with other solutions #282 --- vaft/vaft-ublock-origin.js | 6 +++++- vaft/vaft.user.js | 6 +++++- video-swap-new/video-swap-new-ublock-origin.js | 6 +++++- video-swap-new/video-swap-new.user.js | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/vaft/vaft-ublock-origin.js b/vaft/vaft-ublock-origin.js index 32e3740..76a4b77 100644 --- a/vaft/vaft-ublock-origin.js +++ b/vaft/vaft-ublock-origin.js @@ -27,12 +27,16 @@ twitch-videoad.js text/javascript var IsPlayerAutoQuality = null; const oldWorker = window.Worker; function hookWindowWorker() { - window.Worker = class Worker extends oldWorker { + var newWorker = window.Worker = class Worker extends oldWorker { constructor(twitchBlobUrl, options) { var isTwitchWorker = false; try { isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); } catch {} + if (newWorker.toString() !== window.Worker.toString()) { + console.log('Multiple twitch adblockers installed. Skipping Worker hook (vaft)'); + isTwitchWorker = false; + } if (!isTwitchWorker) { super(twitchBlobUrl, options); return; diff --git a/vaft/vaft.user.js b/vaft/vaft.user.js index e5fa07e..c8a8089 100644 --- a/vaft/vaft.user.js +++ b/vaft/vaft.user.js @@ -39,12 +39,16 @@ var IsPlayerAutoQuality = null; const oldWorker = window.Worker; function hookWindowWorker() { - window.Worker = class Worker extends oldWorker { + var newWorker = window.Worker = class Worker extends oldWorker { constructor(twitchBlobUrl, options) { var isTwitchWorker = false; try { isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); } catch {} + if (newWorker.toString() !== window.Worker.toString()) { + console.log('Multiple twitch adblockers installed. Skipping Worker hook (vaft)'); + isTwitchWorker = false; + } if (!isTwitchWorker) { super(twitchBlobUrl, options); return; diff --git a/video-swap-new/video-swap-new-ublock-origin.js b/video-swap-new/video-swap-new-ublock-origin.js index d71ceed..ed9621f 100644 --- a/video-swap-new/video-swap-new-ublock-origin.js +++ b/video-swap-new/video-swap-new-ublock-origin.js @@ -26,12 +26,16 @@ twitch-videoad.js text/javascript var twitchWorkers = []; const oldWorker = window.Worker; function hookWindowWorker() { - window.Worker = class Worker extends oldWorker { + var newWorker = window.Worker = class Worker extends oldWorker { constructor(twitchBlobUrl, options) { var isTwitchWorker = false; try { isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); } catch {} + if (newWorker.toString() !== window.Worker.toString()) { + console.log('Multiple twitch adblockers installed. Skipping Worker hook (video-swap-new)'); + isTwitchWorker = false; + } if (!isTwitchWorker) { super(twitchBlobUrl, options); return; diff --git a/video-swap-new/video-swap-new.user.js b/video-swap-new/video-swap-new.user.js index 81f3887..d6a5f45 100644 --- a/video-swap-new/video-swap-new.user.js +++ b/video-swap-new/video-swap-new.user.js @@ -38,12 +38,16 @@ var twitchWorkers = []; const oldWorker = window.Worker; function hookWindowWorker() { - window.Worker = class Worker extends oldWorker { + var newWorker = window.Worker = class Worker extends oldWorker { constructor(twitchBlobUrl, options) { var isTwitchWorker = false; try { isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); } catch {} + if (newWorker.toString() !== window.Worker.toString()) { + console.log('Multiple twitch adblockers installed. Skipping Worker hook (video-swap-new)'); + isTwitchWorker = false; + } if (!isTwitchWorker) { super(twitchBlobUrl, options); return;