Skip to content

Instantly share code, notes, and snippets.

@eviltester
Last active April 13, 2020 09:49
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 eviltester/cb27abecdd2eda4abbe82e68ddbd32f7 to your computer and use it in GitHub Desktop.
Save eviltester/cb27abecdd2eda4abbe82e68ddbd32f7 to your computer and use it in GitHub Desktop.
1 to 50 solver
// http://zzzscore.com/1to50/en
function clickAllSquares(){
var clickedCount=0;
for(currentNum=1;currentNum<51;currentNum++){
console.log("processing "+currentNum);
cells = document.querySelectorAll("div#grid div");
for(var cellindex=0;cellindex<cells.length;cellindex++){
var foundInt = parseInt(cells[cellindex].innerText);
if(foundInt==currentNum){
cells[cellindex].dispatchEvent(new Event('tap', { 'bubbles': true }));
clickedCount++;
break;
}
}
}
return clickedCount;
}
// need to pass some control back to the browser to re-render so using setInterval
// to give the browser time to act
function initiateClick(){
if(clickAllSquares()>0){
window.setInterval(initiateClick,1);
}
}
initiateClick();
@eviltester
Copy link
Author

eviltester commented Apr 11, 2020

// second version to allow GUI refresh as we click

 function clickASquare(currentNum){    
    var clickedCount=0;
    //console.log("processing "+currentNum);
    cells = document.querySelectorAll("div#grid div");
    for(var cellindex=0;cellindex<cells.length;cellindex++){
        var foundInt = parseInt(cells[cellindex].innerText);
        if(foundInt==currentNum){
            cells[cellindex].dispatchEvent(new Event('tap', { 'bubbles': true }));
            clickedCount++;
            break;            
        }
    }
    return clickedCount;
}

function initiateSpecificClick(whichNum){
    if(clickASquare(whichNum)>0){
        window.setInterval(initiateClick,1,whichNum+1);
    }
}

initiateSpecificClick(1);

@eviltester
Copy link
Author

A very consise JQuery solution

Adapted from David Giordano @3dgiordano

https://twitter.com/3dgiordano/status/1247349919352053763

 x=$("#grid>div"); function fn(){x.trigger("tap").trigger("tap")}; setInterval(fn,0.1);

@eviltester
Copy link
Author

To 'skip the game' and test the high score screen

redirectResultPage(0.00001);

Again - derived from David Giordano's original tweet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment