From accf04aa3619b6dd40ee1fe63f2d3522bfc5d75d Mon Sep 17 00:00:00 2001 From: pixeltris <6952411+pixeltris@users.noreply.github.com> Date: Tue, 24 Jun 2025 10:49:25 +0100 Subject: [PATCH] Fix vaft intercepting its own request #384 #363 --- vaft/vaft-ublock-origin.js | 5 +++-- vaft/vaft.user.js | 7 ++++--- video-swap-new/video-swap-new-ublock-origin.js | 5 +++-- video-swap-new/video-swap-new.user.js | 7 ++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/vaft/vaft-ublock-origin.js b/vaft/vaft-ublock-origin.js index e021a79..3f13047 100644 --- a/vaft/vaft-ublock-origin.js +++ b/vaft/vaft-ublock-origin.js @@ -1,7 +1,7 @@ twitch-videoad.js text/javascript (function() { if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; } - var ourTwitchAdSolutionsVersion = 4;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script + var ourTwitchAdSolutionsVersion = 5;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script if (window.twitchAdSolutionsVersion && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) { console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -846,7 +846,7 @@ twitch-videoad.js text/javascript } async function handleWorkerFetchRequest(fetchRequest) { try { - const response = await window.fetch(fetchRequest.url, fetchRequest.options); + const response = await window.realFetch(fetchRequest.url, fetchRequest.options); const responseBody = await response.text(); const responseObject = { id: fetchRequest.id, @@ -865,6 +865,7 @@ twitch-videoad.js text/javascript } function hookFetch() { var realFetch = window.fetch; + window.realFetch = realFetch; window.fetch = function(url, init, ...args) { if (typeof url === 'string') { //Check if squad stream. diff --git a/vaft/vaft.user.js b/vaft/vaft.user.js index 276c847..01976e3 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 19.0.0 +// @version 20.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 @@ -13,7 +13,7 @@ // ==/UserScript== (function() { 'use strict'; - var ourTwitchAdSolutionsVersion = 4;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script + var ourTwitchAdSolutionsVersion = 5;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script if (window.twitchAdSolutionsVersion && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) { console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -858,7 +858,7 @@ } async function handleWorkerFetchRequest(fetchRequest) { try { - const response = await window.fetch(fetchRequest.url, fetchRequest.options); + const response = await window.realFetch(fetchRequest.url, fetchRequest.options); const responseBody = await response.text(); const responseObject = { id: fetchRequest.id, @@ -877,6 +877,7 @@ } function hookFetch() { var realFetch = window.fetch; + window.realFetch = realFetch; window.fetch = function(url, init, ...args) { if (typeof url === 'string') { //Check if squad stream. diff --git a/video-swap-new/video-swap-new-ublock-origin.js b/video-swap-new/video-swap-new-ublock-origin.js index ce0d7c3..19cc04d 100644 --- a/video-swap-new/video-swap-new-ublock-origin.js +++ b/video-swap-new/video-swap-new-ublock-origin.js @@ -1,7 +1,7 @@ twitch-videoad.js text/javascript (function() { if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; } - var ourTwitchAdSolutionsVersion = 4;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script + var ourTwitchAdSolutionsVersion = 5;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script if (window.twitchAdSolutionsVersion && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) { console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -575,7 +575,7 @@ twitch-videoad.js text/javascript } async function handleWorkerFetchRequest(fetchRequest) { try { - const response = await window.fetch(fetchRequest.url, fetchRequest.options); + const response = await window.realFetch(fetchRequest.url, fetchRequest.options); const responseBody = await response.text(); const responseObject = { id: fetchRequest.id, @@ -594,6 +594,7 @@ twitch-videoad.js text/javascript } function hookFetch() { var realFetch = window.fetch; + window.realFetch = realFetch; window.fetch = function(url, init, ...args) { if (typeof url === 'string') { if (url.includes('gql')) { diff --git a/video-swap-new/video-swap-new.user.js b/video-swap-new/video-swap-new.user.js index 8e6738b..2041367 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.37 +// @version 1.38 // @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) @@ -13,7 +13,7 @@ // ==/UserScript== (function() { 'use strict'; - var ourTwitchAdSolutionsVersion = 4;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script + var ourTwitchAdSolutionsVersion = 5;// Only bump this when there's a breaking change to Twitch, the script, or there's a conflict with an unmaintained extension which uses this script if (window.twitchAdSolutionsVersion && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) { console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -587,7 +587,7 @@ } async function handleWorkerFetchRequest(fetchRequest) { try { - const response = await window.fetch(fetchRequest.url, fetchRequest.options); + const response = await window.realFetch(fetchRequest.url, fetchRequest.options); const responseBody = await response.text(); const responseObject = { id: fetchRequest.id, @@ -606,6 +606,7 @@ } function hookFetch() { var realFetch = window.fetch; + window.realFetch = realFetch; window.fetch = function(url, init, ...args) { if (typeof url === 'string') { if (url.includes('gql')) {