Customising GMail with GreaseMonkey

Share this article

GreaseMonkey is a Firefox extension that allows you to add “user scripts”: bits of JavaScript which are attached to a particular URL or set of URLs that run when that URL is visited. In essence, it’s like having a bookmarklet that does something useful to a page and having that bookmarklet automatically run when certain pages are visited. With the powers of introspection that come from the DOM, JavaScript can make any changes to a page that it likes, and this is where GreaseMonkey comes in very handy. There’s already a repository of useful user scripts that implement customisations to certain sites, from showing prices inclusive of tax on EBay UK to fixing IE-specific bits in the MSDN documentation.

One of the most powerful, though, is Mihai Parparita’s “Add Persistent Searches to GMail”. The script gives GMail the “saved searches” or “virtual folders” feature from desktop mail clients such as Thunderbird, Evolution, or Mail.app. It works by adding a new HTML block to the page which contains your “saved searches”: these searches themselves are saved in a cookie and the cookie is loaded by the script. The script uses Ajax techniques to fetch the number of messages in each saved search in order that they can be dislayed in the HTML block, and updates those figures every two minutes. I can imagine this being rolled into GMail at some point in the future, but until then GreaseMonkey provides the ideal way to prototype such functionality (as the “Edit styles” bookmarklet or the Edit CSS part of the web developer toolbar do for CSS) and to distribute it out to early adopters.

Stuart Langridge and Tony Steidler-DennisonStuart Langridge and Tony Steidler-Dennison
View Author

Stuart Langridge has been a Linux user since 1997, and is quite possibly the only person in the world to have a BSc in Computer Science and Philosophy. He’s also one-quarter of the team at LugRadio, the world's premiere Free and Open Source Software radio show. Tony Steidler-Dennison is a Systems Engineer with Rockwell Collins, Inc., designing avionics and cabin data servers for commercial airliners. He’s also the host of The Roadhouse Podcast, "the finest blues you've never heard."

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week