<分区>
我正在尝试为 FireFox 开发一个带有 contextMenu 的 WebExtension。目前我只有两个文件,没有真正的功能。问题是即使使用来自 Mozilla Developer Network 的示例代码,它似乎也无法正常工作 - 所以我假设它在 list 中,但我似乎找不到问题所在。
这是我的 manifest.json
文件:
{
"manifest_version": 2,
"name": "FullWindow",
"version": "1.0",
"description": "Test plugin.",
"permissions": ["contextMenus"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["fullwindow.js"]
}
]
}
这是我的fullwindow.js
文件:
console.log("Plugin loaded!");
browser.contextMenus.create({
id: "radio-green",
type: "radio",
title: "Make it green",
contexts: ["all"],
checked: false
}, onCreated);
function onCreated() {
if (browser.runtime.lastError) {
console.log("error creating item:" + browser.runtime.lastError);
} else {
console.log("item created successfully");
}
}
console.log("Test!");
这里的问题是除了最初的“插件已加载!”之外,我没有得到任何控制台日志。也不要得到我的上下文菜单项。