Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
browser.menus.onClicked.addListener not working in Firefox

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I've found a solution - browser.menus.onClicked.addListener() working properly, just there is a necessity to enable logging in browser settings.

First, go to about:config and find key extensions.logging.enabled and switch it to true. Then, display Browser Console from Menu Bar -> Tools -> Browser Tools -> Browser Console or by shortcut Ctrl+Shift+J.

Be aware that Browser Console is not the same as Firefox Developer Tools (from F12 or Ctrl+Shitft+I)!

Last, but not least enable Show Content Messages in Browser Console

enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!