title: How to use autoclick a button as soon as it pops up on a browser with tampermonkey
body: <p>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 :).</p>
  <p>I want to autoclick a particular button on a site that pops up only for a split second.<br />
  Tons of people are trying to click on the same button so you have to be lightning fast.</p>
  <p>I wanted to make a script to make this process easier.</p>
  <p>I use an auto refresh extension to help refresh the page which i would like to use with the script as well.</p>
  <p><em><strong>What im struggling with:</strong></em></p>
  <p><strong>1. Create a userscript with tampermonkey and javascript/jquery to locate and auto click the  button.</strong></p>
  <p><strong>2. The button is not on the page from the start and only pops up for a few seconds.</strong></p>
  <p><strong>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.</strong></p>
  <p><em><strong>My attempts so far:</strong></em></p>
  <p>Ive tried multiple site, extensions and questions here on stack:</p>
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/21069232/how-to-auto-click-an-input-button">How to auto click an input button</a></p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/42553882/automatic-click-on-a-pop-up-button">Automatic click on a pop up button</a></p>
  </li>
  <li><p>Extension Autoclicker (really good btw): <a href="https://chrome.google.com/webstore/detail/auto-clicker-autofill/iapifmceeokikomajpccajhjpacjmibe?hl=en" rel="nofollow noreferrer">https://chrome.google.com/webstore/detail/auto-clicker-autofill/iapifmceeokikomajpccajhjpacjmibe?hl=en</a></p>
  </li>
  <li><p>Extension imacros (also decent) : <a href="https://chrome.google.com/webstore/detail/imacros-for-chrome/cplklnmnlbnpmjogncfgfijoopmnlemp?hl=en#:%7E:text=You%20can%20combine%20iMacros%20with,iMacros%20for%20Firefox%20without%20changes" rel="nofollow noreferrer">https://chrome.google.com/webstore/detail/imacros-for-chrome/cplklnmnlbnpmjogncfgfijoopmnlemp?hl=en#:~:text=You%20can%20combine%20iMacros%20with,iMacros%20for%20Firefox%20without%20changes</a>!</p>
  </li>
  </ol>
  <p>MY ATTEMPT TO MAKE THE PROGRAM WITH TAMPERMONKEY AND jQUERY:
  <strong>I use a Tampermonkey extension that will allow jQuery on all pages just FYI</strong></p>
  <pre><code>    // ==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 = () =&gt; {
          const button =
                document.querySelector(&quot;#queue-0-1394263709&quot;)
          if (button) button.click()
          else setTimeout(clickButton, 500)
      }
      window.addEventListener(&quot;DOMcontentloaded&quot;, clickButton)
  })();
  </code></pre>
  <p>*This was just me trying something with the limited jQuery I know.</p>
  <p>The Button details:
  <strong>Xpath of button:</strong>   //*[@id=&quot;queue-0-1319022196&quot;]</p>
  <p><strong>Selector of button:</strong>  <code>#queue-0-1394263709</code></p>
  <p><strong>Button:</strong> <code>&lt;a href=&quot;#&quot; data=&quot;[object Object]&quot; id=&quot;queue-0-1394263709&quot; name=&quot;queue_item&quot;&gt;Start&lt;/a&gt;</code></p>
  <p>PS: The button does not have a class to the best of my knowledge.
  I would really appreciate help from you guys thanks.</p>
  <p><strong>TL;DR</strong> i want to autoclick a button as soon as it pops up with a script</p>