【发布时间】:2012-01-25 05:50:39
【问题描述】:
当我使用以下方式运行 Chromium 浏览器时:
chromium-browser --load-extension=/path/to/my/extension --user-data-dir=/path/to/chrome/profile --app=http://localhost/somepage
某些内容脚本未注入页面。这些脚本在清单文件中定义如下:
"content_scripts" : [{
"matches" : [ "http://*/*", "https://*/*" ],
"js" : [ "content/s1.js", "content/s2.js", "content/s3.js", "content/s4.js" ],
"run_at" : "document_end"
}]
检查页面时,我看到只有s1.js 和s4.js 被成功注入。重新加载页面后,所有脚本都正确注入,我的扩展按预期工作。
这可能是什么原因,以及如何调试?
编辑:
那些内容脚本(有时无法注入)在开头引用“文档”。好像我把它们包装成这样的东西:
setTimeout(function() { document. ... }, 5000);
它们总是按预期注入。即使在清单中指定了“run_at”:“document_end”,文档是否可能不可用?
谢谢!
【问题讨论】:
-
我也注意到了这一点。我相信这就是我无法使用 JQuery 的 document.ready 函数的原因。
标签: google-chrome-extension chromium