mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-11 05:31:56 +00:00
4.19.2
* Fixed: FrankerFaceZ failing to load after today's Twitch update.
This commit is contained in:
parent
0507300387
commit
f48ed62454
3 changed files with 55 additions and 4 deletions
|
@ -195,6 +195,57 @@ export default class Fine extends Module {
|
|||
return null;
|
||||
}
|
||||
|
||||
searchNode(node, criteria, max_depth=15, depth=0, traverse_roots = true) {
|
||||
if ( ! node )
|
||||
node = this.react;
|
||||
else if ( node._reactInternalFiber )
|
||||
node = node._reactInternalFiber;
|
||||
else if ( node instanceof Node )
|
||||
node = this.getReactInstance(node);
|
||||
|
||||
if ( ! node || node._ffz_no_scan || depth > max_depth )
|
||||
return null;
|
||||
|
||||
if ( typeof criteria === 'string' ) {
|
||||
const wrapper = this._wrappers.get(criteria);
|
||||
if ( ! wrapper )
|
||||
throw new Error('invalid critera');
|
||||
|
||||
if ( ! wrapper._class )
|
||||
return null;
|
||||
|
||||
criteria = n => n && n.constructor === wrapper._class;
|
||||
}
|
||||
|
||||
if ( node && criteria(node) )
|
||||
return node;
|
||||
|
||||
if ( node.child ) {
|
||||
let child = node.child;
|
||||
while(child) {
|
||||
const result = this.searchNode(child, criteria, max_depth, depth+1, traverse_roots);
|
||||
if ( result )
|
||||
return result;
|
||||
child = child.sibling;
|
||||
}
|
||||
}
|
||||
|
||||
const inst = node.stateNode;
|
||||
if ( traverse_roots && inst && inst.props && inst.props.root ) {
|
||||
const root = inst.props.root._reactRootContainer;
|
||||
if ( root ) {
|
||||
let child = root._internalRoot && root._internalRoot.current || root.current;
|
||||
while(child) {
|
||||
const result = this.searchNode(child, criteria, max_depth, depth+1, traverse_roots);
|
||||
if ( result )
|
||||
return result;
|
||||
|
||||
child = child.sibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
searchTree(node, criteria, max_depth=15, depth=0, traverse_roots = true) {
|
||||
if ( ! node )
|
||||
node = this.react;
|
||||
|
@ -218,7 +269,7 @@ export default class Fine extends Module {
|
|||
}
|
||||
|
||||
const inst = node.stateNode;
|
||||
if ( inst && criteria(inst) )
|
||||
if ( inst && criteria(inst, node) )
|
||||
return inst;
|
||||
|
||||
if ( node.child ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue