Dive Into Greasemonkey

Teaching an old web new tricks

1.3. Installing a user script

A Greasemonkey “user script” is a single file, written in Javascript, that customizes one or more web pages.

[Tip]

Many user scripts are available at the Greasemonkey script repository, although there is no requirement to list your scripts there. You may host (and users may install) your script from anywhere. You don't even need a web server; you can install a user script from a local file.

[Note]

A user script's filename must end in .user.js.

The first user script I wrote was called “Butler”. It adds functionality to Google search results.

Procedure: Install the Butler user script

  1. Visit the Butler home page to see a brief description of the functionality that Butler offers. (Not all user scripts have home pages; the only thing Greasemonkey cares about is the script itself.)

  2. Click the link titled “Download version...” (0.3 as of this writing), and you will see the script itself in your browser. It is several pages long.

  3. In the Tools menu, the Install User Script... item should now be enabled. Select it.

  4. A dialog will pop up titled “Install User Script”, which displays the name of the script you are about to install, a brief description, and a list of included and excluded pages. All of this information is taken from the script itself; you'll learn how to define it in Describing your user script with metadata.

  5. Click OK to install the user script.

If all went well, Greasemonkey will pop up an alert saying “Success! Refresh page to see changes.

Now, search for something in Google. In the search results page, there is a line at the top of the results that says “Try your search on: Yahoo, Ask Jeeves, AlltheWeb, ...”. There is also a banner along the top that says “Enhanced by Butler”. All of these were added by the Butler user script.

Further reading

← Installing Greasemonkey
Managing your user scripts →