title: How do I "quietly" reload a page from a Greasemonkey script?
body: <p>I want to reload a page so that it does not cause the effects of a full-page refresh, like displaying "Loading..." on the page's tab.</p>
  
  <p>Here's the code I have so far.  My theory was that I could overwrite the <code>body</code> section with a <code>&lt;frame&gt;</code>-wrapped version of the updated site, gotten via <code>GM_xmlhttpRequest</code>.</p>
  
  <h2>reloader.js</h2>
  
  <pre><code>setInterval(reload, 10000);
  
  function reload() {
      GM_xmlhttpRequest({method: 'GET',
              url: location.href,
              onload: function(responseDetails) {
                  document.body.innerHTML =
                                  '&lt;frame&gt;\n'
                                  + responseDetails.responseText
                                  + '&lt;/frame&gt;\n';
              }});
  }
  </code></pre>
  
  <p>When testing with Firebug on stackoverflow.com, I found that this script updates the <code>body</code> <em>as if I had performed a full-page refresh</em>, without the side effects.  Yay!  Mysteriously, the <code>&lt;frame&gt;</code> tags are nowhere to be found.</p>
  
  <h2>Questions</h2>
  
  <p>What I have right now does a good job of reloading the page, but I have two questions:</p>
  
  <ol>
  <li>How do I stay logged in after a reload? Specifically, what do I need to do to keep me logged in to Stack Overflow?</li>
  <li>Can someone explain <em>why</em> my script works?  Why are there no <code>&lt;frame&gt;</code> tags within the <code>body</code>?</li>
  </ol>
  
  <h2>Updates</h2>
  
  <p>I've incorporated elements from Cleiton, Havenard, and Henrik's answers so far.  I tried sending cookies via the <code>header: { 'Cookie': document.cookie }</code> entry in the data sent through <code>GM_xmlhttpRequest</code>.  This sent some, but not all of the cookies.  It turns out that if I turn on third party cookies in the Firefox then I'll get the necessary extra cookies (<code>.ASPXAUTH</code>, <code>ASP.NET_SessionId</code>, and <code>user</code>), but this is a <a href="http://www.grc.com/cookies.htm" rel="nofollow noreferrer"><em>bad idea</em></a>.</p>