What are the APIs or the code in Firefox source for the "Manage Extension Shortcuts" in about:addons?

There is a new feature in Firefox which enables the keyboard shortcuts for extensions to be managed in one place.

What are the APIs it uses, and if it doesn’t use any APIs where is the code that implements in the Firefox source?

It exposes the commands API: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/commands

1 Like

Some of them are left undefined for the user to set them to their own preferences.

They can also be changed from the defaults set in manifest JSON by the user at runtime how can that also be checked?

What do you want to check?

Looking at the commands - Mozilla | MDN page I see reset(), update(), getAll() and onCommand.

update() appears to be the one through which changes to shortcuts can be registered and I wonder if an addon can be used to log and track changes to them, and so be used to create an equivalent of the Mozilla shortcut management page as that is not good enough for my needs.

You can only update etc. your own shortcuts, i.e. the one your extension registers. So you can offer your own UI to change the shortcut commands in your extension.

Isn’t there a hook or a monitor to find out what other extensions are doing or have set at runtime? From what I see getAll() returns the contents of the manifest.json but the user can change them from the code defaults and this is what I want to see so I can adjust them to my preferences.

As I said earlier it is the code used in the Manage Extension Shortcuts page that I need to know about. What I want to do is possible. Whether it uses unexposed internal APIs or is based on some custom implemenation is what I need to know. For example in emacs the descbinds command shows you all the keybindings and the functions they are bound to. It is the Firefox equivalent of these that I need to know.

I am not sure I understand what you’re asking for. Maybe it would help if you could explain what you’re trying to achieve?

I need a list of all the active shortcuts set in Firefox and the addons that respond to them. If the user has changed a shortcut from the default in manifest.json then I should know what it has been changed to.

It is not just for my addon but for all addons.

And how is the list in about:addons not satisfying that need? Do you want to programmatically interact with it? And if yes, from where?

I have more addons than the page displays, and some individuals addons have more shortcuts than the page displays.

I need to reassign a lot of them and that will be easier if I can see many of them at once, rather than assign a shortcut for the UI to tell me there is a conflict, and not even know which addon it is.

As for the programmability it has to be from my own addon.

The lack of UI programmability in Firefox is really bad.

The page doesn’t show add-ons without any commands defined. If the add-on doesn’t use the commands API but instead uses event listeners in a content script or just keyboard shortcuts inside their own page, there’s no way for Firefox to know about it, just like website keyboard shortcuts.

If the page doesn’t display them, they shouldn’t be commands defined in the manifest of the extension. You may have to expand the card to see all the shortcuts: https://bugzilla.mozilla.org/show_bug.cgi?id=1521826

It appears a patch is being worked on, even if the review of it seems to have stalled: https://bugzilla.mozilla.org/show_bug.cgi?id=1520123

That’s not really possible. Generally extensions can only interact with other extensions over a plain text messaging port. That’s part of the sandbox, to ensure extensions don’t mess with each other without consent.

You could write an “experiment” that interacts directly with Firefox internals. If you can handle an “experiment” I’d expect you’d be able to handle finding the relevant internals.

1 Like