Greasemonkey is probably the coolest Firefox extension I’ve found. It lets you write Javascript code that can modify the page being displayed, either to add functionality, change the appearance, or even fetch data from other pages and merge it into the current page.
So, trying to learn this new extension led me to Dive Into Greasemonkey, a superb online book explaining the use of this extension. A few weeks later, I received Greasemonkey Hacks by the same author and was estatic! Dive Into Greasemonkey was a great start to learning GM, it already had the feeling of the O’Reilly Hacks series, and here is a whole book by the very same author.
Maybe the tutorial-like nature of Dive Into Greasemonkey had me looking for something else in GM Hacks, but for some reason I’m having trouble “getting it”. The book starts off with some very good introductory material on GM itself, including a good tutorial on XPath usage, but GM Hacks assumes you know Javascript and the objects that Firefox uses. Having gone through Dive Into Greasemonkey I knew enough of this to get by, but I still find myself looking up reference information on websites rather than finding an explanation in the book.
The Hacks books are often a collection of many people’s scripts and it shows. There are several ways to do some things (such as iterate through all the links on a page), and the scripts in the book switch between them at will. I found one case where the choice was actually explained, but for the others I have to assume that the methods are the same and the choice is a personal preference.
Maybe I had some bad luck, but I found the index to be useless for the things I was looking for when I was developing my own scripts.
My final gripe goes back to the need for more tutorial material in the book. One of the best features of GM is the GM_xmlhttpRequest function, which lets you pull in arbitrary web pages through your script. Nowhere in the book is a description on how to use the function, just POOF, it’s there.
With the complaints above you might think I didn’t like the book. As a tutorial I think you can do better, but I look at it as 100 odd scripts to give me ideas on how I can use GM. And, as I learn more Javascript and get more experienced with GM, I’m able to pull out more and more from the sample scripts to use on my own.
The list of scripts in this book is here, and as you can see, there’s a lot of different things you can do with GM. The URL for the script is usually given so you don’t have to type it in (some are several pages long), though I noticed one that I tried to use had completely changed since the book was published.
This is a good book for someone looking to get ideas for using Greasemonkey and to pull out patterns. Those just getting into it are best to read Dive Into Greasemonkey first and maybe a good Javascript book before tackling this one, though.
(Edit Dec 25, was missing half a sentence from paragraph 5)