Skip to content

Instantly share code, notes, and snippets.

@okcoker
Created August 8, 2012 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okcoker/3297550 to your computer and use it in GitHub Desktop.
Save okcoker/3297550 to your computer and use it in GitHub Desktop.
Press play first, copy this in console and press enter | http://www.google.com/logos/2012/basketball-2012-hp.html
var score_screen = document.getElementById('hplogo_sc').style.opacity,
canvas = document.getElementById("hplogo-c"),
evt,
interval,
counts = 0,
first = 270,
second = 430,
third = 620,
fourth = 850;
var pressFor = function(sec) {
evt = document.createEvent("MouseEvents");
evt.initMouseEvent("mousedown", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
canvas.dispatchEvent(evt);
setTimeout(function() {
evt = document.createEvent("MouseEvents");
evt.initMouseEvent("mouseup", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
canvas.dispatchEvent(evt);
}, sec);
};
var firstPhase = function() {
console.log('firstPhase');
interval = setInterval(function(){
pressFor(first);
if (counts === 23) {
secondPhase();
}
outputCounts();
},first);
};
var secondPhase = function() {
console.log('second phase');
clearInterval(interval);
interval = setInterval(function(){
pressFor(second);
if (counts === 38) {
clearInterval(interval);
thirdPhase();
}
outputCounts();
},second);
};
var thirdPhase = function() {
console.log('third phase');
interval = setInterval(function(){
pressFor(third);
if (counts === 50) {
clearInterval(interval);
fourthPhase();
}
outputCounts();
},third);
};
var fourthPhase = function() {
console.log('fourth phase');
interval = setInterval(function(){
pressFor(fourth);
if (counts === 80) {
console.log('Game Over');
clearInterval(interval);
}
outputCounts();
},fourth);
};
var outputCounts = function() {
counts++;
console.log(counts);
};
if (score_screen !== 1) {
firstPhase();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment