NoScript + setTimeout in Greasemonkey = fail

Ask for help about NoScript, no registration needed to post
User avatar
computerfreaker
Senior Member
Posts: 220
Joined: Wed Sep 16, 2009 10:03 pm
Location: USA

NoScript + setTimeout in Greasemonkey = fail

Post 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!
With great power comes great responsibility.
Learn something new every day, and the rest will take care of itself.
Life is a journey, not a destination. Enjoy the trip!
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: NoScript + setTimeout in Greasemonkey = fail

Post 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.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
User avatar
computerfreaker
Senior Member
Posts: 220
Joined: Wed Sep 16, 2009 10:03 pm
Location: USA

Re: NoScript + setTimeout in Greasemonkey = fail

Post by computerfreaker »

Thanks for the info. I've filed a RFE, as you suggested, and hopefully the Greasemonkey devs will add GM_setTimeout soon.
With great power comes great responsibility.
Learn something new every day, and the rest will take care of itself.
Life is a journey, not a destination. Enjoy the trip!
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
Post Reply