'browser.menus.onClicked.addListener not working in Firefox [duplicate]
Currently I'm working on my own Firefox extension and I've met the problem with adding listener to an onclick event for a context menu item.
manifest.json
{
"manifest_version": 2,
"name": "My extension name",
"version": "1.0",
"description": "My extension description",
"icons": {
"48": "icons/icon.png"
},
"permissions": ["menus"],
"background": {
"scripts": ["index.js"]
}
}
index.js
browser.menus.create({
id: 'my-ext-item',
title: 'Custom ctx item',
contexts: ['selection']
});
browser.menus.onClicked.addListener(function(info, tab) {
console.log("Clicked!");
});
browser.menus.create() apparently works fine, because the new item appear in my context menu. The problem is with catching a click event - it is never fires.
I've wrote above code according to the MDN Web Docs. I test it on Firefox 97.0.1 x64.
What did I wrong and what should I repair?
PS. I was trying with older browser.contextMenus.create and browser.contextMenus.onClicked.addListener but it didn't work either.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
