diff --git a/vaft/vaft-ublock-origin.js b/vaft/vaft-ublock-origin.js index 3c32e03..441dc73 100644 --- a/vaft/vaft-ublock-origin.js +++ b/vaft/vaft-ublock-origin.js @@ -70,7 +70,15 @@ twitch-videoad.js text/javascript var IsPlayerAutoQuality = null; const oldWorker = window.Worker; window.Worker = class Worker extends oldWorker { - constructor(twitchBlobUrl) { + constructor(twitchBlobUrl, options) { + var isTwitchWorker = false; + try { + isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); + } catch {} + if (!isTwitchWorker) { + super(twitchBlobUrl, options); + return; + } var newBlobStr = ` ${getStreamUrlForResolution.toString()} ${getStreamForResolution.toString()} @@ -84,7 +92,7 @@ twitch-videoad.js text/javascript ${tryNotifyTwitch.toString()} ${parseAttributes.toString()} ${getWasmWorkerUrl.toString()} - var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}'); + var workerUrl = getWasmWorkerUrl('${twitchBlobUrl.replaceAll("'", "%27")}'); if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) { declareOptions(self); self.addEventListener('message', function(e) { @@ -108,7 +116,7 @@ twitch-videoad.js text/javascript importScripts(workerUrl); } `; - super(URL.createObjectURL(new Blob([newBlobStr]))); + super(URL.createObjectURL(new Blob([newBlobStr])), options); twitchWorkers.push(this); this.onmessage = function(e) { if (e.data.key == 'ShowAdBlockBanner') { @@ -238,6 +246,7 @@ twitch-videoad.js text/javascript function getWasmWorkerUrl(twitchBlobUrl) { var req = new XMLHttpRequest(); req.open('GET', twitchBlobUrl, false); + req.overrideMimeType("text/javascript"); req.send(); return req.responseText.split("'")[1]; } diff --git a/vaft/vaft.user.js b/vaft/vaft.user.js index fe9d54b..ee50dbe 100644 --- a/vaft/vaft.user.js +++ b/vaft/vaft.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name TwitchAdSolutions (vaft) // @namespace https://github.com/pixeltris/TwitchAdSolutions -// @version 9.0.0 +// @version 10.0.0 // @description Multiple solutions for blocking Twitch ads (vaft) // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js // @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js @@ -82,7 +82,15 @@ var IsPlayerAutoQuality = null; const oldWorker = window.Worker; window.Worker = class Worker extends oldWorker { - constructor(twitchBlobUrl) { + constructor(twitchBlobUrl, options) { + var isTwitchWorker = false; + try { + isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); + } catch {} + if (!isTwitchWorker) { + super(twitchBlobUrl, options); + return; + } var newBlobStr = ` ${getStreamUrlForResolution.toString()} ${getStreamForResolution.toString()} @@ -96,7 +104,7 @@ ${tryNotifyTwitch.toString()} ${parseAttributes.toString()} ${getWasmWorkerUrl.toString()} - var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}'); + var workerUrl = getWasmWorkerUrl('${twitchBlobUrl.replaceAll("'", "%27")}'); if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) { declareOptions(self); self.addEventListener('message', function(e) { @@ -120,7 +128,7 @@ importScripts(workerUrl); } `; - super(URL.createObjectURL(new Blob([newBlobStr]))); + super(URL.createObjectURL(new Blob([newBlobStr])), options); twitchWorkers.push(this); this.onmessage = function(e) { if (e.data.key == 'ShowAdBlockBanner') { @@ -250,6 +258,7 @@ function getWasmWorkerUrl(twitchBlobUrl) { var req = new XMLHttpRequest(); req.open('GET', twitchBlobUrl, false); + req.overrideMimeType("text/javascript"); req.send(); return req.responseText.split("'")[1]; } diff --git a/video-swap-new/video-swap-new-ublock-origin.js b/video-swap-new/video-swap-new-ublock-origin.js index 82e1b72..1032b58 100644 --- a/video-swap-new/video-swap-new-ublock-origin.js +++ b/video-swap-new/video-swap-new-ublock-origin.js @@ -27,7 +27,15 @@ twitch-videoad.js text/javascript var twitchWorkers = []; const oldWorker = window.Worker; window.Worker = class Worker extends oldWorker { - constructor(twitchBlobUrl) { + constructor(twitchBlobUrl, options) { + var isTwitchWorker = false; + try { + isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); + } catch {} + if (!isTwitchWorker) { + super(twitchBlobUrl, options); + return; + } var newBlobStr = ` ${processM3U8.toString()} ${hookWorkerFetch.toString()} @@ -39,7 +47,7 @@ twitch-videoad.js text/javascript ${parseAttributes.toString()} ${onFoundAd.toString()} ${getWasmWorkerUrl.toString()} - var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}'); + var workerUrl = getWasmWorkerUrl('${twitchBlobUrl.replaceAll("'", "%27")}'); if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) { declareOptions(self); self.addEventListener('message', function(e) { @@ -55,7 +63,7 @@ twitch-videoad.js text/javascript importScripts(workerUrl); } ` - super(URL.createObjectURL(new Blob([newBlobStr]))); + super(URL.createObjectURL(new Blob([newBlobStr])), options); twitchWorkers.push(this); this.onmessage = function(e) { // NOTE: Removed adDiv caching as '.video-player' can change between streams? @@ -103,6 +111,7 @@ twitch-videoad.js text/javascript function getWasmWorkerUrl(twitchBlobUrl) { var req = new XMLHttpRequest(); req.open('GET', twitchBlobUrl, false); + req.overrideMimeType("text/javascript"); req.send(); return req.responseText.split("'")[1]; } diff --git a/video-swap-new/video-swap-new.user.js b/video-swap-new/video-swap-new.user.js index a4ce015..e3b487a 100644 --- a/video-swap-new/video-swap-new.user.js +++ b/video-swap-new/video-swap-new.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name TwitchAdSolutions (video-swap-new) // @namespace https://github.com/pixeltris/TwitchAdSolutions -// @version 1.27 +// @version 1.28 // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/video-swap-new/video-swap-new.user.js // @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/video-swap-new/video-swap-new.user.js // @description Multiple solutions for blocking Twitch ads (video-swap-new) @@ -39,7 +39,15 @@ var twitchWorkers = []; const oldWorker = window.Worker; window.Worker = class Worker extends oldWorker { - constructor(twitchBlobUrl) { + constructor(twitchBlobUrl, options) { + var isTwitchWorker = false; + try { + isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv'); + } catch {} + if (!isTwitchWorker) { + super(twitchBlobUrl, options); + return; + } var newBlobStr = ` ${processM3U8.toString()} ${hookWorkerFetch.toString()} @@ -51,7 +59,7 @@ ${parseAttributes.toString()} ${onFoundAd.toString()} ${getWasmWorkerUrl.toString()} - var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}'); + var workerUrl = getWasmWorkerUrl('${twitchBlobUrl.replaceAll("'", "%27")}'); if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) { declareOptions(self); self.addEventListener('message', function(e) { @@ -67,7 +75,7 @@ importScripts(workerUrl); } ` - super(URL.createObjectURL(new Blob([newBlobStr]))); + super(URL.createObjectURL(new Blob([newBlobStr])), options); twitchWorkers.push(this); this.onmessage = function(e) { // NOTE: Removed adDiv caching as '.video-player' can change between streams? @@ -115,6 +123,7 @@ function getWasmWorkerUrl(twitchBlobUrl) { var req = new XMLHttpRequest(); req.open('GET', twitchBlobUrl, false); + req.overrideMimeType("text/javascript"); req.send(); return req.responseText.split("'")[1]; }