X
Business

Gmonkey - The Gmail GreaseMonkey API

Gmail has already gained a relatively large market share considering that it requires significant effort to switch mail services, and keep everyone you know in the loop. The new version of Gmail -- which was more of a back-end update -- has given developers access to an easy Greasemonkey API that makes developing plugins or changing the appearance of Gmail a breeze.
Written by Garett Rogers, Inactive

Gmail has already gained a relatively large market share considering that it requires significant effort to switch mail services, and keep everyone you know in the loop. The new version of Gmail -- which was more of a back-end update -- has given developers access to an easy Greasemonkey API that makes developing plugins or changing the appearance of Gmail a breeze.

With the older version of Gmail, developers really had to hack in everything they wanted to modify, but the "new" Gmail makes it easy to capture events, and grab regions of the DOM (interface) that can then manipulated with javascript. Here is a very simple user script that would populate the "gmail" object that can then be used to do what you like:

var gmail = null;

window.addEventListener('load', function() { if (unsafeWindow.gmonkey) { unsafeWindow.gmonkey.load('1.0', init) } }, true);

function init(g) { gmail = g; }

If you are interested in making your own user scripts for Gmail, you can find the documentation for the current version of the API (which technically still isn't supported) here.

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, another wrote these scripts to add functionality to Gmail, and a third wrote two books on the subject (and these docs).

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 could, and hopefully will, encourage developers to roll their own Gmail -- including themed interfaces, and custom functionality.

Editorial standards