I’m working on a simple add-on but my keyboard shortcut “commands” don’t seem to be running. I’m having a hard time debugging it because I can’t locate my script’s console output or find my script in my devtools debug sources.
I’m using a content script, so according to Debugging content scripts (Extension Workshop) I should see my console output in the regular console for the page where my script is injected.
I’ve also checked the extension-specific debugging interface (by clicking “Inspect” from the about:debugging -> This Firefox page) but I don’t see my logs or sources there either.
I’m loading my add-on using about:debugging -> This Firefox -> Load Temporary Add-on.
Here’s my manifest.json:
And the extension:
My extension does seem to be loading because I see the red border around the page.
You’re calling browser.commands.onCommand.addListener() from a content script.
The content script crashes (?) when it reaches this line, so console.log() isn’t executed.
If you put browser.commands.onCommand.addListener() in a background script, it works.