mirror of
https://github.com/pixeltris/TwitchAdSolutions.git
synced 2025-04-29 22:24:29 +02:00
Fix ad due to delayed worker hook #277
This commit is contained in:
parent
04b93b2775
commit
0863c6d74b
@ -812,27 +812,7 @@ twitch-videoad.js text/javascript
|
|||||||
return realFetch.apply(this, arguments);
|
return realFetch.apply(this, arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function isWorkerIntact() {
|
|
||||||
// Taken from Adguard Extra
|
|
||||||
const iframe = window.document.createElement('iframe');
|
|
||||||
window.document.body.append(iframe);
|
|
||||||
const cleanWindow = iframe.contentWindow;
|
|
||||||
if (cleanWindow.Worker.toString() === window.Worker.toString()) {
|
|
||||||
iframe.remove();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
iframe.remove();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
function onContentLoaded() {
|
function onContentLoaded() {
|
||||||
if (!isWorkerIntact()) {
|
|
||||||
console.log('Twitch Worker is already hooked');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
|
||||||
declareOptions(window);
|
|
||||||
hookWindowWorker();
|
|
||||||
hookFetch();
|
|
||||||
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
||||||
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
||||||
try {
|
try {
|
||||||
@ -874,11 +854,19 @@ twitch-videoad.js text/javascript
|
|||||||
}
|
}
|
||||||
}catch{}
|
}catch{}
|
||||||
}
|
}
|
||||||
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
if (window.Worker.toString().includes('twitch')) {
|
||||||
onContentLoaded();
|
console.log('Twitch Worker is already hooked');
|
||||||
} else {
|
} else {
|
||||||
window.addEventListener("DOMContentLoaded", function() {
|
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
||||||
|
declareOptions(window);
|
||||||
|
hookWindowWorker();
|
||||||
|
hookFetch();
|
||||||
|
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
||||||
onContentLoaded();
|
onContentLoaded();
|
||||||
});
|
} else {
|
||||||
|
window.addEventListener("DOMContentLoaded", function() {
|
||||||
|
onContentLoaded();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name TwitchAdSolutions (vaft)
|
// @name TwitchAdSolutions (vaft)
|
||||||
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
||||||
// @version 11.0.0
|
// @version 12.0.0
|
||||||
// @description Multiple solutions for blocking Twitch ads (vaft)
|
// @description Multiple solutions for blocking Twitch ads (vaft)
|
||||||
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
|
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
|
||||||
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
|
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
|
||||||
@ -824,27 +824,7 @@
|
|||||||
return realFetch.apply(this, arguments);
|
return realFetch.apply(this, arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function isWorkerIntact() {
|
|
||||||
// Taken from Adguard Extra
|
|
||||||
const iframe = window.document.createElement('iframe');
|
|
||||||
window.document.body.append(iframe);
|
|
||||||
const cleanWindow = iframe.contentWindow;
|
|
||||||
if (cleanWindow.Worker.toString() === window.Worker.toString()) {
|
|
||||||
iframe.remove();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
iframe.remove();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
function onContentLoaded() {
|
function onContentLoaded() {
|
||||||
if (!isWorkerIntact()) {
|
|
||||||
console.log('Twitch Worker is already hooked');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
|
||||||
declareOptions(window);
|
|
||||||
hookWindowWorker();
|
|
||||||
hookFetch();
|
|
||||||
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
||||||
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
||||||
try {
|
try {
|
||||||
@ -886,11 +866,19 @@
|
|||||||
}
|
}
|
||||||
}catch{}
|
}catch{}
|
||||||
}
|
}
|
||||||
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
if (window.Worker.toString().includes('twitch')) {
|
||||||
onContentLoaded();
|
console.log('Twitch Worker is already hooked');
|
||||||
} else {
|
} else {
|
||||||
window.addEventListener("DOMContentLoaded", function() {
|
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
||||||
|
declareOptions(window);
|
||||||
|
hookWindowWorker();
|
||||||
|
hookFetch();
|
||||||
|
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
||||||
onContentLoaded();
|
onContentLoaded();
|
||||||
});
|
} else {
|
||||||
|
window.addEventListener("DOMContentLoaded", function() {
|
||||||
|
onContentLoaded();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -581,27 +581,7 @@ twitch-videoad.js text/javascript
|
|||||||
localStorage.setItem(lsKeyVolume, currentVolumeLS);
|
localStorage.setItem(lsKeyVolume, currentVolumeLS);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
function isWorkerIntact() {
|
|
||||||
// Taken from Adguard Extra
|
|
||||||
const iframe = window.document.createElement('iframe');
|
|
||||||
window.document.body.append(iframe);
|
|
||||||
const cleanWindow = iframe.contentWindow;
|
|
||||||
if (cleanWindow.Worker.toString() === window.Worker.toString()) {
|
|
||||||
iframe.remove();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
iframe.remove();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
function onContentLoaded() {
|
function onContentLoaded() {
|
||||||
if (!isWorkerIntact()) {
|
|
||||||
console.log('Twitch Worker is already hooked');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
|
||||||
declareOptions(window);
|
|
||||||
hookWindowWorker();
|
|
||||||
hookFetch();
|
|
||||||
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
||||||
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
||||||
try {
|
try {
|
||||||
@ -669,11 +649,19 @@ twitch-videoad.js text/javascript
|
|||||||
return realGetItem.apply(this, arguments);
|
return realGetItem.apply(this, arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
if (window.Worker.toString().includes('twitch')) {
|
||||||
onContentLoaded();
|
console.log('Twitch Worker is already hooked');
|
||||||
} else {
|
} else {
|
||||||
window.addEventListener("DOMContentLoaded", function() {
|
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
||||||
|
declareOptions(window);
|
||||||
|
hookWindowWorker();
|
||||||
|
hookFetch();
|
||||||
|
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
||||||
onContentLoaded();
|
onContentLoaded();
|
||||||
});
|
} else {
|
||||||
|
window.addEventListener("DOMContentLoaded", function() {
|
||||||
|
onContentLoaded();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name TwitchAdSolutions (video-swap-new)
|
// @name TwitchAdSolutions (video-swap-new)
|
||||||
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
||||||
// @version 1.29
|
// @version 1.30
|
||||||
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/video-swap-new/video-swap-new.user.js
|
// @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
|
// @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)
|
// @description Multiple solutions for blocking Twitch ads (video-swap-new)
|
||||||
@ -593,27 +593,7 @@
|
|||||||
localStorage.setItem(lsKeyVolume, currentVolumeLS);
|
localStorage.setItem(lsKeyVolume, currentVolumeLS);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
function isWorkerIntact() {
|
|
||||||
// Taken from Adguard Extra
|
|
||||||
const iframe = window.document.createElement('iframe');
|
|
||||||
window.document.body.append(iframe);
|
|
||||||
const cleanWindow = iframe.contentWindow;
|
|
||||||
if (cleanWindow.Worker.toString() === window.Worker.toString()) {
|
|
||||||
iframe.remove();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
iframe.remove();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
function onContentLoaded() {
|
function onContentLoaded() {
|
||||||
if (!isWorkerIntact()) {
|
|
||||||
console.log('Twitch Worker is already hooked');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
|
||||||
declareOptions(window);
|
|
||||||
hookWindowWorker();
|
|
||||||
hookFetch();
|
|
||||||
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
// This stops Twitch from pausing the player when in another tab and an ad shows.
|
||||||
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
|
||||||
try {
|
try {
|
||||||
@ -681,11 +661,19 @@
|
|||||||
return realGetItem.apply(this, arguments);
|
return realGetItem.apply(this, arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
if (window.Worker.toString().includes('twitch')) {
|
||||||
onContentLoaded();
|
console.log('Twitch Worker is already hooked');
|
||||||
} else {
|
} else {
|
||||||
window.addEventListener("DOMContentLoaded", function() {
|
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
||||||
|
declareOptions(window);
|
||||||
|
hookWindowWorker();
|
||||||
|
hookFetch();
|
||||||
|
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
|
||||||
onContentLoaded();
|
onContentLoaded();
|
||||||
});
|
} else {
|
||||||
|
window.addEventListener("DOMContentLoaded", function() {
|
||||||
|
onContentLoaded();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
Loading…
x
Reference in New Issue
Block a user