我想为 chrome 浏览器创建一个扩展:上下文菜单中的项目菜单在您使用左键或右键单击项目菜单时具有两种不同的操作。对于火狐可以实现,但是对于Chrome呢?如何?
背景.js:
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({
title: 'do action (left cl. - first, right cl. - second)',
id: 'test',
contexts: ['link'],
});
});
chrome.contextMenus.onClicked.addListener(function(info, tab) {
if (info.menuItemId === "test") {
console.log("first action completed")
}
});