Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setTimeout broken again in 1.0 #1620

Closed
peci1 opened this issue Aug 31, 2012 · 9 comments
Closed

setTimeout broken again in 1.0 #1620

peci1 opened this issue Aug 31, 2012 · 9 comments
Milestone

Comments

@peci1
Copy link

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

@arantius
Copy link
Collaborator

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
Copy link
Author

peci1 commented Aug 31, 2012

Okay, here is a sample code:

// ==UserScript==
// @name        test
// @namespace   server.gvn.cz/~mp890318
// @include     https://github.com/greasemonkey/greasemonkey/issues/1620
// @grant GM_util
// @grant GM_util.timeout
// @version     1
// ==/UserScript==
alert("test1");
setTimeout('alert("test2")', 500);

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

@BrockA
Copy link
Contributor

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
Copy link
Collaborator

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
Copy link
Contributor

BrockA commented Sep 1, 2012

@arantius,

// ==UserScript==
// @name        _del5
// @namespace   _pc
// @include     https://github.com/greasemonkey/greasemonkey/issues/*
// @grant       none
// ==/UserScript==

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

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

@peci1
Copy link
Author

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
Copy link
Collaborator

arantius commented Sep 6, 2012

Test script: https://gist.github.com/3656920

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 as completed Sep 6, 2012
arantius added a commit that referenced this issue Sep 6, 2012
@AYOUBZER
Copy link

AYOUBZER commented Oct 6, 2019

hello
i have a problem with the BLS , exactelly in the time out ,
the 504 and 502 error codes . after consulting by Cntr+U ( source code) i have found that the time out is fixed by 200 .
setTimeout(function(){send=true;},200);
what i have to do ?????

@Cerberus-tm
Copy link

@AYOUBZER I don't really understand what you mean, but it sounds as though you were talking about a userscript, not the extension itself. In that case, this is not the place to ask for advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants