Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda