Sunday, November 18, 2007

Gmail API for Greasemonkey

Gmail's new version broke many plug-ins and Greasemonkey scripts, so Google decided to come up with a long-term solution: an API for Greasemonkey.

Greasemonkey is an integral part of the web experience for many experienced users. Google acknowledges that some people are going to change their own experience of our web applications regardless of what we do. Resistance, as they say, is futile. It would also be somewhat hypocritical. After all, a Google employee wrote Greasemonkey in the first place [my note: Aaron Boodman], another wrote these scripts to add functionality to Gmail [my note: Mihai Parparita], and a third wrote two books on the subject (and these docs) [my note: Mark Pilgrim].

Instead, we would like to provide a little help to make such scripts more robust. Instead of finding elements by XPath or DOM traversal, this API provides accessor methods for getting common screen elements. Instead of forcing you to monkey-patch (ahem) our internal functions, this API provides callbacks to call your functions when specific events occur.

This API is experimental. New features and code changes may still cause Greasemonkey scripts to break.

The first Greasemonkey script that uses this API is Mihai Parparita's Macro, which brings additional keyboard shortcuts to Gmail, and the rest of his already famous scripts should also be ported to Gmail's new codebase. The API is not meant to expose messages, contacts or settings, it's more like a convenient way to customize Gmail's interface and functionality without relying too much on the implementation's details.