title: Click a button, wait and reload the page
body: <p>I'm looking for some specific text on a page, then automatically clicking a button if the text exists (otherwise reloading the page after a few seconds). What I would like is to reload the page after the click has been executed (with a little delay). Here's my code which is not working:</p>
  
  <pre><code>var content = document.body.textContent || document.body.innerText;
  var hasText = content.indexOf("this is my text")!==-1;
  el = document.querySelector(".btn.secondClass");
  
  if(hasText &amp;&amp; el){
    el.click()
    {
      setTimeout(function(){
        window.location.reload()
      },5000);
    }
  }
  else {
    setTimeout(function(){
      window.location.reload()
    },5000);
  }
  </code></pre>
  
  <p>This just seems to reload the page after 5 seconds and the click doesn't get fired. Am I missing something?</p>