I am attempting to create a script that can extract data from my rock paper scissors gameplay on a specific website ():
var h_choice = document.querySelectorAll(".play-page-gamer__choices")[0];
var h_rock = document.querySelectorAll(".play-page-gamer__choices")[0]
.childNodes[1].childNodes[2];
var h_paper = document.querySelectorAll(".play-page-gamer__choices")[0]
.childNodes[3].childNodes[2];
var h_scissors = document.querySelectorAll(".play-page-gamer__choices")[0]
.childNodes[5].childNodes[2];
game = [];
h_rock.addEventListener("click", () => {
console.log("rock");
});
h_paper.addEventListener("click", () => {
console.log("paper");
});
h_scissors.addEventListener("click", () => {
console.log("scissors");
});
This is just a snapshot of the code, let me know if you need more details 😁
I have set up event listeners to detect which choice I make through clicking but unfortunately, the events are not triggered when I click on the image.
Upon clicking an image, I expect to see a message in the console like 'paper' if I click on paper, however, nothing is displayed. Interestingly, when I simulate a click using h_paper.click(), it does return 'paper' in the console.
I even checked if the event listener was removed, but it appears intact as seen in the array with my function:
() => {
console.log('paper')
}