mirror of
https://github.com/pixeltris/TwitchAdSolutions.git
synced 2024-11-22 02:12:45 +01:00
Sanity checks on worker url
Ref: https://github.com/brave/adblock-resources/pull/186
This commit is contained in:
parent
e73c6fb021
commit
39666c7bb1
@ -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];
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user