Using and Installing Greasemonkey Scripts

greasemonkey logo
As a programmer, I often have need to tweak or examine little bits of a page’s HTML. Although firebug is a great tool and incredibly flexible, sometime it just doesn’t quite fit the bill. When such cases arise, greasemonkey is a great tool. It allows you to write small bits of javascript to run when a given page loads. One example of where this can be very useful is the following. I wanted to check the meta data on several pages on a website. Although I could easily do this with firebug, it would involve opening firebug for every site and then searching for the meta inside the html tab. It would work, but takes more time than I want to spend on ever page. However, with a quick greasemonkey script, I can have my browser display a small div in the bottom corner that prints out the meta info for any site I visit.

To create your own greasemonkey script, simply install greasemonkey, click on the icon and select New User Script. Then you will be prompted for some info about the script.
Name: what ever you want
Namespace: some unique identifier. A domain name you own is a good option
Description: What ever you want
Includes: http://www.mysite.com/*
Excludes: http://www.mysite.com/boring/*

After you enter this information, it will prompt you to select your editor and you can start writing your script. After you save, your script will be available in your browser when you refresh the page.

Finally, if you wish to copy your user script to another computer, simply save the script as a .user.js file and then drop and drag it into Firefox. Firefox will then prompt you to install the script and you can use it on the new computer.

This entry was posted in JavaScript and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>