Fix muted streams pausing when switching tabs on chrome #336
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
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 = 7;// 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 = 8;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof unsafeWindow === 'undefined') {
|
if (typeof unsafeWindow === 'undefined') {
|
||||||
unsafeWindow = window;
|
unsafeWindow = window;
|
||||||
}
|
}
|
||||||
@@ -1018,6 +1018,7 @@ twitch-videoad.js text/javascript
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}catch{}
|
}catch{}
|
||||||
|
let hidden = document.__lookupGetter__('hidden');
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(document, 'hidden', {
|
Object.defineProperty(document, 'hidden', {
|
||||||
get() {
|
get() {
|
||||||
@@ -1030,9 +1031,23 @@ twitch-videoad.js text/javascript
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
};
|
};
|
||||||
document.addEventListener('visibilitychange', block, true);
|
let wasVideoPlaying = true;
|
||||||
document.addEventListener('webkitvisibilitychange', block, true);
|
var visibilityChange = e => {
|
||||||
document.addEventListener('mozvisibilitychange', block, true);
|
if (typeof chrome !== 'undefined') {
|
||||||
|
const videos = document.getElementsByTagName('video');
|
||||||
|
if (videos.length > 0) {
|
||||||
|
if (hidden.apply(document) === true) {
|
||||||
|
wasVideoPlaying = !videos[0].paused && !videos[0].ended;
|
||||||
|
} else if (wasVideoPlaying && !videos[0].ended) {
|
||||||
|
videos[0].play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block(e);
|
||||||
|
};
|
||||||
|
document.addEventListener('visibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('webkitvisibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('mozvisibilitychange', visibilityChange, true);
|
||||||
document.addEventListener('hasFocus', block, true);
|
document.addEventListener('hasFocus', block, true);
|
||||||
try {
|
try {
|
||||||
if (/Firefox/.test(navigator.userAgent)) {
|
if (/Firefox/.test(navigator.userAgent)) {
|
||||||
|
|||||||
+20
-5
@@ -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 22.0.0
|
// @version 23.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 = 7;// 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 = 8;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof unsafeWindow === 'undefined') {
|
if (typeof unsafeWindow === 'undefined') {
|
||||||
unsafeWindow = window;
|
unsafeWindow = window;
|
||||||
}
|
}
|
||||||
@@ -1031,6 +1031,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}catch{}
|
}catch{}
|
||||||
|
let hidden = document.__lookupGetter__('hidden');
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(document, 'hidden', {
|
Object.defineProperty(document, 'hidden', {
|
||||||
get() {
|
get() {
|
||||||
@@ -1043,9 +1044,23 @@
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
};
|
};
|
||||||
document.addEventListener('visibilitychange', block, true);
|
let wasVideoPlaying = true;
|
||||||
document.addEventListener('webkitvisibilitychange', block, true);
|
var visibilityChange = e => {
|
||||||
document.addEventListener('mozvisibilitychange', block, true);
|
if (typeof chrome !== 'undefined') {
|
||||||
|
const videos = document.getElementsByTagName('video');
|
||||||
|
if (videos.length > 0) {
|
||||||
|
if (hidden.apply(document) === true) {
|
||||||
|
wasVideoPlaying = !videos[0].paused && !videos[0].ended;
|
||||||
|
} else if (wasVideoPlaying && !videos[0].ended) {
|
||||||
|
videos[0].play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block(e);
|
||||||
|
};
|
||||||
|
document.addEventListener('visibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('webkitvisibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('mozvisibilitychange', visibilityChange, true);
|
||||||
document.addEventListener('hasFocus', block, true);
|
document.addEventListener('hasFocus', block, true);
|
||||||
try {
|
try {
|
||||||
if (/Firefox/.test(navigator.userAgent)) {
|
if (/Firefox/.test(navigator.userAgent)) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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 = 7;// 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 = 8;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof unsafeWindow === 'undefined') {
|
if (typeof unsafeWindow === 'undefined') {
|
||||||
unsafeWindow = window;
|
unsafeWindow = window;
|
||||||
}
|
}
|
||||||
@@ -789,6 +789,7 @@ twitch-videoad.js text/javascript
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}catch{}
|
}catch{}
|
||||||
|
let hidden = document.__lookupGetter__('hidden');
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(document, 'hidden', {
|
Object.defineProperty(document, 'hidden', {
|
||||||
get() {
|
get() {
|
||||||
@@ -801,9 +802,23 @@ twitch-videoad.js text/javascript
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
};
|
};
|
||||||
document.addEventListener('visibilitychange', block, true);
|
let wasVideoPlaying = true;
|
||||||
document.addEventListener('webkitvisibilitychange', block, true);
|
var visibilityChange = e => {
|
||||||
document.addEventListener('mozvisibilitychange', block, true);
|
if (typeof chrome !== 'undefined') {
|
||||||
|
const videos = document.getElementsByTagName('video');
|
||||||
|
if (videos.length > 0) {
|
||||||
|
if (hidden.apply(document) === true) {
|
||||||
|
wasVideoPlaying = !videos[0].paused && !videos[0].ended;
|
||||||
|
} else if (wasVideoPlaying && !videos[0].ended) {
|
||||||
|
videos[0].play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block(e);
|
||||||
|
};
|
||||||
|
document.addEventListener('visibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('webkitvisibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('mozvisibilitychange', visibilityChange, true);
|
||||||
document.addEventListener('hasFocus', block, true);
|
document.addEventListener('hasFocus', block, true);
|
||||||
try {
|
try {
|
||||||
if (/Firefox/.test(navigator.userAgent)) {
|
if (/Firefox/.test(navigator.userAgent)) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name TwitchAdSolutions (video-swap-new)
|
// @name TwitchAdSolutions (video-swap-new)
|
||||||
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
||||||
// @version 1.40
|
// @version 1.41
|
||||||
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/video-swap-new/video-swap-new.user.js
|
// @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
|
// @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)
|
// @description Multiple solutions for blocking Twitch ads (video-swap-new)
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
var ourTwitchAdSolutionsVersion = 7;// 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 = 8;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof unsafeWindow === 'undefined') {
|
if (typeof unsafeWindow === 'undefined') {
|
||||||
unsafeWindow = window;
|
unsafeWindow = window;
|
||||||
}
|
}
|
||||||
@@ -802,6 +802,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}catch{}
|
}catch{}
|
||||||
|
let hidden = document.__lookupGetter__('hidden');
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(document, 'hidden', {
|
Object.defineProperty(document, 'hidden', {
|
||||||
get() {
|
get() {
|
||||||
@@ -814,9 +815,23 @@
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
};
|
};
|
||||||
document.addEventListener('visibilitychange', block, true);
|
let wasVideoPlaying = true;
|
||||||
document.addEventListener('webkitvisibilitychange', block, true);
|
var visibilityChange = e => {
|
||||||
document.addEventListener('mozvisibilitychange', block, true);
|
if (typeof chrome !== 'undefined') {
|
||||||
|
const videos = document.getElementsByTagName('video');
|
||||||
|
if (videos.length > 0) {
|
||||||
|
if (hidden.apply(document) === true) {
|
||||||
|
wasVideoPlaying = !videos[0].paused && !videos[0].ended;
|
||||||
|
} else if (wasVideoPlaying && !videos[0].ended) {
|
||||||
|
videos[0].play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block(e);
|
||||||
|
};
|
||||||
|
document.addEventListener('visibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('webkitvisibilitychange', visibilityChange, true);
|
||||||
|
document.addEventListener('mozvisibilitychange', visibilityChange, true);
|
||||||
document.addEventListener('hasFocus', block, true);
|
document.addEventListener('hasFocus', block, true);
|
||||||
try {
|
try {
|
||||||
if (/Firefox/.test(navigator.userAgent)) {
|
if (/Firefox/.test(navigator.userAgent)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user