From 401dc9ddd4965b4a4ca804f66a5c36aca51b1947 Mon Sep 17 00:00:00 2001 From: pixeltris <6952411+pixeltris@users.noreply.github.com> Date: Mon, 21 Jul 2025 13:27:13 +0100 Subject: [PATCH] Fix streams pausing when switching tab #414 --- 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 f9e76ec..0426566 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 = 8;// Used to prevent conflicts with outdated versions of the scripts + var ourTwitchAdSolutionsVersion = 9;// Used to prevent conflicts with outdated versions of the scripts if (typeof unsafeWindow === 'undefined') { unsafeWindow = window; } @@ -1019,6 +1019,7 @@ twitch-videoad.js text/javascript }); }catch{} let hidden = document.__lookupGetter__('hidden'); + let webkitHidden = document.__lookupGetter__('webkitHidden'); try { Object.defineProperty(document, 'hidden', { get() { @@ -1036,7 +1037,7 @@ twitch-videoad.js text/javascript if (typeof chrome !== 'undefined') { const videos = document.getElementsByTagName('video'); if (videos.length > 0) { - if (hidden.apply(document) === true) { + if (hidden.apply(document) === true || (webkitHidden && webkitHidden.apply(document) === true)) { wasVideoPlaying = !videos[0].paused && !videos[0].ended; } else if (wasVideoPlaying && !videos[0].ended) { videos[0].play(); diff --git a/vaft/vaft.user.js b/vaft/vaft.user.js index b03a9d1..174b2cf 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 23.0.0 +// @version 24.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 @@ -14,7 +14,7 @@ // ==/UserScript== (function() { 'use strict'; - var ourTwitchAdSolutionsVersion = 8;// Used to prevent conflicts with outdated versions of the scripts + var ourTwitchAdSolutionsVersion = 9;// Used to prevent conflicts with outdated versions of the scripts if (typeof unsafeWindow === 'undefined') { unsafeWindow = window; } @@ -1032,6 +1032,7 @@ }); }catch{} let hidden = document.__lookupGetter__('hidden'); + let webkitHidden = document.__lookupGetter__('webkitHidden'); try { Object.defineProperty(document, 'hidden', { get() { @@ -1049,7 +1050,7 @@ if (typeof chrome !== 'undefined') { const videos = document.getElementsByTagName('video'); if (videos.length > 0) { - if (hidden.apply(document) === true) { + if (hidden.apply(document) === true || (webkitHidden && webkitHidden.apply(document) === true)) { wasVideoPlaying = !videos[0].paused && !videos[0].ended; } else if (wasVideoPlaying && !videos[0].ended) { videos[0].play(); diff --git a/video-swap-new/video-swap-new-ublock-origin.js b/video-swap-new/video-swap-new-ublock-origin.js index 56baad4..dcb06e1 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 = 8;// Used to prevent conflicts with outdated versions of the scripts + var ourTwitchAdSolutionsVersion = 9;// Used to prevent conflicts with outdated versions of the scripts if (typeof unsafeWindow === 'undefined') { unsafeWindow = window; } @@ -790,6 +790,7 @@ twitch-videoad.js text/javascript }); }catch{} let hidden = document.__lookupGetter__('hidden'); + let webkitHidden = document.__lookupGetter__('webkitHidden'); try { Object.defineProperty(document, 'hidden', { get() { @@ -807,7 +808,7 @@ twitch-videoad.js text/javascript if (typeof chrome !== 'undefined') { const videos = document.getElementsByTagName('video'); if (videos.length > 0) { - if (hidden.apply(document) === true) { + if (hidden.apply(document) === true || (webkitHidden && webkitHidden.apply(document) === true)) { wasVideoPlaying = !videos[0].paused && !videos[0].ended; } else if (wasVideoPlaying && !videos[0].ended) { videos[0].play(); diff --git a/video-swap-new/video-swap-new.user.js b/video-swap-new/video-swap-new.user.js index d9085c2..e5a8825 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.41 +// @version 1.42 // @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) @@ -14,7 +14,7 @@ // ==/UserScript== (function() { 'use strict'; - var ourTwitchAdSolutionsVersion = 8;// Used to prevent conflicts with outdated versions of the scripts + var ourTwitchAdSolutionsVersion = 9;// Used to prevent conflicts with outdated versions of the scripts if (typeof unsafeWindow === 'undefined') { unsafeWindow = window; } @@ -803,6 +803,7 @@ }); }catch{} let hidden = document.__lookupGetter__('hidden'); + let webkitHidden = document.__lookupGetter__('webkitHidden'); try { Object.defineProperty(document, 'hidden', { get() { @@ -820,7 +821,7 @@ if (typeof chrome !== 'undefined') { const videos = document.getElementsByTagName('video'); if (videos.length > 0) { - if (hidden.apply(document) === true) { + if (hidden.apply(document) === true || (webkitHidden && webkitHidden.apply(document) === true)) { wasVideoPlaying = !videos[0].paused && !videos[0].ended; } else if (wasVideoPlaying && !videos[0].ended) { videos[0].play();