Skip to main content

Hacking the Google Doodle for Fun and Profit, Minus the Profit

File under

Like many of my friends (especially my running friends), I’ve gotten a little caught up in Olympic fever this week. Also like many of my friends, I have zero chance of ever making it into the Olympics. But a few days ago, Google released a game that gave all us pathetic slobs a chance to feel what it’s like to take home the gold: The Google Doodle Hurdle Game.

Over at my work, we rarely miss a Google Doodle, and before long, people were bragging about their times in the company-wide chat room. First, somebody posted a 13.5. Not bad … for a chump. Soon after, another employee laid waste to that pathetic time and posted a 12.9. And then, many bloody fingers later, one intrepid soul (not me) posted a 12.5.

Not one to lose a competition over something that most people wouldn’t even bother to enter, let alone consider a competition, or even think about for more than four seconds, I resolved to beat the unbeatable time … until my fingers got tired. That took about two minutes. “Oh well,” I thought, “who cares about winning a stupid game?

But wait. These are the Olympics, damnit, and America isn’t about giving up when things get hard – it’s about finding the fastest, easiest way to get what you want without putting in the work. Drugs! Or … maybe I could use my fingers in a different way. Instead of punching left and right like some kind of trained Olympic monkey, maybe I could hack the doodle, computer style.

How could I do this? Well, all we’re really doing with this game is pressing the left and right buttons over and over in rapid succession, and occasionally jumping when we encounter a hurdle. And computers are especially good at doing these kinds of mundane, repetitive tasks. Could we simulate pressing the left and right keys repeatedly?

jQuery is a popular JavaScript library that contains all sorts of useful functions for everyday web development. One of those handy functions is simulating (or “triggering”) a keypress. So basically, all we have to do is “outsource” (another thing America is good at) the button mashing to jQuery. Mmm, I can taste that gold medal now.

Want to gain Olympic glory and impress your friends?* Set your phaser to “nerd” and follow these steps:

  1. Use Firefox. This won’t work in Chrome.
  2. Since the Doodle is a day old now, bring it up at this special URL (note: you must use this URL, not the one Google gives you when you finish playing the game. Trust me though it’s legit.):

  3. You need to get jQuery on the page somehow. Easiest way to do this is to install the FireQuery extension.

    If you don’t already have it, you will also need Firebug:

  4. Still with me? Great. The nerd force is strong in you. Open Firebug and click the jQuerify tab to get jQuery on the page.
  5. Click the Console tab and paste in this performance-enhancing code:

    // Create keypress events for the left and right arrow buttons
    var left = jQuery.Event("keydown", { keyCode: 37 });
    var right = jQuery.Event("keydown", { keyCode: 39 });

    for (var i=0; i<800; i++) {
    jQuery("#hplogo canvas").trigger(left);
    jQuery("#hplogo canvas").trigger(right);

  6. Click Run or hit Enter.

Huzzah! After a little “practice”, I was able to complete the hurdles in the groin-grabbingly fast time of 0.7 seconds:

Google Hurdle Doodle completed in 0.7 seconds
Note that we don’t even bother jumping over the hurdles. We’re so fast, we just Usain Bolt our way right through them. Aww yeah.

*None of this will happen.