Skip to content

Commit

Permalink
Fix vaft / video-swap-new #220
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltris committed Feb 23, 2024
1 parent 0f7864c commit 9bd481a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 20 deletions.
22 changes: 18 additions & 4 deletions vaft/vaft-ublock-origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,24 @@ twitch-videoad.js text/javascript
}
return null;
}
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
function findReactRootNode() {
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
}
if (reactRootNode == null) {
var containerName = Object.keys(rootNode).find(x => x.startsWith('__reactContainer'));
if (containerName != null) {
reactRootNode = rootNode[containerName];
}
}
return reactRootNode;
}
var reactRootNode = findReactRootNode();
if (!reactRootNode) {
console.log('Could not find react root');
return;
}
videoPlayer = findReactNode(reactRootNode, node => node.setPlayerActive && node.props && node.props.mediaPlayerInstance);
videoPlayer = videoPlayer && videoPlayer.props && videoPlayer.props.mediaPlayerInstance ? videoPlayer.props.mediaPlayerInstance : null;
Expand Down
24 changes: 19 additions & 5 deletions vaft/vaft.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name TwitchAdSolutions (vaft)
// @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 5.8.5
// @version 6.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
Expand Down Expand Up @@ -732,10 +732,24 @@
}
return null;
}
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
function findReactRootNode() {
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
}
if (reactRootNode == null) {
var containerName = Object.keys(rootNode).find(x => x.startsWith('__reactContainer'));
if (containerName != null) {
reactRootNode = rootNode[containerName];
}
}
return reactRootNode;
}
var reactRootNode = findReactRootNode();
if (!reactRootNode) {
console.log('Could not find react root');
return;
}
videoPlayer = findReactNode(reactRootNode, node => node.setPlayerActive && node.props && node.props.mediaPlayerInstance);
videoPlayer = videoPlayer && videoPlayer.props && videoPlayer.props.mediaPlayerInstance ? videoPlayer.props.mediaPlayerInstance : null;
Expand Down
20 changes: 15 additions & 5 deletions video-swap-new/video-swap-new-ublock-origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,21 @@ twitch-videoad.js text/javascript
}
return null;
}
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
function findReactRootNode() {
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
}
if (reactRootNode == null) {
var containerName = Object.keys(rootNode).find(x => x.startsWith('__reactContainer'));
if (containerName != null) {
reactRootNode = rootNode[containerName];
}
}
return reactRootNode;
}
var reactRootNode = findReactRootNode();
if (!reactRootNode) {
console.log('Could not find react root');
return;
Expand All @@ -543,7 +553,7 @@ twitch-videoad.js text/javascript
console.log('Could not find player state');
return;
}
if (player.paused) {
if (player.paused || player.core?.paused) {
return;
}
if (isSeek) {
Expand Down
22 changes: 16 additions & 6 deletions video-swap-new/video-swap-new.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name TwitchAdSolutions (video-swap-new)
// @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.22
// @version 1.23
// @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)
Expand Down Expand Up @@ -535,11 +535,21 @@
}
return null;
}
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
function findReactRootNode() {
var reactRootNode = null;
var rootNode = document.querySelector('#root');
if (rootNode && rootNode._reactRootContainer && rootNode._reactRootContainer._internalRoot && rootNode._reactRootContainer._internalRoot.current) {
reactRootNode = rootNode._reactRootContainer._internalRoot.current;
}
if (reactRootNode == null) {
var containerName = Object.keys(rootNode).find(x => x.startsWith('__reactContainer'));
if (containerName != null) {
reactRootNode = rootNode[containerName];
}
}
return reactRootNode;
}
var reactRootNode = findReactRootNode();
if (!reactRootNode) {
console.log('Could not find react root');
return;
Expand All @@ -555,7 +565,7 @@
console.log('Could not find player state');
return;
}
if (player.paused) {
if (player.paused || player.core?.paused) {
return;
}
if (isSeek) {
Expand Down

0 comments on commit 9bd481a

Please sign in to comment.