Greasemonkey Manual:Other Useful Tools

From GreaseSpot Wiki
Jump to: navigation, search
Greasemonkey Manual
Using Greasemonkey
Installing Scripts
Script Management
Monkey Menu
Getting Help
User Script Authoring
Other Useful Tools

This page briefly describes tools that can help in writing user scripts. The descriptions link to more thorough explanations of the tools.

So far, tools are all targeted to help write scripts included in just a content page, and don't explicitly support the fact that Greasemonkey scripts run in a sandbox distinct from the base page. So, noting caveats of how these tools behave or misbehave with the Greasemonkey sandbox model is the major independent content of this page. (other than saying that the tool can work in the Greasemonkey world, that is.)

Note in particular that Greasemonkey does not expose a user script's global object which means no tool can see it and directly help in debugging, but it is possible to pass things to unsafeWindow for temporary help.


The Console² extension enhances the JavaScript console with a number of new features. It allows you to filter by language (CSS, JavaScript, XML), type (error, warning, message), and context (chrome, content). It also includes a search box, a customizable toolbar, and the ability to hide duplicates. For Firefox 1.5, it will rename the JavaScript Console to Error Console.

DOM Inspector

The DOM Inspector extension is a very powerful tool, that lets you fully explore the DOM (Document Object Model) tree of a page, and even gives to limited ability to edit and delete nodes and attributes. it can even inspect the XML tree for browser windows/sub windows, making it equally powerful for extension developers. It is an optional component in the Firefox installer, to get it you must use the Custom Installation option while installing Firefox. Access it via clicking "Tools>DOM Inspector".

It is good for examining where in a document's DOM changes need to be made and for looking at the changes after a script has run.

Note: If you click the "Inspect" button in the inspector, it will reload the URL next to it and no scripts will run. This can either be confusing or helpful.

Extensions that enhance the DOM Inspector are:


The Firebug extension combines the error messages that you see in the JavaScript Console with the inspection abilities of "DOM Inspector", all available in a lower panel on the screen. It also provides a wide array of debugging tools, including object inspection, a debugging environment, and a robust logging mechanism.

Note:: The XMLHttpRequest spy (logger) built into Firebug works for content pages only, and will not catch GM_xmlhttpRequest calls. To watch those you should run an extension like Tamper Data that shows all Firefox requests.

Strongly Note: On the GM lists there have been several reports that running Firebug may cause strange or random errors in GM scripts. If you run Firebug and experience something inexplicable one first step is to right click on the Firebug icon in the status bar, disable it, and then retry. For the reported cases this is fix enough. Anyway, if this fix works for you then please report it because nobody understands the root cause of the conflict.

Reported Conflicts:

Here are some active links that find all mentions of "Firebug" in greasemonkey-users or greasemonkey-dev in case the above list of conflicts has not been recently updated.

JavaScript Console

The JavaScript Console (called Error Console in Firefox 2.0) is built into Firefox (access it via clicking "Tools>JavaScript Console" or "Tools>Error Console"), and shows errors, messages and warnings in JavaScript and CSS, both in the document context and in the chrome (browser source, including extensions) context.

If you have problems installing or using Greasemonkey, installing or running a script, your first step is to turn on the Console and see if errors are reported there. When you activate the Console you may often find a long listing of lots of errors in pages that you have visited. Just click the "clear" button and reload the problem page to see what errors it alone causes.

The Greasemonkey API provides the function GM_log which lets scripts write messages that can be seen on the Console.

[The JavaScript Console also provides an "Evaluate" text input box, which evaluates inside the Chrome window]

Extensions that enhance the JavaScript Console include:

JavaScript Shell

The Squarefree JavaScript Shell bookmarklet opens a shell window for the current document. Often a script can be developed incrementally by testing each step in this shell.

Note: The JavaScript shell's usefulness is limited for user scripting, as it executes code in the window context, not in the sandbox. It does not have access to the Greasemonkey API, nor is it subject to the same security model or XPCNativeWrapper-related problems.

However if you understand sandboxing and the GM API, and don't feed to the Shell anything that involves such unclean complications it works fine. I.e. any clean part of a userscript that works will work in the Shell. The converse is not true - something working in the shell does not mean it will work in a userscript because it might not follow the implicit rules of cleanliness.

Tamper Data

The Tamper Data extension lets one see the details of the get and put traffic caused by a page.


The XPather extension helps a script writer find and test out XPath expressions for use in scripts. It is not accessed through the Tool menu, instead it is integrated into the DOM Inspector and also can be found in the right-click menu.