Feed Sign in with OpenID OpenID

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 , , ,

View blog reactions

Next: Less code is more

Previous: London

27 comments

  1. 16909125? That's amazing, I use that seed in my code too!

    Jim - 8th July 2005 10:49 - #

  2. I wondered how long it would be before there was an official version of the Google toolbar, now I can finally stop firing up IE when I want to know the pagerank of the site I'm visiting. Kudos to Google for making such a useful tool (although I guess it's a sound decision commercially given that it effectively brands your browser with their name) available free of charge.

    Paul - 8th July 2005 11:25 - #

  3. Paul, if it is only PR what interests you then PageRank extension is available for quite some time...

    Rimantas - 8th July 2005 13:38 - #

  4. Thank you for the hilarious source code observation! :)

    Brent O'Connor - 8th July 2005 14:18 - #

  5. Always nice to see a SpaceBalls reference in code.

    Tom Clancy - 8th July 2005 15:08 - #

  6. I'm most excited about the spell checker, a public web service that does that with Google reliability is *huge*.

    Matt - 8th July 2005 18:31 - #

  7. Can the toolbar also be made to work with the Mozilla Suite Browser (1.7.x)? I'm guessing there shouldn't be that much difference between Mozilla and Firefox, but the toolbar won't install on my browser.

    Alberto - 9th July 2005 00:17 - #

  8. 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 - #

  9. 16909125 = 0x01020345

    Todd Larason - 9th July 2005 06:05 - #

  10. "a public web service"... is it? Publicly-accessible, but minus a TOS, I'd be concerned about using it.

    Anil - 9th July 2005 08:21 - #

  11. 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 - #

  12. Rimantus: As far as I'm aware, Google frowned upon any unofficial tools that showed pagerank statistics as such extensions required a request to be sent to their servers for each page view. So whilst such extensions probably did exist before now they were bending the rules if not breaking them.

    Paul - 9th July 2005 13:18 - #

  13. XUL "the platypus of the internet"? I'm confused. I thought this was the platypus of the internet...

    Dave - 9th July 2005 14:40 - #

  14. Well, whether or not it's legal, I answered Matt's call, at least partially. For anyone interested in a few more details, as well as a working script that uses AJAX and PHP to spell check, you can check out my blog entry, as well as my code.

    Chris Meller - 10th July 2005 02:26 - #

  15. Checking the spelling of words has been publicly available using Googles Web API for many years now. There are no gaurentees if you use the URI found in the toolbar.

    Tony - 10th July 2005 09:14 - #

  16. Is there any way to make toolbars in Firefox take up less height? The text and icons have very generous top+bottom padding in my browser - far more than the Bookmarks toolbar folder items have. Which is fast encroaching on my browing space... Heck, any way to get toolbars alongside each other rather than just above/below?

    Peter Bowyer - 10th July 2005 09:50 - #

  17. Is there any way to make toolbars in Firefox take up less height?

    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 - #

  18. Following up Chris Meller's implementation, I re-modify the ajax spellchecker for wordpress to support Google's spelling engine. http://www.lab4games.net/zz85/blog/2005/07/10/spot -the-difference-for-spell-check-engine/

    zz85 - 10th July 2005 19:46 - #

  19. 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 tab
    

    Michael Bolin - 11th July 2005 06:03 - #

  20. Jim: thanks a lot, that works! However, it also collapsed the 'Go' button on the main toolbar, which wasn't entirely intended... I've tried using different hierachys of selectors but cannot find anything which will encompass all user-installed toolbars and nothing else. Have you any ideas?

    Peter Bowyer - 13th July 2005 09:29 - #

  21. this sucks

    ret4wr - 13th July 2005 23:33 - #

  22. I still don't know how to get auto spell check on my page !!!

    frank45 - 14th July 2005 19:42 - #

  23. You people are begining to make me feel like a complete ilietarte-xxx illatertat-xxx ellitar-xxx aw -crap--a dumb guy.

    frank45 - 14th July 2005 19:55 - #

  24. Google strikes again! Congratulations Simon for noticing this so quickly and thanks sharing this information with us. For those interested, I put some additional information about the XML payload used by the spell checker on my blog (about XML, XForms, and Web apps).

    Alex

    Alessandro Vernet - 21st July 2005 19:33 - #

  25. 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 - #

  26. I was searching for PR toolbar for Firefox anf I chanced upon to read this very useful Search Result. I must say, this thread was really an edification for me. :) So this is the story behind Google's Tool bar.

    Rakesh Ojha - 15th August 2005 07:25 - #

  27. I'm a volunteer moderator and sure miss this program when my prossesser went bad, I have a version for IE but don't like useing IE, I have windows 98SE and I use Mozilla Firefox, my problem is I want that Google spell checker and it won't download to 98SE anymore, like it did a couple of month ago, even thought it said its for XP it worked just great on 98SE, why do they put limits on it? can anyone help me. there must be an extention for 98, I can't find it. Thanks, Carl

    Carl Ketchum - 14th June 2006 20:07 - #

Comments are closed.

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

A django site