title: Set waiting time, delay time, to execute script
body: <p>this script for greasemonkey is working for me, to click a button, when a certain website was loaded. </p>
  
  <p>But how can I set a waiting time? Example: The website loaded and the script waits 1 second till it is executed.</p>
  
  <p>My second question is: how can I run it only once per pageload? The script starts over and over again.</p>
  
  <pre><code>    // ==UserScript==
  // @name     _YOUR_NAME
  // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
  // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  // @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
  // @grant    GM_addStyle
  // ==/UserScript==
  /*- The @grant directive is needed to work around a design change
      introduced in GM 1.0.   It restores the sandbox.
  */
  
  function clickSubmitBtnWhenItAppears (jNode) {
      var clickEvent  = document.createEvent ('MouseEvents');
      clickEvent.initEvent ('click', true, true);
      jNode[0].dispatchEvent (clickEvent);
  }
  
  //-- Value match is case-sensitive
  waitForKeyElements (
      //"#btn_submit input[type='submit'][value*='Click Me Now']",
      "input[type='submit'][value*='Click Me Now']",
      clickSubmitBtnWhenItAppears
  );
  </code></pre>
  
  <p>Script source: <a href="https://stackoverflow.com/questions/13900399/how-do-i-get-greasemonkey-to-click-on-a-button-that-only-appears-after-a-delay">How do I get Greasemonkey to click on a button that only appears after a delay?</a></p>