【发布时间】:2012-11-03 22:40:17
【问题描述】:
我对看似非常简单的事情感到困惑。 我试图在用户访问的每个页面中注入我自己的 div,在 google chrome 扩展中。 我查看了网络上的示例,但似乎没有什么对我有用:s
这是我的 manifest.json
{
"name": "My extension",
"version": "1.0",
"permissions": [
"http://*/*", "tabs", "https://*/*"
],
"browser_action": {
"default_title": "My extension",
"default_icon": "icon.png"
},
"manifest_version": 2,
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["test.js"],
"run_at": "document_end",
"all_frames": true
}
]
}
还有我的 test.js
var newdiv = document.createElement('div');
newdiv.setAttribute('id','this_is_my_own_div');
document.body.appendChild(newdiv);
但我在源代码中一无所获... 我的 div 没有创建。 如何检查我的 test.js 是否正在运行?我不明白为什么它是和别人一起工作而不是和我一起工作:s 任何帮助不胜感激!
【问题讨论】:
标签: dom google-chrome-extension content-script