RubberStumble: or How to Bounce around the Web

RubberStumble is an extension I wrote for Google Chrome that was inspired by my burning need to Stumble.  I quickly fell in love with Chrome when I discovered it, but not having that stumble button was a deal breaker in the early versions of the browser (version 1 and 2).  I learned something about my habits in those days… Whenever I finished with the webpage I was on, I moved my mouse without thinking to click Stumble.  Then there was a brief moment of confusion when the Stumble button wasn’t there, and I would sigh.  Well, as you can imagine, a man can only put up with that for so long.  I didn’t plan on changing my habits, so I had to change my browser.  Back to FF.

This may seem quite strange if you’re not familiar with StumbleUpon.  Let me describe it briefly.  It started as an extension for FireFox, a toolbar that has a green button on it, the Stumble button.  When you click the button, it takes you to a random page on the internet.  The pages in the stumble database are submitted by users, and divided into categories.  You register your account at StumbleUpon.com, and choose your categories (like computer, math, and cats).

The genius of StumbleUpon is that it will take you to places you never would have thought to go before.  Sure, if you know what you’re looking for on the internet, then you can google for it and probably find it.  But there is a ton of funny and interesting content out there that you would never think to google for.  For example, here is a blog post I just stumbled, a list of 10 places you can never go.  An interesting read that taught me things I would never have googled for.  Here’s another: Bear and Fox comics.  I’ve never heard of ‘em before.  This comic features a product called “Crybaby lemonade”.  Ok, maybe I’m not quite getting that joke, but whatever.  It took me 20 seconds to click stumble, read that comic, and then click stumble again.  YAY!.  So you can see why I could not participate in any non-stumbling browser.

A few months later I was inspired to revisit Chrome when I saw that they had implemented the beginnings of an Extension framework.  I was excited to see what was out there, and I was confident I could find an extension for stumbling.  So, I read the documentation for the Extension framework, and started poking at the Firefox StumbleUpon extension to see what secrets it held.  First I looked at the files of the extension that were installed on my computer.  On windows Xp the files can be found here:

C:\Documents and Settings\<USERNAME>\Application Data\Mozilla\Firefox\Profiles\<somestring>.default\extensions\{AE93811A-5C9A-4d34-8462-F7B864FC4696}

This folder has a compiled jar file and a couple of plain text .js files.  Reading through the file named StumbleupongService.js I discovered the URIs of some other scripts, most importantly: chrome://stumbleupon/content/datastore.js.  Put this URI into firefox (if you have the extension installed, of course) and you get to download a javascript file just under 3k lines.  Now, this file doesn’t reveal all of the secrets of StumbleUpon, but pretty much everything that has to be done browser side is done here (as far as i can tell).  From this file I learned how the password is encrypted to be sent over the wire to the stumbleupon servers.

Next, I used a tool called Fiddler Proxy to get a transcript of a StumbleUpon session, to recreate it with my own extension.  It basically goes like this:

  1. Browser POSTS a login request to StumbleUpon.
  2. SU replies with the results.
  3. Browser POSTS a request for recommended pages for the user.
  4. Browser sends back a list of 3 websites with various metadata on each.
  5. Browser navigates to the first page.
  6. Browser notifies SU that it went to that page.

After step 6, when the button is clicked again then the extension goes either to step 5 or step 3, depending on whether the last batch of recommended pages is exhausted or not.

I had the most difficult time recreating step 1.  See, the password that the user types in is not sent to SU, rather they send the SHA1 hash of that password.  But whenever I tried to build a http request that matched the one I was seeing, I couldn’t get my input to create the same hash.  Turned out that the hash was correct, but the results were encoded differently by mozilla and the library I was using.  My library (courtesy of webtoolkit.info) returned the results encoded as hex, and the mozilla library. returned them encoded in base64.  Once I changed sha1.js to return base64 strings, things started clicking.

I was quickly able to get SU to send me a list of recommendations.  For a while I tried to avoid step #6, but eventually I had to implement it because SU kept sending duplicate pages.  Working with the google chrome browser was pretty easy, the documentation was clear and because the extension framework was small it was easy to take in all of the features.

I originally built the UI to the extension as a browser tool strip, this was the way it was done in the very early stages of the chrome extension API  (before the gallery opened).  The tool strip solution was not very good, the way it worked was that there would be an additional toolbar just for extension controls at the bottom of the browser window.  It’s pretty inconvenient to click on something at the very bottom of the screen though, if you have to go there frequently.  But it worked and I was happy.  Eventually I had to update the interface to use Browser Actions instead of Toolstrip buttons, but this was easy and a much nicer solution.

The official SU extension for chrome was released a few months later, when the gallery opened.  I haven’t tried it yet, but I’m sure its nice.  It is guaranteed to have more features than RubberStumble, like the ability to vote pages up or down, or to write reviews on pages, or to change what category or keyword you are stumbling on.  RubberStumble will only do one thing… stumble.  If I can come up with a way to add more features without taking up more screen space, or without requiring more clicks to get to stumble, I may add some.

RubberStumble can be installed from the extension gallery.  The redmine project page for RubberStumble is public, anyone can post bugs or request features or post on the forum over there.  If you want the source code, you can check it out here by SVN.

5 thoughts on “RubberStumble: or How to Bounce around the Web”

  1. I have a burning need for this extension, but for some reason today it started always directing me to one youtube video. This happens on more than one PC. Hopefully you’re still supporting this and can figure out how to work around what is almost certainly something that SU as done to detect and redirect users of your awesome extension. Thanks -Rance

  2. Hi Rance. I’m still supporting this extenion, I use it myself! But I’m on vacation at the beach this week and I don’t have internet here. I’ll try to get online and check it out but may have to wait untill next Monday if its not an easy fix. Thanks!

  3. Thanks, David! Just an update to say that the problem is still occurring on multiple PCs and after being reinstalled! I’m sure that you are busy, so please take a look when you get the chance. If it helps, the URL that keeps loading is this: http://www.youtube.com/watch?v=U-NEZ0GGkAA

    Thanks again! -Rance

  4. Did you get my email Rance? Try the suggestions in there and write me back please, the extension is still working for me so there is not much i can do. i have another idea i’ll share w/ you by email.

  5. Hello David. I like this extension very much, but for some reason I can no longer find it on chrome web store. Is there any other place I can download it from, because i have it on only one machine and don’t know how to transfer it to another.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>