Fix vaft intercepting its own request #384 #363

This commit is contained in:
pixeltris
2025-06-24 10:49:25 +01:00
parent ad58a85a04
commit accf04aa36
4 changed files with 14 additions and 10 deletions
@@ -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')) {