google-chrome-extension - 什么时候run_at : document_idle content script run?

标签 google-chrome-extension

运行内容脚本有三个选项:

  • 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已解雇
  • 一直是 200ms 自从 DOMContentLoaded已经开除了。

  • 在典型页面上,这些脚本可能会在 #2 处运行。

    关于google-chrome-extension - 什么时候run_at : document_idle content script run?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33248629/

    相关文章:

    google-chrome-extension - 如何将 chrome 扩展的高度设置为浏览器窗口高度?

    Chrome 扩展程序的 Javascript 外部脚本无法正常工作

    javascript - 使用 JavaScript 访问 Chrome 扩展程序的剪贴板

    Javascript Chrome 扩展程序不显示结果

    javascript - 即使用户导航到另一个页面,如何将内容脚本保留在选项卡中?

    javascript - 我正在访问的网站可以访问由 Chrome 扩展程序添加的全局变量吗?

    javascript - 检查并替换文本/节点 Chrome 扩展程序中的多个字符串

    javascript - 浏览器打开和关闭时自动登录和注销

    google-chrome - Greasemonkey类型的用户脚本可以打包为Chrome扩展程序吗?

    javascript - 修改谷歌浏览器扩展程序以删除标签