1. Use the `onCompleted` event with a filter for `xmlhttprequest`. This method will run **when the request has finished**. It's possible that the page has not been rendered yet.
  2.  
  3. // In background.js:
  4. chrome.webRequest.onCompleted.addListener(function(details) {
  5. chrome.tabs.executeScript(details.tabId, {
  6. file: 'contentscript.js',
  7. allFrames: true // <-- You might want to tweak this
  8. });
  9. }, {
  10. urls: ['http://example.com/foo.js*'],
  11. types: ['xmlhttprequest']
  12. });
  13.  
  14. [`chrome.tabs.executeScript`][1] will execute the content script when the page has loaded.
  15.  
  16.  
  17. [1]: http://code.google.com/chrome/extensions/tabs.html#method-executeScript