Home > front end >  Writing tampermonkey met a very strange questions, to answer?
Writing tampermonkey met a very strange questions, to answer?

Time:09-25

the complete code is as follows, a very simple code
 
//==UserScript==
//@ name test
//@ namespace http://tampermonkey.net/
//@ version 0.1
//@ the description the try to take over the world!
//@ the author You
//@ match https://live.bilibili.com/*
//@ grant none
//==/UserScript==

(function () {
'use strict;
; (function func () {
Const injectAnchor=document. GetElementsByClassName (' right action ') [0]
The console. The log (injectAnchor)
If (injectAnchor) {
The console. The log (' find injectAnchor ')
} else {
RequestAnimationFrame ((function () {
Func ()
}))
}
}) ();
}) ();


Is to use the requestAnimationFrame find - action containing the right element of this class, find stopped,
This code directly put the console to perform is no problem (chrome),
But on the tampermonkey will be infinite, find the class also can't stop, the diagram below:



You can see the code has entered the if, but behind or to perform in the else requestAnimationFrame,
Script matching is b to stand any studio and solving is this why?

CodePudding user response:

Try adding a return false

CodePudding user response:

reference 1st floor usecf response:
add a return false try

Tried, still won't do... The problem for me to study all morning, it somehow

CodePudding user response:

refer to the second floor xicichen0129 response:
Quote: refer to 1st floor usecf response:

Try adding a return false

Tried, still won't do... The question I've been studying all morning, it somehow

Do not use a closure, direct definition method then calls also tried, also not line,

CodePudding user response:

The console. The log (' find injectAnchor ');
return false;

CodePudding user response:

reference 4 floor design hand reply:
. The console log (' find injectAnchor ');
return false;
this tried, still won't do,
  • Related