我正在使用contentcript进行扩展。它应该更改DOM元素的段落,但它不起作用。 这是我的.json文件
{
"name": "MyExtension",
"version": "0.5",
"description": "Moja prva extenzija!",
"permissions": ["storage",
"activeTab"],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"run_at": "document_idle",
"js": ["contentScript.js"]
}
],
"browser_action":{
"default_icon":"h3.png",
"default_popup":"popup.html"
},
"manifest_version": 2
}
这是我的contentScript.js:
document.getElementById("click").onclick= funt; // "click" is button of extension
function funt() {
document.getElementById("demo").innerHTML="Hello"; //demo is DOM element
}