0

我被看似非常简单的东西所困扰。我试图在用户访问的每个页面中注入我自己的 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 任何帮助感谢!

4

1 回答 1

2

它工作尝试:

"browser_action": { "default_title": "My extension", "default_icon": "icon.png" },

代替:

"browser_action": { "name": "My extension", "icons": ["icon.png"] }, 
于 2012-11-15T10:44:36.523 回答