I know I don't really mean it, and I love GreaseMonkey, but at times, it does gets frustrating to write for Grease Monkey. Not because of its Wrapped Environment, but more because of the error reporting and all that. So I thought of doing a little experiment on developing GreaseMonkey Scripts. Some premises are
- I hate the obscure errors that say that the error is in greasemonkey.js !!!
- There is lot of functionality that I use across scripts
- Firebug helps me better debugging, and i can do quick experiments with a page using FireBug
- Most times, I prefer to have a local version of the page to which the script will be applied, I am not on the Internet at all times
- GM_registerMenuCommand adds all the menus the TOOLS > GM > UserScript menu, and I hate navigating to that location everytime during testing, just to activate the command
- GM_setValue, puts that value in about:config, and I am not happy about reloading that about:config, and search for greasemonkey everytime some value is changed - maybe a list of values can be used
STEP 1 .
I have all the common utilities in the UTIL directory, and my build.xml just combines all the files to a single GM script. I am currently working on deploying the scripts to GM using ANT, but even though I am modifying config.xml, the changes are not getting picked up.
Its always easier to start if the page is a part of the actual page [After all, GM was invented for teh sole purpose of adding scripts to pages] . So, I wrote a GM simulator that overrides the GM functions and has page specific implementations. Check out the HTML file in the SIGN on Manager folder. The GM Simulator saves all the values as cookies, and also adds the menu to the panel under it.
Here is the GreaseMonkey Simulator file :http://www.box.net/shared/vqfqi8cnbg
Lets see how this approach helps me out !!
My Experimental Workspace