我发现了很多类似的问题,但没有一个是相同的,也没有正确的解决方案。这是一个很奇怪的问题。setTimeout并不总是在Greasemonkey中工作
我有一个简单的Greasemonkey脚本测试问题:
// ==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();
这是萤火虫的输出:
start
wait
wait
wait
wait
的等待()函数被调用4次,然后停止。如果我将超时设置为100ms,则通话似乎至少可以工作10/15秒,然后停止。
我使用的是: 火狐12.0 的Greasemonkey 0.9.19
也许是因为Greasemonkey脚本在网页完全加载时停止运行? – JoP