运行内容脚本有三个选项:
document_start
- 在 <head>
开头注入(inject)document_end
- 在 DOMContentLoaded
之后立即注入(inject)document_idle
- 什么时候注入(inject)??? 最佳答案
根据to the current Chromium source :
We try to run idle in two places: here and DidFinishLoad. DidFinishDocumentLoad() corresponds to completing the document's load, whereas DidFinishLoad corresponds to completing the document and all subresources' load. We don't want to hold up script injection for a particularly slow subresource, so we set a delayed task from here - but if we finish everything before that point (i.e., DidFinishLoad() is triggered), then there's no reason to keep waiting.
翻译成网络开发人员的话,这基本上意味着……
document_idle
脚本将运行最早的这些事情之一是真实的:window.onload
已解雇DOMContentLoaded
已经开除了。 在典型页面上,这些脚本可能会在 #2 处运行。
关于google-chrome-extension - 什么时候run_at : document_idle content script run?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33248629/