Skip to content

Instantly share code, notes, and snippets.

@eviltester
Last active April 13, 2020 09:49
Show Gist options
  • Save eviltester/cb27abecdd2eda4abbe82e68ddbd32f7 to your computer and use it in GitHub Desktop.
Save eviltester/cb27abecdd2eda4abbe82e68ddbd32f7 to your computer and use it in GitHub Desktop.

Revisions

  1. eviltester revised this gist Apr 11, 2020. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -27,5 +27,3 @@ function initiateClick(){
    }

    initiateClick();

    // TODO: this could be much more efficient
  2. eviltester created this gist Apr 11, 2020.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    // 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();

    // TODO: this could be much more efficient