本文介绍了setTimeout并非始终在Greasemonkey中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了很多类似的问题,但是不尽相同,也没有正确的解决方案.这是一个非常奇怪的问题.

I've found a lot of similar problems but none equal and no right solution. This is a very strange issue.

我有一个简单的Greasemonkey脚本来测试问题:

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();

这是萤火虫的输出:

start
wait
wait
wait
wait

wait()函数被调用4次,然后停止.如果我将超时"设置为100ms,则通话似乎至少可以运行10/15秒,然后停止.

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.

我正在使用:Firefox 12.0Greasemonkey 0.9.19

I'm using:Firefox 12.0Greasemonkey 0.9.19

推荐答案

这是Greasemonkey 0.9.19中的错误.
添加了一项功能,即使页面的JS被禁用,它也允许setTimeout()工作,并且引入了一些复杂性(问题 1549 1552 1553 等).

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.).

应该很快在0.9.20版中解决该问题,或者恢复到0.9.18版.

It should be resolved shortly in release 0.9.20, or revert to version 0.9.18.

这篇关于setTimeout并非始终在Greasemonkey中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 04:09