Remove potential conflict with misc extensions

This commit is contained in:
pixeltris 2021-06-24 10:26:07 +01:00
parent 29a3cdccc8
commit ac04e98d61
5 changed files with 168 additions and 128 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions // @name TwitchAdSolutions
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.8 // @version 1.9
// @description Multiple solutions for blocking Twitch ads // @description Multiple solutions for blocking Twitch ads
// @author pixeltris // @author pixeltris
// @match *://*.twitch.tv/* // @match *://*.twitch.tv/*
@ -576,8 +576,10 @@
return; return;
} }
if (isSeek) { if (isSeek) {
console.log('Force seek to reset player (hopefully fixing any audio desync)'); console.log('Force seek to reset player (hopefully fixing any audio desync) pos:' + player.getPosition() + ' range:' + JSON.stringify(player.getBuffered()));
var pos = player.getPosition();
player.seekTo(0); player.seekTo(0);
player.seekTo(pos);
return; return;
} }
if (isPausePlay) { if (isPausePlay) {
@ -607,17 +609,21 @@
function onContentLoaded() { function onContentLoaded() {
// This stops Twitch from pausing the player when in another tab and an ad shows. // This stops Twitch from pausing the player when in another tab and an ad shows.
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30 // Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
try {
Object.defineProperty(document, 'visibilityState', { Object.defineProperty(document, 'visibilityState', {
get() { get() {
return 'visible'; return 'visible';
} }
}); });
}catch{}
try {
Object.defineProperty(document, 'hidden', { Object.defineProperty(document, 'hidden', {
get() { get() {
return false; return false;
} }
}); });
const block = e => { }catch{}
var block = e => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
@ -626,6 +632,7 @@
document.addEventListener('webkitvisibilitychange', block, true); document.addEventListener('webkitvisibilitychange', block, true);
document.addEventListener('mozvisibilitychange', block, true); document.addEventListener('mozvisibilitychange', block, true);
document.addEventListener('hasFocus', block, true); document.addEventListener('hasFocus', block, true);
try {
if (/Firefox/.test(navigator.userAgent)) { if (/Firefox/.test(navigator.userAgent)) {
Object.defineProperty(document, 'mozHidden', { Object.defineProperty(document, 'mozHidden', {
get() { get() {
@ -639,6 +646,7 @@
} }
}); });
} }
}catch{}
} }
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") { if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
onContentLoaded(); onContentLoaded();

View File

@ -567,8 +567,10 @@ twitch-videoad.js application/javascript
return; return;
} }
if (isSeek) { if (isSeek) {
console.log('Force seek to reset player (hopefully fixing any audio desync)'); console.log('Force seek to reset player (hopefully fixing any audio desync) pos:' + player.getPosition() + ' range:' + JSON.stringify(player.getBuffered()));
var pos = player.getPosition();
player.seekTo(0); player.seekTo(0);
player.seekTo(pos);
return; return;
} }
if (isPausePlay) { if (isPausePlay) {
@ -598,17 +600,21 @@ twitch-videoad.js application/javascript
function onContentLoaded() { function onContentLoaded() {
// This stops Twitch from pausing the player when in another tab and an ad shows. // This stops Twitch from pausing the player when in another tab and an ad shows.
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30 // Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
try {
Object.defineProperty(document, 'visibilityState', { Object.defineProperty(document, 'visibilityState', {
get() { get() {
return 'visible'; return 'visible';
} }
}); });
}catch{}
try {
Object.defineProperty(document, 'hidden', { Object.defineProperty(document, 'hidden', {
get() { get() {
return false; return false;
} }
}); });
const block = e => { }catch{}
var block = e => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
@ -617,6 +623,7 @@ twitch-videoad.js application/javascript
document.addEventListener('webkitvisibilitychange', block, true); document.addEventListener('webkitvisibilitychange', block, true);
document.addEventListener('mozvisibilitychange', block, true); document.addEventListener('mozvisibilitychange', block, true);
document.addEventListener('hasFocus', block, true); document.addEventListener('hasFocus', block, true);
try {
if (/Firefox/.test(navigator.userAgent)) { if (/Firefox/.test(navigator.userAgent)) {
Object.defineProperty(document, 'mozHidden', { Object.defineProperty(document, 'mozHidden', {
get() { get() {
@ -630,6 +637,7 @@ twitch-videoad.js application/javascript
} }
}); });
} }
}catch{}
} }
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") { if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
onContentLoaded(); onContentLoaded();

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions (notify-reload) // @name TwitchAdSolutions (notify-reload)
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.8 // @version 1.9
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js // @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js
// @description Multiple solutions for blocking Twitch ads (notify-reload) // @description Multiple solutions for blocking Twitch ads (notify-reload)
@ -578,8 +578,10 @@
return; return;
} }
if (isSeek) { if (isSeek) {
console.log('Force seek to reset player (hopefully fixing any audio desync)'); console.log('Force seek to reset player (hopefully fixing any audio desync) pos:' + player.getPosition() + ' range:' + JSON.stringify(player.getBuffered()));
var pos = player.getPosition();
player.seekTo(0); player.seekTo(0);
player.seekTo(pos);
return; return;
} }
if (isPausePlay) { if (isPausePlay) {
@ -609,17 +611,21 @@
function onContentLoaded() { function onContentLoaded() {
// This stops Twitch from pausing the player when in another tab and an ad shows. // This stops Twitch from pausing the player when in another tab and an ad shows.
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30 // Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
try {
Object.defineProperty(document, 'visibilityState', { Object.defineProperty(document, 'visibilityState', {
get() { get() {
return 'visible'; return 'visible';
} }
}); });
}catch{}
try {
Object.defineProperty(document, 'hidden', { Object.defineProperty(document, 'hidden', {
get() { get() {
return false; return false;
} }
}); });
const block = e => { }catch{}
var block = e => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
@ -628,6 +634,7 @@
document.addEventListener('webkitvisibilitychange', block, true); document.addEventListener('webkitvisibilitychange', block, true);
document.addEventListener('mozvisibilitychange', block, true); document.addEventListener('mozvisibilitychange', block, true);
document.addEventListener('hasFocus', block, true); document.addEventListener('hasFocus', block, true);
try {
if (/Firefox/.test(navigator.userAgent)) { if (/Firefox/.test(navigator.userAgent)) {
Object.defineProperty(document, 'mozHidden', { Object.defineProperty(document, 'mozHidden', {
get() { get() {
@ -641,6 +648,7 @@
} }
}); });
} }
}catch{}
} }
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") { if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
onContentLoaded(); onContentLoaded();

View File

@ -567,8 +567,10 @@ twitch-videoad.js application/javascript
return; return;
} }
if (isSeek) { if (isSeek) {
console.log('Force seek to reset player (hopefully fixing any audio desync)'); console.log('Force seek to reset player (hopefully fixing any audio desync) pos:' + player.getPosition() + ' range:' + JSON.stringify(player.getBuffered()));
var pos = player.getPosition();
player.seekTo(0); player.seekTo(0);
player.seekTo(pos);
return; return;
} }
if (isPausePlay) { if (isPausePlay) {
@ -598,17 +600,21 @@ twitch-videoad.js application/javascript
function onContentLoaded() { function onContentLoaded() {
// This stops Twitch from pausing the player when in another tab and an ad shows. // This stops Twitch from pausing the player when in another tab and an ad shows.
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30 // Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
try {
Object.defineProperty(document, 'visibilityState', { Object.defineProperty(document, 'visibilityState', {
get() { get() {
return 'visible'; return 'visible';
} }
}); });
}catch{}
try {
Object.defineProperty(document, 'hidden', { Object.defineProperty(document, 'hidden', {
get() { get() {
return false; return false;
} }
}); });
const block = e => { }catch{}
var block = e => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
@ -617,6 +623,7 @@ twitch-videoad.js application/javascript
document.addEventListener('webkitvisibilitychange', block, true); document.addEventListener('webkitvisibilitychange', block, true);
document.addEventListener('mozvisibilitychange', block, true); document.addEventListener('mozvisibilitychange', block, true);
document.addEventListener('hasFocus', block, true); document.addEventListener('hasFocus', block, true);
try {
if (/Firefox/.test(navigator.userAgent)) { if (/Firefox/.test(navigator.userAgent)) {
Object.defineProperty(document, 'mozHidden', { Object.defineProperty(document, 'mozHidden', {
get() { get() {
@ -630,6 +637,7 @@ twitch-videoad.js application/javascript
} }
}); });
} }
}catch{}
} }
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") { if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
onContentLoaded(); onContentLoaded();

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions (notify-strip) // @name TwitchAdSolutions (notify-strip)
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.8 // @version 1.9
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js // @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js
// @description Multiple solutions for blocking Twitch ads (notify-strip) // @description Multiple solutions for blocking Twitch ads (notify-strip)
@ -578,8 +578,10 @@
return; return;
} }
if (isSeek) { if (isSeek) {
console.log('Force seek to reset player (hopefully fixing any audio desync)'); console.log('Force seek to reset player (hopefully fixing any audio desync) pos:' + player.getPosition() + ' range:' + JSON.stringify(player.getBuffered()));
var pos = player.getPosition();
player.seekTo(0); player.seekTo(0);
player.seekTo(pos);
return; return;
} }
if (isPausePlay) { if (isPausePlay) {
@ -609,17 +611,21 @@
function onContentLoaded() { function onContentLoaded() {
// This stops Twitch from pausing the player when in another tab and an ad shows. // This stops Twitch from pausing the player when in another tab and an ad shows.
// Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30 // Taken from https://github.com/saucettv/VideoAdBlockForTwitch/blob/cefce9d2b565769c77e3666ac8234c3acfe20d83/chrome/content.js#L30
try {
Object.defineProperty(document, 'visibilityState', { Object.defineProperty(document, 'visibilityState', {
get() { get() {
return 'visible'; return 'visible';
} }
}); });
}catch{}
try {
Object.defineProperty(document, 'hidden', { Object.defineProperty(document, 'hidden', {
get() { get() {
return false; return false;
} }
}); });
const block = e => { }catch{}
var block = e => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
@ -628,6 +634,7 @@
document.addEventListener('webkitvisibilitychange', block, true); document.addEventListener('webkitvisibilitychange', block, true);
document.addEventListener('mozvisibilitychange', block, true); document.addEventListener('mozvisibilitychange', block, true);
document.addEventListener('hasFocus', block, true); document.addEventListener('hasFocus', block, true);
try {
if (/Firefox/.test(navigator.userAgent)) { if (/Firefox/.test(navigator.userAgent)) {
Object.defineProperty(document, 'mozHidden', { Object.defineProperty(document, 'mozHidden', {
get() { get() {
@ -641,6 +648,7 @@
} }
}); });
} }
}catch{}
} }
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") { if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
onContentLoaded(); onContentLoaded();