Getting Started ⬌ Installing Scripts ⬌ Managing Scripts ⬌ Monkey Menu ⬌ Creating Scripts ⬌ Environment ⬌ Other Useful Tools ⬌ API
This page briefly describes tools that can help in writing User scripts. The descriptions link to more thorough explanations of the tools. There may be additional tools available by a search on AMO.
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.
⬆ ⬇ | DOM Inspector | Firebug | JavaScript Console | JavaScript Shell | Live HTTP Headers | Regular Expressions Tester | SQLite Manager | Tamper Data | XPather
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.
The DOM Inspector extension s 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 Live HTTP Headers or 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.
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:
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_script]ing, 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.
The Live HTTP Headers extension lets one see the details of the get and put traffic caused by a page.
The Regular Expressions Tester is a testing tool for regular expressions with color highlighting (including submatches) and helpers for creating expressions.
The SQLite Manager extension allows editing and viewing of the SQLite persistent storage introduced in Greasemonkey 1.13+.
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.
Getting Started ⬌ Installing Scripts ⬌ Managing Scripts ⬌ Monkey Menu ⬌ Creating Scripts ⬌ Environment ⬌ Other Useful Tools ⬌ API
Wiki: GM_log
Wiki: GM_xmlhttpRequest
Wiki: Global_object
Wiki: Greasemonkey_Manual:API
Wiki: Greasemonkey_Manual:Creating_Scripts
Wiki: Greasemonkey_Manual:Environment
Wiki: Greasemonkey_Manual:Getting_Started
Wiki: Greasemonkey_Manual:Installing_Scripts
Wiki: Greasemonkey_Manual:Managing_Scripts
Wiki: Greasemonkey_Manual:Monkey_Menu
Wiki: Sandbox
Wiki: Script_injection_rules
Wiki: Security
Wiki: User_script
Wiki: XPCNativeWrapper
Wiki: unsafeWindow