我想在事件$window.ready之前从铬扩展名执行代码。
显然"runs_at":"document_start“应该管用,据谷歌称
在"document_start“的情况下,文件在css的任何文件之后注入,但在构造任何其他DOM或运行任何其他脚本之前。
然而,它似乎不起作用。以下代码:
manifest.json:
{
"name": "Testextension Extension",
"manifest_version": 2,
"version": "0.1",
"content_scripts": [{
"matches": [
"file:///C:/test.html"
],
"js": ["test.js"],
"runs_at": "document_start"
}]
}test.js:
console.log("the extension content script is happening");test.html:
<html>
<head>
<script src="jquery.min.js"></script>
<script type="application/javascript">
console.log ("script is happening in page");
$(window).ready(function () {console.log("window.ready is happening");});
$(document).ready(function () {console.log("document.ready is happening");});
</script>
</head>
<body>
</body>
</html>提供以下控制台输出:
script is happening in page
window.ready is happening
document.ready is happening
the extension content script is happening 我不拥有我的扩展应该工作的页面,所以我不能修改它以在我的Chrome扩展之后执行。
我做错什么了吗,还是这是Chrome的问题?
我能做些什么?
编辑:这是关于我使用"runs_at“而不是"run_at”吗?
edit2:对不起,好像是关于那个的。
发布于 2013-12-31 23:59:22
问题的存在是因为我犯了拼写错误"runs_at“(而不是"run_at")。我的Chrome扩展现在可以正常工作了。
https://stackoverflow.com/questions/20848057
复制相似问题