views:

267

answers:

1

How can one run a chromium extension content_script after window.load and after all other window.load listeners have been triggered?

I'm currently hacking thru a site's javascript attempting to improve it's functionality. But I want such improvements to happen after all it's ready js is finished.

What I actually need is a way to set a trigger after the site is ready to be patched.

If there is no simple way to do it, has someone done a general function which would work with the top JS frameworks (jQuery, prototype, etc)?

BTW, doing this won't work, since it will be triggered before the page script's listeners which are added later:

window.addEventListener("load", callback, false);
+1  A: 

http://code.google.com/chrome/extensions/content_scripts.html:

(discussing Manifest's content_scripts.run_at property)

Listening for the onload event is unnecessary for content scripts running at document_idle because they are guaranteed to run after the DOM is complete.

Being document_idle the default mode, it should work as you expected, but you don't have to add a listener for the page-load, just write the JS you want to inject.

tokland