🤯 50% Off! 700+ courses, assessments, and books

Customising GMail with GreaseMonkey

    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.