Fix vaft / video-swap-new #220
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user