I have my own javascript that I need to test with Greasemonkey. I've never worked with Greasemonkey before; How do I test the script?
I am not testing it on the World Wide Web, I have saved the target page (Firefox > Save page as > Web page, complete), so I am testing it locally.
What is the process? How do I test the script?
IF you make any changes to the javascript and/or DOM, it is possibly detectable by the page.
GreaseMonkey is a Firefox extension that lets you run arbitrary Javascript code against selected web pages. What this means is that GreaseMonkey lets you change how other people's web pages look and how they function (but just in your own browser, of course).
Yes, in theory, a site can deduce the presence of scripts in various situations. This is not foolproof and usually is way too much trouble for the negligible "threat" to the site. (Then again, some webmasters can be obsessive-paranoids about such things. ;) )
Here are some guidelines for troubleshooting Greasemonkey scripts, both in general, and on local copies of webpages.
For testing on local pages (without a local web-server), you must change a setting of Greasemonkey.
Open about:config and set greasemonkey.fileIsGreaseable
to true
Make sure the local copy of the webpage is not in the system's /tmp
or /temp
folder(s). The script will not work reliably, if it is.
Make sure the script source is not in the system's /tmp
or /temp
folder(s). The script will not install if it is.
For a script to work on local files, be sure you have an appropriate @include
directive aimed at the local webpage copy. For example:
// @include file:///D:/web/local%20page%20copies/*
Familiarize yourself with Firefox's error console (CtrlShiftJ) and how it can be used to determine the source of errors in Greasemonkey scripts.
Install Firebug and get familiar with it. Firebug's excellent console functions work great from within a GM script -- although you might have to preface them with unsafeWindow.
.
Test as much of the javascript as you can, that doesn't use GM_ functions, in Firebug's JavaScript console first.
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With