Greasemonkey Followups #

My Bloglines-del.icio.us integration script was tweaked into a Bloglines-BlogMarks.net script. Too bad that's the one Evan noticed.

The Gmail persistent searches user script was well received. Apparently it made it as far as ETech:

A popular XUL overlay is GreaseMonkey which the author showed could be used to add features to web sites such as persistent searches to GMail all using client side script.

Drew Amato submitted a simple patch that makes the searches box remember its expanded/collapsed state. Norman Rasmussen submitted another that makes sure the searches box ends up between the labels and invites boxes. Both of these have been incorporated into the script.

Sung Kim has spun off the idea into a Google Scholar persistent search add-on. Scholar Monitor lets you keep track of authors, research groups or topics.

Finally, this is only tangentially related, but Brad (of the LiveJournal fame) has come up with an even cooler use for data: URLs: a shared whiteboard (description here). The whiteboard data is refreshed via a base64 encoded PNG that is returned from the server via a XMLHttpRequest object. Crazy stuff.

The Relentless March of Progress #

My bank was acquired by another bank a while back, and I guess the merger has now reached the point where the IT systems must be integrated. I received a letter informing me of this and the specific changes that it entails:

If your Username contains letters, you'll be asked to change to a new numeric ID. Passwords that are eight or more letters will also need to be changed. The new passcode can contain 4-7 letters, numbers or combination of the two...To retain history currently viewed through Cardmember Access [the old system], we recommend that you print a copy or save any paper statements you received...Any alerts that you set up through Cardmember Access will be discontinued when the upgrade process begins.

Upgrade indeed. I'm pretty sure that these arbitrary limits will do wonders for security, and that the user experience will be improved by not having functionality present on the old site. I'm not holding my breath for RSS feeds of account activity or any actual improvements.

Adding Persistent Searches to Gmail #

Update on 12/23/2005: The script has been updated to be compatible with Firefox 1.5. See this entry for more information.

Persistent searches (a.k.a. smart folders or saved searches) seem to be the feature du jour of email clients. Thunderbird has them, Evolution has them, and Mail.app soon will. On the other hand, Gmail is the web mail app to use. While one doesn't normally think of web apps as having such advanced power user features, it recently occurred to me that it should be possible to add persistent searches to Gmail:

  • Persistent Searches ScreenshotIf you haven't already, install the excellent greasemonkey Firefox extension.
  • Open up this user script (in Firefox).
  • From the "Tools" menu, select "Install User Script.." and confirm all of the various prompts.
  • Go to your Gmail account (some refreshing may be necessary).
  • There should now be a "Searches" box on the left size, below the "Labels" and "Invite a friend" ones.
  • Clicking on a search executes the saved query. To refresh result counts, click on the refresh icon in the upper right corner.
  • Use the "Edit searches" link to customize your persistent searches.
  • As a bonus feature, all threads now have a "Toggle font" link which switches the message font to a fixed size one - great for reading source code.

There are some caveats. Saved searches are stored in a cookie. This means that you cannot easily share them between computers. Ideally this could be remedied by storing the searches within Gmail itself (perhaps as a dummy contact or a special filter), but I'm not quite sure how to do that yet. Furthermore, result counts may not be accurate beyond a certain limit (e.g. Gmail itself reports "about 80" results when there are in fact 77). In general, the smaller the result size, the more accurate the search is.

Toggle Font ScreenshotThe user script has a pretty straightforward implementation. It looks for the "Labels" box, and if it finds one, it inserts a "Searches" one. As previously mentioned, I store all the searches in a cookie. To actually perform a search, I created a an XMLHttpRequest object and use it to fetch the search results for each saved search. The response contains in it the total number of messages that matched the query. It would've been nice to use the DOM (and then a JavaScript eval()) to parse it, but this turned out to be more difficult than expected (XMLHttpRequest only provides a parsed DOM for XML documents).

Rather than specifying all of the CSS properties inline or via the JavaScript style object, an approach which separated appearance from structure was used. Effectively, a style sheet was embedded into the user script and inserted upon initialization. This style sheet was also used for the toggling of the font (the message body always appears to be in a <div> of class mb). It also has the advantage of making the script self-contained, since it doesn't depend on an external CSS file. Also for the same goal of encapsulation, the font toggling icon was embedded in the script itself via a data: URL (generated with hixie's tool).

Disclaimer: I happen to work for Google. This script was produced without any internal knowledge of Gmail, and is not endorsed by Google in any way. If you have any problems with it, please only contact me.