Greasing Gmail

Monday, April 21st, 2008

Greasemonkey is a wonderful thing. I enjoy the little (or sometimes not so little) challenges posed by websites that I want to modify. One of the most difficult scripts to write for is Gmail, because of its dynamic nature and its reliance on very large helpings of obfuscated JavaScript and HTML. In addition, you can’t use Firebug to debug scripts, which is a major annoyance, so alert and GM_log become one’s best debugging friends. To make writing Greasemonkey scripts a bit easier, the chaps on the Gmail team supplied an API, which one commenter describes as “truly incredible, forward thinking”. It really is quite nice.

Yesterday I decided to add a little bit of functionality to Gmail. I wanted to be able to isolate messages from a mailing list I subscribe to that nobody had replied to. This would require marking as read “conversations” or messages containing “Re:” at the start of the subject line. The obvious place to put links to do this is along with the other “selectors” above the thread list (Figure 1).

Figure 1
New selectors added

I call them “selectors” simply because Gmail has given each “link” (actually a span) a custom selector attribute. The original markup before adding the links after “Unstarred” looks like this (it isn’t nicely indented in Gmail’s code though):

[HTML]

Select:

All,
None,
Read,
Unread,
Starred,
Unstarred

[/HTML]

So, it looks pretty simple to add a couple of commas and two more spans. And it is, but how to access the containing div is what the Gmail API makes easier. This is the complete script, and we’ll start off with the main loading business and the function that handles the adding of these two new links, addlinks:

(more…)

mulberry sale spyder womens jacket cheap new balance 574 mulberry outlet cheap new balance 574 arcteryx outlet mulberry sale spyder womens jacket mulberry sale spyder womens jacket mulberry outlet mulberry outlet new balance 574

Popular Articles

Top 10 Commentators


Subscribe to this feed! Subscribe by Email!

Random Bits Podcast

You need to download the Flash player from Adobe

Other Sites