Dive Into Greasemonkey

Teaching an old web new tricks

2.4. Editing your user script

For script authors, the “Manage User Scripts” dialog has a feature that is especially useful: an Edit button to edit an installed script “live”.

Procedure: Edit Hello World source code and see the results

  1. From the menu, select ToolsManage User Scripts.... Greasemonkey will pop up the “Manage User Scripts” dialog.

  2. In the left-hand pane, select Hello World and click Edit. This should open the installed version of Hello World in your favorite text editor. (If it doesn't, verify that .js files are associated with your favorite text editor.)

  3. Change the alert statement to display “Live editing!” instead.

  4. Save your changes in your editor, then go back to your browser and test the change by refreshing any page. You should see the results of your change immediately; there is no need to re-install or “refresh” your user script in any way. You are editing “live”.

[Tip]

When you click Edit in the “Manage User Scripts” dialog, you are “live” editing a copy of your script that is buried deep inside your Firefox profile directory. I've gotten into the habit, once I've finished a “live” editing session, of going back to my text editor one last time and selecting FileSave as..., and saving the user script in another directory. While it's not necessary (Greasemonkey only pays attention to the copy in your profile directory), I prefer to keep the “master copy” of my scripts in another directory with the rest of my work.

← Coding your user script
Debugging User Scripts →