
Draft answer
By: a guest on
Aug 3rd, 2012 | syntax:
None | size: 0.70 KB | hits: 64 | expires: Never
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.
// In background.js:
chrome.webRequest.onCompleted.addListener(function(details) {
chrome.tabs.executeScript(details.tabId, {
file: 'contentscript.js',
allFrames: true // <-- You might want to tweak this
});
}, {
urls: ['http://example.com/foo.js*'],
types: ['xmlhttprequest']
});
[`chrome.tabs.executeScript`][1] will execute the content script when the page has loaded.
[1]: http://code.google.com/chrome/extensions/tabs.html#method-executeScript