MozillaZine

How to "Manage Extension Shortcuts"?

Announce and Discuss the Latest Theme and Extension Releases.
voipfc
 
Posts: 72
Joined: November 16th, 2006, 11:16 am
Location: Accra

Post Posted June 2nd, 2019, 8:46 am

Hi guys,

I am trying to switch to a keyboard driven totally mouseless workflow (wherever possible) and one area I am frustrated is in managing keyboard shortcuts. After seeing how Firefox now has a "Manage Extension Shortcuts" page in about:preferences I want to create something like for myself, something more effective, else I will have to modify every addon I use to read my customized settings.

I have asked some questions at Github I have linked to rather than repeat them here.


https://github.com/mstriemer/html-about ... -451199913

https://github.com/passff/passff/pull/3 ... -498034693

https://discourse.mozilla.org/t/what-ar ... s/41047/11

To summarise the questions are:

1. Where is the Manage Extensions Shortcuts implemented in the Firefox code base?

2. Where is the data for the shortcuts stored?

3. Is it possible for an addon to read all the shortcuts including those different from the manifest.json and those modified by the users?

4. Is it possible to for addon to set the shortcuts for other addons?

5. Are there Webextensions APIs for the whole process, ie those exposed to addon developers, not those used internally by Firefox

DanRaisch
Moderator

User avatar
 
Posts: 121893
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted June 2nd, 2019, 10:25 am

Moving to Firefox Builds where pre-release versions are discussed.

voipfc
 
Posts: 72
Joined: November 16th, 2006, 11:16 am
Location: Accra

Post Posted June 2nd, 2019, 11:42 am

DanRaisch wrote:Moving to Firefox Builds where pre-release versions are discussed.


I think this belongs in Extension development because "Manage Extension Shortcuts" is the current stable version.

DanRaisch
Moderator

User avatar
 
Posts: 121893
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted June 2nd, 2019, 1:31 pm

I don't see that in version 67.0 which is current. What is the complete menu path you are using to get to that?

mightyglydd

User avatar
 
Posts: 9513
Joined: November 4th, 2006, 7:07 pm
Location: Hollywood Ca.

Post Posted June 2nd, 2019, 5:20 pm

Click on the cogwheel to the right of Extensions > Manage Your Extensions
#KeepFightingMichael

voipfc
 
Posts: 72
Joined: November 16th, 2006, 11:16 am
Location: Accra

Post Posted June 2nd, 2019, 5:23 pm

Exactly as @mightyglydd says

DanRaisch
Moderator

User avatar
 
Posts: 121893
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted June 3rd, 2019, 3:28 am

Yup, there it is. OK, moving back to Extension Releases. (Although I'm thinking that Support would be more appropriate.)

morat
 
Posts: 3327
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 5th, 2019, 10:46 pm

1.

chrome\toolkit\content\mozapps\extensions\shortcuts.html
chrome\toolkit\content\mozapps\extensions\shortcuts.js

These files are in the omni.ja archive in the install directory.

4.

Addons are explicitly blocked from operating on another addon's moz-extension page.

How can I execute a userscript on a moz-extension page?
http://stackoverflow.com/questions/52131490

5.

commands
http://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/manifest.json/commands
http://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/commands

P.S.

Here is how to list shortcuts using the browser toolbox console.

Code: Select all
(function () {

  AddonManager.getAddonsByTypes(["extension"]).then(function (addons) {
    addons.forEach(function (addon) {
      var policy = WebExtensionPolicy.getByID(addon.id);
      if (policy && policy.extension && policy.extension.shortcuts) {
        console.log(addon.name);
        policy.extension.shortcuts.allCommands().then(function (commands) {
          for (var i = 0; i < commands.length; i++) {
            var command = commands[i];
            console.log(command);
          }
        });
      }
    });
  });

})();

Here is how to update a shortcut using the browser toolbox console.

Code: Select all
(function () {

  var id = "uBlock0@raymondhill.net"; // uBlock Origin
  var policy = WebExtensionPolicy.getByID(id);
  if (policy && policy.extension && policy.extension.shortcuts) {
    policy.extension.shortcuts.updateCommand({
      name: "launch-element-picker",
      shortcut: "Ctrl+Shift+1",
    });
  }

})();

Firefox 67.0.1
Windows 7 SP1 32-bit

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 4 guests