Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion vaft/vaft-ublock-origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ twitch-videoad.js text/javascript
return !hasConflict || hasReinsert;
}
// Replace window.Worker to intercept Twitch's video worker and inject ad-blocking logic
let injectedBlobUrl = null;
function hookWindowWorker() {
// Prevent Twitch from revoking our injected worker blob URL
const originalRevokeObjectURL = URL.revokeObjectURL;
URL.revokeObjectURL = function(url) {
if (url === injectedBlobUrl) return;
return originalRevokeObjectURL.call(this, url);
};
const reinsert = getWorkersForReinsert(window.Worker);
const newWorker = class Worker extends getCleanWorker(window.Worker) {
constructor(twitchBlobUrl, options) {
Expand Down Expand Up @@ -205,7 +212,8 @@ twitch-videoad.js text/javascript
hookWorkerFetch();
eval(workerString);
`;
super(URL.createObjectURL(new Blob([newBlobStr])), options);
injectedBlobUrl = URL.createObjectURL(new Blob([newBlobStr]));
super(injectedBlobUrl, options);
twitchWorkers.length = 0;
twitchWorkers.push(this);
this.addEventListener('message', (e) => {
Expand Down
10 changes: 9 additions & 1 deletion vaft/vaft.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@
return !hasConflict || hasReinsert;
}
// Replace window.Worker to intercept Twitch's video worker and inject ad-blocking logic
let injectedBlobUrl = null;
function hookWindowWorker() {
// Prevent Twitch from revoking our injected worker blob URL
const originalRevokeObjectURL = URL.revokeObjectURL;
URL.revokeObjectURL = function(url) {
if (url === injectedBlobUrl) return;
return originalRevokeObjectURL.call(this, url);
};
const reinsert = getWorkersForReinsert(window.Worker);
const newWorker = class Worker extends getCleanWorker(window.Worker) {
constructor(twitchBlobUrl, options) {
Expand Down Expand Up @@ -216,7 +223,8 @@
hookWorkerFetch();
eval(workerString);
`;
super(URL.createObjectURL(new Blob([newBlobStr])), options);
injectedBlobUrl = URL.createObjectURL(new Blob([newBlobStr]));
super(injectedBlobUrl, options);
twitchWorkers.length = 0;
twitchWorkers.push(this);
this.addEventListener('message', (e) => {
Expand Down
Loading