Simon Willison’s Weblog

Dissecting the Google Firefox Toolbar

Google have finally released a Firefox version of the Google Toolbar, with some nice praise for XUL in to the bargain. Of course, the most interesting part of the toolbar from a geeky point of view is the bit that queries Google’s servers for PageRank. Sure enough, if you download the google-toolbar.xpi file, unzip it, then unzip the google-toolbar.jar file within there’s a file called pagerank.js with all of the juicy details.

To query PageRank, the toolbar makes a standard HTTP request to toolbarqueries.google.com, with the page to query in a parameter along with a hash (presumably to discourage scraping). pagerank.js includes the hash algorithm, with some amusing implementation details:

var GPR_HASH_SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";

function GPR_awesomeHash(value) {
  var kindOfThingAnIdiotWouldHaveOnHisLuggage = 16909125;
  ...
}

The spell check feature (spellcheck.js) is interesting as well. When you click the “Check” button, the toolbar packages any content in form fields up in XML and POSTs it to http://www.google.com/tbproxy/spell. It get backs a simple XML document providing the offset, length and confidence for each spelling error along with a list of suggested alternatives. The user interface stuff is all handled by the extension.

If you want to watch the toolbar in action, I recommend the fantastic LiveHTTPHeaders extension.

This is Dissecting the Google Firefox Toolbar by Simon Willison, posted on 8th July 2005.

Tagged , , ,

Next: Less code is more

Previous: London

Previously hosted at http://simon.incutio.com/archive/2005/07/08/toolbar