问题
I've found a lot of similar problems but none equal and no right solution. This is a very strange issue.
I have a simple Greasemonkey script to test the issue:
// ==UserScript==
// @name testdiddio
// @namespace http://userscripts.org/users/useridnumber
// @include https://www.google.it/
// @version 1
// ==/UserScript==
function wait(){
console.info("wait");
setTimeout(wait,1000);
}
console.info("start");
wait();
This is the output from firebug:
start
wait
wait
wait
wait
The wait() function is called 4 times then stops. If I set the Timeout to 100ms the call seems works for at least 10/15 seconds then stops.
I'm using: Firefox 12.0 Greasemonkey 0.9.19
回答1:
This is a bug in Greasemonkey 0.9.19.
A feature was added to allow setTimeout()
to work even when a page's JS was disabled and it introduced some complications (Issues 1549, 1552, and 1553, etc.).
It should be resolved shortly in release 0.9.20, or revert to version 0.9.18.
来源:https://stackoverflow.com/questions/10553274/settimeout-not-always-working-in-greasemonkey