Fix vaft ad leakage ("Preparing your stream..." screen will be displayed)

This commit is contained in:
pixeltris
2025-10-08 22:23:25 +01:00
parent 2796f5979e
commit 53c18325bc
2 changed files with 12 additions and 5 deletions
+6 -2
View File
@@ -1,7 +1,8 @@
twitch-videoad.js text/javascript twitch-videoad.js text/javascript
(function() { (function() {
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; } if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
var ourTwitchAdSolutionsVersion = 9;// Used to prevent conflicts with outdated versions of the scripts 'use strict';
var ourTwitchAdSolutionsVersion = 10;// Used to prevent conflicts with outdated versions of the scripts
if (typeof unsafeWindow === 'undefined') { if (typeof unsafeWindow === 'undefined') {
unsafeWindow = window; unsafeWindow = window;
} }
@@ -327,13 +328,16 @@ twitch-videoad.js text/javascript
//Here we check the m3u8 for any ads and also try fallback player types if needed. //Here we check the m3u8 for any ads and also try fallback player types if needed.
var responseText = await response.text(); var responseText = await response.text();
var weaverText = null; var weaverText = null;
weaverText = await processM3U8(url, responseText, realFetch, PlayerType2); var fallbackWeaverText = weaverText = await processM3U8(url, responseText, realFetch, PlayerType2);
if (weaverText.includes(AdSignifier)) { if (weaverText.includes(AdSignifier)) {
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3); weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
} }
if (weaverText.includes(AdSignifier)) { if (weaverText.includes(AdSignifier)) {
weaverText = await processM3U8(url, responseText, realFetch, PlayerType4); weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
} }
if (weaverText.includes(AdSignifier)) {
weaverText = fallbackWeaverText;
}
resolve(new Response(weaverText)); resolve(new Response(weaverText));
} else { } else {
resolve(response); resolve(response);
+6 -3
View File
@@ -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 24.0.0 // @version 25.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
@@ -14,7 +14,7 @@
// ==/UserScript== // ==/UserScript==
(function() { (function() {
'use strict'; 'use strict';
var ourTwitchAdSolutionsVersion = 9;// Used to prevent conflicts with outdated versions of the scripts var ourTwitchAdSolutionsVersion = 10;// Used to prevent conflicts with outdated versions of the scripts
if (typeof unsafeWindow === 'undefined') { if (typeof unsafeWindow === 'undefined') {
unsafeWindow = window; unsafeWindow = window;
} }
@@ -340,13 +340,16 @@
//Here we check the m3u8 for any ads and also try fallback player types if needed. //Here we check the m3u8 for any ads and also try fallback player types if needed.
var responseText = await response.text(); var responseText = await response.text();
var weaverText = null; var weaverText = null;
weaverText = await processM3U8(url, responseText, realFetch, PlayerType2); var fallbackWeaverText = weaverText = await processM3U8(url, responseText, realFetch, PlayerType2);
if (weaverText.includes(AdSignifier)) { if (weaverText.includes(AdSignifier)) {
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3); weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
} }
if (weaverText.includes(AdSignifier)) { if (weaverText.includes(AdSignifier)) {
weaverText = await processM3U8(url, responseText, realFetch, PlayerType4); weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
} }
if (weaverText.includes(AdSignifier)) {
weaverText = fallbackWeaverText;
}
resolve(new Response(weaverText)); resolve(new Response(weaverText));
} else { } else {
resolve(response); resolve(response);