setTimeout broken again in 1.0 #1620

peci1 opened this Issue Aug 31, 2012 · 7 comments


None yet

3 participants

peci1 commented Aug 31, 2012

Hello, bad news... setTimeout() ceased working for me after update to 1.0

I tried setting:
@grant none
@grant GM_util
@grant GM_util.timeout
@grant setTimeout
none of which work.

Thanks for any help ;)


You're going to need to be much more specific; works fine for me.

Provide a link to an exact script, the shorter the better, that doesn't work for you. (Plus, setTimeout is not a Greasemonkey API, so @grant is unrelated.)

peci1 commented Aug 31, 2012

Okay, here is a sample code:

// ==UserScript==
// @name        test
// @namespace
// @include
// @grant GM_util
// @grant GM_util.timeout
// @version     1
// ==/UserScript==
setTimeout('alert("test2")', 500);

The string "test1" is shown, whereas "test2" is never shown.

BrockA commented Sep 1, 2012

@peci1, your test script would probably work if you used @grant none, and no other grants.

However, that is a poor way to use setTimeout. Avoid "eval" strings whenever you can.

A more proper usage, will also work irregardless of the @grant settings.

//-- Traditional
setTimeout ( function () {
    alert ("test2");
    }, 500

//-- Okay for most modern browsers (certainly for Greasemonkey)
setTimeout (alert, 500, "test2");
arantius commented Sep 1, 2012

The issue originally from #1318 is indeed happening in the @grant none case. The underlying Firefox bug is fixed and slated to be released in Firefox 16.

Otherwise, in 15, I am indeed seeing strange behavior that I've yet to 100% explain.

BrockA commented Sep 1, 2012


// ==UserScript==
// @name        _del5
// @namespace   _pc
// @include*
// @grant       none
// ==/UserScript==

setTimeout('alert("test2")', 500);

works fine for me.
(FF 15.0, GM 1.0, Win XP)

peci1 commented Sep 3, 2012

Seems to be a little bit weird.

The script from @BrockA works fine.

My script works well on most pages (after changing the include clause), but when I run it a lot of times, then the second alert stops working. Even duplicating the tab with bad behavior helps, the duplicated page shows two alerts.

Most of my setTimeout statements have started to work as expected yesterday (but I don't know of a recent update to FF or GM).

arantius commented Sep 6, 2012

Test script:

Behaves as expected (setTimeout broken after alert); the bug from issue #1318 is back in the grant-none mode. If I edit none to GM_log, then it works again as expected (I see three alerts).

If I edit the setTimeout lines, then in the legacy case I see one global-model alert, then two tab-modal alerts (not exactly broken, but admittedly weird; this will go away in Firefox 16). If I then go back to grant none, I see one tab-modal alert, and then still brokenness as expected.

@arantius arantius closed this in 9acad2d Sep 6, 2012
@arantius arantius added a commit that referenced this issue Sep 6, 2012
@arantius arantius Fix alert + setTimeout in grant none case.
Fixes #1620
Refs #1318
Refs #1350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment