Created
May 28, 2020 17:35
-
-
Save eviltester/42de6e41d2d1cdd591be0fc024f10920 to your computer and use it in GitHub Desktop.
play tic tac toe org random bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://playtictactoe.org/ | |
function playGame(){ | |
var restart = document.querySelector("div.restart"); | |
if(restart.style.display=="block"){ | |
restart.click() | |
}else{ | |
var squares = document.querySelectorAll("div.square > div:not(.x):not(.o)"); | |
var item=Math.floor(Math.random()*squares.length) | |
squares[item].parentElement.dispatchEvent(new Event('mousedown')); | |
} | |
} | |
var playBot = window.setInterval(playGame,500); | |
//window.clearInterval(playBot); | |
// And my notes that I used during recon when building the code | |
/* | |
restart div overlay | |
div.restart | |
document.querySelector("div.restart").click() | |
document.querySelector("div.restart").style.display | |
div.square | |
div.square > div:not(.x):not(.o) | |
document.querySelectorAll("div.square")[0].dispatchEvent(new Event('mousedown')) | |
document.querySelectorAll("div.square > div:not(.x):not(.o)")[0].parentElement.dispatchEvent(new Event('mousedown')) | |
true | |
document.querySelectorAll("div.square > div:not(.x):not(.o)")[0].dispatchEvent(new Event('mousedown', {"bubbles":true})) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was inspired to automate this game based on Angie Jones video using Java and WebDriver to provide another example of automating the same game.
Angie's video:
https://www.youtube.com/watch?v=nZZD2aFAm_A