vaft buffering mitigation tweaks #492

And ad segment cache memory leak fix
This commit is contained in:
pixeltris
2026-02-26 14:22:30 +00:00
parent b91c184904
commit cebf3d73f0
4 changed files with 74 additions and 54 deletions
@@ -1,7 +1,7 @@
twitch-videoad.js text/javascript
(function() {
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
const ourTwitchAdSolutionsVersion = 22;// Used to prevent conflicts with outdated versions of the scripts
const ourTwitchAdSolutionsVersion = 23;// Used to prevent conflicts with outdated versions of the scripts
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
@@ -351,7 +351,7 @@ twitch-videoad.js text/javascript
streamInfo.NumStrippedAdSegments = 0;
}
streamInfo.IsStrippingAdSegments = hasStrippedAdSegments;
AdSegmentCache.forEach((key, value, map) => {
AdSegmentCache.forEach((value, key, map) => {
if (value < Date.now() - 120000) {
map.delete(key);
}
@@ -591,6 +591,7 @@ twitch-videoad.js text/javascript
}
function gqlRequest(body, playerType) {
if (!gql_device_id) {
gql_device_id = '';
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i += 1) {
gql_device_id += chars.charAt(Math.floor(Math.random() * chars.length));
+4 -3
View File
@@ -1,7 +1,7 @@
// ==UserScript==
// @name TwitchAdSolutions (video-swap-new)
// @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.54
// @version 1.55
// @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';
const ourTwitchAdSolutionsVersion = 22;// Used to prevent conflicts with outdated versions of the scripts
const ourTwitchAdSolutionsVersion = 23;// Used to prevent conflicts with outdated versions of the scripts
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
@@ -363,7 +363,7 @@
streamInfo.NumStrippedAdSegments = 0;
}
streamInfo.IsStrippingAdSegments = hasStrippedAdSegments;
AdSegmentCache.forEach((key, value, map) => {
AdSegmentCache.forEach((value, key, map) => {
if (value < Date.now() - 120000) {
map.delete(key);
}
@@ -603,6 +603,7 @@
}
function gqlRequest(body, playerType) {
if (!gql_device_id) {
gql_device_id = '';
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 32; i += 1) {
gql_device_id += chars.charAt(Math.floor(Math.random() * chars.length));