I am having some trouble writing a script for actioning the clicking of a button on a website via javascript console (forgive me I am a total noob when it comes to js).
I have to following:
let FollowBtn35 = document.querySelector("#content > div.container > div > div.b-fans__container > div.b-users__list > div:nth-child(35) > div > div.g-btn__group > div > span")
FollowBtn35.click()
let FollowBtn37 = document.querySelector("#content > div.container > div > div.b-fans__container > div.b-users__list > div:nth-child(37) > div > div.g-btn__group > div > span")
FollowBtn37.click()
let FollowBtn38 = document.querySelector("#content > div.container > div > div.b-fans__container > div.b-users__list > div:nth-child(38) > div > div.g-btn__group > div > span")
FollowBtn38.click()
This only works on the 1st line, so FollowBtn35 and the rest it does nothing. Does anyone know why this might be or able to point me in the right direction?
What I want to achieve from the script is replicate the clicking of a button followed by a pause then the clicking of another button and so on for 100's if possible 1000's of buttons on a webpage.
The following has been suggested but thus returns unidentified:
const buttons = document.querySelectorAll('g-btn__group')
buttons.forEach((btn)=> {btn.addEventListener('click',function (e) {const elm = e.target console.log(elm.value) // Do something... }, false)})
Any help would be greatly appreciated and I am even willing to pay if required such is the importance of this