Google Doodle Basketball – Automatic 45 Points

Enamored by Google Doodle Basketball, but unable to get more than 42 points, I was intrigued at the upper limit of the game’s score. I knew for sure you could get away another shot past 42 once the balls move off the screen, but I was never able to get there.

The easiest solution was to write 40 lines of JavaScript to win for me. I spent some time playing around with the shot times, and was unable to get more than 45. But at least now I have a script that gets 45 points automatically every single time:

// first of all, bring in jQuery to handle triggering events
var s = document.createElement('script');
s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
document.body.appendChild(s);

// let's define our parameters... basically, how long each shot takes
var wait = 1000,
	freethrow = 100,
	jumpshot = 250,
	forthree = 430,
	waydowntown = 650,
	moneyball = 1000,
	timeouts = [
		// click the start button first, and then the first throw
		// needs a lag first or it doesn't register
		1000, 500, 300, 200,
		freethrow, wait, freethrow, wait, freethrow, wait, freethrow,
		wait, jumpshot, wait, jumpshot, wait, jumpshot, wait, jumpshot,
		wait, forthree, wait, forthree, wait, forthree, wait, forthree,
		wait, waydowntown, wait, waydowntown, wait, waydowntown, wait, waydowntown,
		wait, wait, moneyball],
	n = 0;

// now walk through the timeouts array, alternating between clicking down and up
function go () {
	var timeout = timeouts.shift(),
		i = n++;

	if (timeout)
	{
		setTimeout(function () {

			var e = $.Event(i % 2 == 0 ? 'mousedown' : 'mouseup');
			$('canvas').trigger(e);

			go();
		}, timeout);
	}
}
go();

To run it, just load Google’s homepage or their direct basketball doodle page and paste the code into Chrome’s JS console and hit enter. If all goes right, enjoy a perfect score.

Unfortunately, it looks like the timing of the script may be dependent on the performance of the computer it’s being run on. Tested on three different computers, I got surprisingly different results. On my computer, it hasn’t missed a shot yet. On another one, every now and again it misses one. On a third computer, it wasn’t able to get more than a couple in at all. So, if you can’t experience it first hand, either fiddle with the shot timing variables or just enjoy this video: