Skip to content

Instantly share code, notes, and snippets.

@DarrenCattle
Last active August 29, 2015 14:02
Show Gist options
  • Save DarrenCattle/c0978de461dd30cde2b4 to your computer and use it in GitHub Desktop.
Save DarrenCattle/c0978de461dd30cde2b4 to your computer and use it in GitHub Desktop.
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
var delay = 500;
var i = 0; var d = 0;
var x = 0; var y = 0;
var x1 = 0; var y1 = 0;
for(i = 0; i < 400; i++) {
setTimeout(
(function(i,x,y,d) {
return function() {
if(d==0){
y1=y+1; x1=x+1;
if(!$('.col_' + y1 + '_' + x1).style.backgroundColor) {
$('.col_' + y + '_' + x).click();
$('.col_' + y1 + '_' + x1).click();
y=y1; x=x1;}
else {d=1;}
}
else if(d==1){
y1=y-1; x1=x+1;
if(!$('.col_' + y1 + '_' + x1).style.backgroundColor) {
$('.col_' + y + '_' + x).click();
$('.col_' + y1 + '_' + x1).click();
y=y1; x=x1;}
else {d=2;}
}
else if(d==2){
y1=y-1; x1=x-1;
if(!$('.col_' + y1 + '_' + x1).style.backgroundColor) {
$('.col_' + y + '_' + x).click();
$('.col_' + y1 + '_' + x1).click();
y=y1; x=x1;}
else {d=3;}
}
else if(d==3){
y1=y+1; x1=x-1;
if(!$('.col_' + y1 + '_' + x1).style.backgroundColor) {
$('.col_' + y + '_' + x).click();
$('.col_' + y1 + '_' + x1).click();
y=y1; x=x1;}
else {d=0;}
}
}
})(i,x,y,d), delay);
delay += 500;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment