An Intro to Greasemonkey


January 17, 2008 17:31 by joel

One of the cooler toys that I've been playing with lately is Greasemonkey. Greasemonkey is an add-on for Firefox that allows you to install custom scripts (written in JavaScript) that can manipulate or add functionality to web pages. There is an entire repository of scripts to check out at userscripts.org that do everything from removing annoying ads to adding incredibly beneficial functionality. User scripting allows you to customize any (and every, if you have the time) web page in pretty much any way that you want.

To get started in the world of Greasemonkey, you first need to install the Add-On. If all you're planning on doing is using scripts that other people have written, then that's all you need. However, if you're gonna get busy and make your own, you'll need a few more components. For anybody that is doing any kind of Javascript developing for the Web, there really is no tool more powerful than Firebug, and writing Greasemonkey scripts is no exception. It offers an easy way to debug your scripts, and also allows you to gather a lot of information about a page in a very intuitive way. 

The other tool that you're going to need is a text editor. Personally, I like Notepad++, but you can really use anything. I won't go into all the details of why I like that particular program. I'll save that for another post. Suffice it to say, if you're going to be editing much code, it's nice to have the features of a text editor that is geared towards that purpose. 

Now you're all set up for writing your own Greasemonkey scripts. The combination of a good text editor and Firebug allows you to develop Javascript with almost as much ease as if you were using a full IDE. One thing to remember before I sign off is that because of the way Greasemonkey accesses the page, scripts are afforded a lot more trust than regular embedded Javascript. What this boils down to is that if you are using other people's scripts, you need to be more careful about where they are coming from. Look for scripts with lots of comments and lots of downloads, signifying that there has been plenty of time for anything subversive to have been discovered. If you are writing your own scripts, even if you have loads of experience with Javascript, you need to pay extra attention to a few details about the Greasemonkey environment. Check out this post for an example, and then the security information on the Greasemonkey wiki (also, just in case you missed it at the top of the wiki, this page should be required reading for anyone writing Greasemonkey scripts). 

I'll include a few links here to some resources, and in my next post I'll introduce you to a script that I wrote, and talk a bit about the Gmail Greasemonkey API



Related posts

Comments

January 20. 2008 20:00

Notepad++ is certainly the way to go!! Have you checked out Paint.NET (http://www.getpaint.net/)? It's another great (free) application.

Adam

January 24. 2008 22:21

Thanks for the comment, Adam. I'll have to try out that application.

joel

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

November 19. 2008 17:17