I’ve taken different approaches to find out whether JS is enabled / running correctly.
Usually I just do something like this:
$('.jstest').html('JavaScript works.');
<p class='jstest'></p>
So, I can see whether I accidentally disabled JS, or I have a syntax error and JS is not running correctly without consulting firebug.
Now, this requires me to modify every single page. With Greasemonkey I thought this problem could be solved, without interfering with the site. But so far I couldn’t find a way. I’ve tried:
- inserting a right after the opening body
- inserting a script tag with a src to a remote server
Both ways still work, even if the JS on the site is not executed because of script / syntax errors.
Now, I’ve tried to insert a noscript container with Greasemonkey and disable js to find out whether the JS on the site reacts while Greasemonkey is not affected. No, GM does not work without JS 😛
It seems like GM is running independently from all other scripts on that site. Anybody know a solution?
Greasemonkey will run, even if the target page has JS disabled, because GM runs in its own, privileged sandbox.
You can test if JS is available on the target page by injecting a JS function and then using GM to see if that function actually ran.
Here’s a script that does that:
Note that the two
@includedirectives are for a site where I allow and disallow JS, respectively (using the NoScript add-on). (Script tests pass.)