我有一个非常简单的扩展:
宣言 Json
{
"name": "historyCleaner",
"version": "0.1.1",
"manifest_version": 1,
"description": "This is my first Chrome extension",
"background": {
"scripts": ["cleaner.js"]
},
"permissions": [
"history"
]
}
更干净了
chrome.history.onVisited.addListener(function(HistoryItem result) {
console.log("it works!");
alert("it works!");
});
我已经把它装进了谷歌浏览器,它已经打开了,但是... 它不能工作。它不会在控制台中记录任何东西,也不会提醒任何东西,更糟糕的是,我在开发人员工具“ Scripts”选项卡中找不到它。我怎么才能知道它为什么不起作用?
//编辑
我把声明 json 改成了这个:
{
"name": "historyCleaner",
"version": "0.1.5",
"manifest_version": 1,
"description": "This is my first Chrome extension",
"background_page": "background.html",
"permissions": [
"history",
"background"
]
}
并在 backound.html 中嵌入 JavaScript