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.
16909125? That's amazing, I use that seed in my code too!
Jim - 8th July 2005 10:49 - #
Paul - 8th July 2005 11:25 - #
Rimantas - 8th July 2005 13:38 - #
Brent O'Connor - 8th July 2005 14:18 - #
Tom Clancy - 8th July 2005 15:08 - #
Matt - 8th July 2005 18:31 - #
Alberto - 9th July 2005 00:17 - #
This is interesting stuff. I might start unzipping more XPIs to see what's inside. :-)
On another topic: Congrats at getting a first in your degree!
http://www.flickr.com/photos/simon/24455043/
Dean Edwards - 9th July 2005 00:51 - #
Todd Larason - 9th July 2005 06:05 - #
Anil - 9th July 2005 08:21 - #
Anil: I think that's the most interesting part of this. The PageRank querying service is evidently not intended for public consumption (the comments in the code make that clear), and the spell checking thing is undocumented so we can assume that's not meant to be a public service either. But both of them ARE public - in that you can access them if you know how, and there's no authentication attached to them (well, the PageRank thing has the hash protection but for the spell check you just need to know where it is and what to send it).
They are both also very unlikely to stop working - because Google have deployed thousands (if not millions) of toolbars that rely on them.
I have no idea what the legal situation is on this - that's why I didn't post full code, just the bits that I found amusing. Could using these web services from your own software count as unauthorised access of a computer network or service? I wonder if even Google legal have figured that one out.
Simon Willison - 9th July 2005 11:22 - #
Paul - 9th July 2005 13:18 - #
XUL "the platypus of the internet"? I'm confused. I thought this was the platypus of the internet...
Dave - 9th July 2005 14:40 - #
Chris Meller - 10th July 2005 02:26 - #
Tony - 10th July 2005 09:14 - #
Peter Bowyer - 10th July 2005 09:50 - #
Edit ~/.mozilla/firefox/.../chrome/userChrome.css - it's just a normal CSS file with some extra elements and properties.
You can find the interesting elements and properties by using Tools | DOM Inspector - go to File | Inspect a window, select one of your browser windows, and then browse through the tree. Select an element, and on the right-hand side, you'll be able to select "Computed Style".
For instance, using this method, I was able to find that using the following code in my userChrome.css reduced the height of the main toolbar:
toolbarbutton { height: 35px; }Jim Dabell - 10th July 2005 19:23 - #
zz85 - 10th July 2005 19:46 - #
In addition to the PageRank stuff, poking through the code also reveals the following keyboard shortcuts: alt+O gives the search box keyboard focus (not alt+G like in IE because alt+G opens the Go menu in Firefox) After you have typed your search terms into the box, you can submit your search as follows: enter executes the search and displays the Google search results in the current tab alt+enter executes the search and displays the results in a *NEW* tab shift+enter automatically takes you to the first Google search result for the search terms (what I'm Feeling Lucky does) alt+shift+enter opens the first search result (I'm Feeling Lucky) in a new tabMichael Bolin - 11th July 2005 06:03 - #
Peter Bowyer - 13th July 2005 09:29 - #
ret4wr - 13th July 2005 23:33 - #
frank45 - 14th July 2005 19:42 - #
frank45 - 14th July 2005 19:55 - #
Alex
Alessandro Vernet - 21st July 2005 19:33 - #
So does that mean if I spellcheck a page where I have entered my credit card, the card number gets sent unencrypted to Google?
Steve
Steve Holt - 27th July 2005 12:58 - #
Rakesh Ojha - 15th August 2005 07:25 - #
Carl Ketchum - 14th June 2006 20:07 - #