开发者

Chromium extensions: How to run a content_script after all the document's listeners are triggered?

开发者 https://www.devze.com 2022-12-14 07:57 出处:网络
How can one run a chromium extension content_script after window.load and after all other window.load listeners have been triggered?

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 fin开发者_JS百科ished.

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);


Content_script

(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号