Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Draft answer

By: a guest on Aug 3rd, 2012  |  syntax: None  |  size: 0.70 KB  |  views: 145  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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