Dive Into Greasemonkey

Teaching an old web new tricks

3.1. Tracking crashes with JavaScript Console

If your user script doesn't appear to be running, the first place to check is JavaScript Console, which lists all script-related errors, including user scripts.

Procedure: Open JavaScript Console

  1. From the Firefox menu, select ToolsJavascript Console.

  2. The console lists all script errors on all pages since you opened Firefox, which can be quite a lot. (You'd be surprised how many high-profile sites have scripts that crash regularly.) Click Clear to clear the list before starting to debug your own user script.

Now refresh the page you were working on to test the user script that doesn't appear to be doing anything. If it is indeed crashing, an exception will be displayed in JavaScript Console.

[Note]

If your user script is crashing, JavaScript Console will display an exception and a line number. Due to the way Greasemonkey injects user scripts into a page, this line number is not actually useful, and you should ignore it. It is not the line number within your user script where the exception occurred.

← Debugging User Scripts
Logging with GM_log →