title: Chrome Extension: How to get page content of current tab from devtools when requests finished?
body: <p>I'm developing a chrome extension to verify page content of current tab from devtools when request finishes. I'm only interested in following types of requests: <a href="http://developer.chrome.com/trunk/extensions/webRequest.html#type-RequestFilter" rel="nofollow">main_frame, sub_frame, and xmlhttprequest</a>.</p>
  
  <p>It can be done like this:</p>
  
  <ol>
  <li>listen for <code>chrome.webRequest.onCompleted</code> event in background.js and filter out non-interested requests</li>
  <li>communicate with contentScript.js to get the page content</li>
  <li>send page content as a message to devtools</li>
  </ol>
  
  <p>But will such situation happen?</p>
  
  <ol>
  <li>In background.js, request A completes and send a message M_A to contentScript.js to get page content.</li>
  <li>Request B completes and page content changed.</li>
  <li>In contentScript.js, M_A is received, then ...</li>
  </ol>
  
  <p>So I want to find a better way, like put all the logic in devtools:</p>
  
  <pre><code>var requestFinishedHandler = function(request) {
      // do something here ...
  }
  chrome.devtools.network.onRequestFinished.addListener(requestFinishedHandler);
  </code></pre>
  
  <p>Any advice?</p>