清单:
{
"manifest_version": 2,
"name": "Copy As",
"version": "1.0",
"description": "Adds a right click option to quickly convert a macaddress and search ecoverage for an installation address.",
"background": {
"scripts": ["background.js"]
},
"permissions": ["contextMenus","clipboardWrite"]
}
背景:
browser.contextMenus.create({
id: "conMacProv",
title: "ProvisionLink MAC",
contexts: ["selection"]
});
browser.contextMenus.create({
id: "conMacDev",
title: "DevStat MAC",
contexts: ["selection"]
});
browser.contextMenus.create({
id: "conWimaxStarQ",
title: "Wimax - StarQuality",
contexts: ["selection"]
});
browser.contextMenus.create({
id: "conHex",
title: "Hex",
contexts: ["selection"]
});
browser.contextMenus.onClicked.addListener(function (info, tab) {
console.log(info);
console.log("test");
});
创建了菜单项,但单击这些项不会产生控制台日志。 我正在使用FF 56.0.1
无视以下内容:
此脚本也会出现以下控制台错误:
传递给getElementById()的空字符串。 main.7d260b3049ff.js:2:7526
答案 0 :(得分:-1)
尝试像这样添加你的听众:
browser.contextMenus.onClicked.addListener((info, tab) => {
console.log("Item " + info.menuItemId + " clicked " + "in tab " + tab.id);
});