title: Actions on page reload/refresh in JavaScript
body: <p>What I want to do is trigger a function from an extension/GM Script once a page in FireFox reloads/refreshes...</p>
  
  <p>Picture this:</p>
  
  <ol>
  <li>I goto a webpage that asks for a username and password.</li>
  <li>My code populates these values and submits the credentials</li>
  <li>The webpage reloads and brings up a page asking me to enter a pre-decided number</li>
  <li>I enter the number</li>
  <li>The webpage reloads and brings up a page asking me to select an option from a dropdown</li>
  <li>I select ...
  .. you get the idea..</li>
  </ol>
  
  <p>I figured I wanted to write some JavaScript to do all this.. and <b>since persistence would be required and I don't have capability to change the source site, I thought of writing a FireFox extension or GreaseMonkey - basically anything on the client side</b>.</p>
  
  <p>Something like that the event DOMContentReloaded would have acted like (had it existed) :</p>
  
  <p>addEventListener("DOMContentReloaded", pageReloaded, false);</p>
  
  <p>Typical test cases for such code would be to:</p>
  
  <ol>
  <li>Find out how much time it took between page refreshes</li>
  <li>Wait for the second instance of page refresh to happen and then redirect to another page
  ,etc
  ..</li>
  </ol>
  
  <p><b>All this would be done from a FireFox extension (or GreaseMonkey in case a slution in GM would be easier/better/recommended) - given this, things should be easy?</b></p>