title: JavaScript Bookmarklet: Infinite loop to perform a function, then on page load, execute the function again
body: <p>How would I go about implementing this as a bookmarklet? </p>
  
  <p>This is the function that I have:</p>
  
  <pre><code>javascript: function tr_f() { 
    var followlinks = []; 
    for (var i=0; i &lt; document.links.length; i++) {
          if (document.links[i].getAttribute("class")=="follow"){
                followlinks[followlinks.length] = document.links[i];
          }
    } 
    for (var i=0; i&lt;followlinks.length; i++) {
          var rrr=followlinks[i].onclick();
    } 
  } tr_f();
  </code></pre>
  
  <p>I want to modify this code to perform the function, then refresh the page, wait a few seconds, and execute the function again - in an infinite loop. </p>
  
  <p>Alternatively, in fact a better method, would be to refresh the page once the bookmarklet has been clicked, execute the function on page load, and then do it again. </p>