Skip to content

Instantly share code, notes, and snippets.

@asmaps
Created March 11, 2014 17:03
Show Gist options
  • Save asmaps/9490209 to your computer and use it in GitHub Desktop.
Save asmaps/9490209 to your computer and use it in GitHub Desktop.
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
var left = new Event("keydown");
left.which = 37;
var up = new Event("keydown");
up.which = 38;
var right = new Event("keydown");
right.which = 39;
var down = new Event("keydown");
down.which = 40;
function play() {
document.dispatchEvent(left);
document.dispatchEvent(up);
document.dispatchEvent(right);
document.dispatchEvent(down);
if(!$('.game-message').hasClass('game-over')){
setTimeout(play, 10);
}
else {
setTimeout(function(){$('.retry-button').click();play();}, 1000);
}
}
play();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment