Page 1 of 1

NoScript + setTimeout in Greasemonkey = fail

Posted: Sun Dec 05, 2010 1:53 am
by computerfreaker
I have both NoScript and Greasemonkey installed, and use several GM scripts to add functionality to websites I regularly visit. Lately, I decided to write my own GM script for a page, but my setTimeout calls did nothing - it was like the setTimeout call wasn't there at all. No errors, no warnings, just... nothing.

I started Googling and eventually reached http://userscripts.org/topics/2992?page=1, where I found that NoScript is apparently blocking the setTimeout calls. Sure enough, as soon as I allowed scripts on my site (just my site's domain, none of the adware domains running scripts on the site) the setTimeout calls started working as expected. I revoked the temporary permissions and down went setTimeout again.

Is there anything I can do about this, or am I stuck allowing the site to run scripts so I can use my GM script?

Thanks!

Re: NoScript + setTimeout in Greasemonkey = fail

Posted: Sun Dec 05, 2010 9:46 am
by Giorgio Maone
Unfortunately that's the way it works.
GreaseMonkey uses a sandbox to run its scripts, and that sandbox gets some privileges over the regular content, among which there's the ability to run even if scripts are disabled for the current page.
However, on pages where scripts are disabled, timeouts never fire.รน
This could be worked around by GreaseMonkey developers, by adding a GM_setTimeout() function which uses a timer which is not tied to the content page and runs the delayed function in a sandbox.
It may be worth a RFE.

Re: NoScript + setTimeout in Greasemonkey = fail

Posted: Mon Dec 06, 2010 3:07 pm
by computerfreaker
Thanks for the info. I've filed a RFE, as you suggested, and hopefully the Greasemonkey devs will add GM_setTimeout soon.