setTimeout not always working in Greasemonkey

你离开我真会死。 提交于 2019-12-22 08:07:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!