So I have seen multiple questions on this but i don't think i have seen one that has been solved. I am also super new to JS, jQuery and I have never made a userscript before so I still dont know a lot of words or concepts. So feel free to dumb it down for me :).
I want to autoclick a particular button on a site that pops up only for a split second.
Tons of people are trying to click on the same button so you have to be lightning fast.
I wanted to make a script to make this process easier.
I use an auto refresh extension to help refresh the page which i would like to use with the script as well.
What im struggling with:
1. Create a userscript with tampermonkey and javascript/jquery to locate and auto click the button.
2. The button is not on the page from the start and only pops up for a few seconds.
3. The page is constantly refreshing but I wanted to make sure the script will keep trying to click the button till it pops up and then stop once clicked.
My attempts so far:
Ive tried multiple site, extensions and questions here on stack:
Extension Autoclicker (really good btw): https://chrome.google.com/webstore/detail/auto-clicker-autofill/iapifmceeokikomajpccajhjpacjmibe?hl=en
Extension imacros (also decent) : https://chrome.google.com/webstore/detail/imacros-for-chrome/cplklnmnlbnpmjogncfgfijoopmnlemp?hl=en#:~:text=You%20can%20combine%20iMacros%20with,iMacros%20for%20Firefox%20without%20changes!
MY ATTEMPT TO MAKE THE PROGRAM WITH TAMPERMONKEY AND jQUERY: I use a Tampermonkey extension that will allow jQuery on all pages just FYI
// ==UserScript==
// @name Autoclicker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match Name
// @grant none
// ==/UserScript==
(function() {
'use strict';
const clickButton = () => {
const button =
document.querySelector("#queue-0-1394263709")
if (button) button.click()
else setTimeout(clickButton, 500)
}
window.addEventListener("DOMcontentloaded", clickButton)
})();
*This was just me trying something with the limited jQuery I know.
The Button details: Xpath of button: //*[@id="queue-0-1319022196"]
Selector of button: #queue-0-1394263709
Button: <a href="#" data="[object Object]" id="queue-0-1394263709" name="queue_item">Start</a>
PS: The button does not have a class to the best of my knowledge. I would really appreciate help from you guys thanks.
TL;DR i want to autoclick a button as soon as it pops up with a script