我有非常简单的扩展:
清单.json
{
"name": "historyCleaner",
"version": "0.1.1",
"manifest_version": 1,
"description": "This is my first Chrome extension",
"background": {
"scripts": ["cleaner.js"]
},
"permissions": [
"history"
]
}
清洁器.js
chrome.history.onVisited.addListener(function(HistoryItem result) {
console.log("it works!");
alert("it works!");
});
我已经在谷歌浏览器中加载了它,它已打开并且......它不起作用。它不会在控制台中记录任何内容,也不会发出任何警报,更糟糕的是,我在开发人员工具的“脚本”选项卡中找不到它。我怎样才能找到它为什么不起作用?
//编辑
我已将 manifest.json 更改为这个:
{
"name": "historyCleaner",
"version": "0.1.5",
"manifest_version": 1,
"description": "This is my first Chrome extension",
"background_page": "background.html",
"permissions": [
"history",
"background"
]
}
并在 background.html 中嵌入 JavaScript