keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

@morat

Thanks, that works fine. [The (") characters need to be changed to (') characters in order to be used in a tbkeys shortcut.]
Mr. Qwerky
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

Note: I'm posting a summary of the last few replies to help other tbkeys users.

The following experiment_apis addon has two commands and a browser action button and a message display action button.

* command cmd_max-msg-pane: Shift+F8
* command cmd_toggle-folder-pane: F9

The buttons execute the cmd_max-msg-pane command.

Maximize Message Pane
http://addons.thunderbird.net/thunderbird/addon/1392

A user wants to create a Shift+Z shortcut to execute the cmd_max-msg-pane command.

The Addons Manager tab requires either Ctrl or Alt for alphabetic keys, so a Shift+Z shortcut isn't allowed.

i.e. Tools > Addons > Extensions > Cogwheel > Manage Extension Shortcuts

Manage extension shortcuts
http://www.ghacks.net/2019/01/16/manage ... outaddons/

Here is how to click the browserAction or messageDisplayAction button using the extension id.

Code: Select all

(function () {
  var getBrowserActionButton = function (aId) {
    aId = aId.toLowerCase();
    aId = aId.replace(/[^a-z0-9_-]/g, '_');
    aId = aId + '-browserAction-toolbarbutton';
    return window.document.getElementById(aId);
  };
  var getMessageDisplayActionButton = function (aId) {
    aId = aId.toLowerCase();
    aId = aId.replace(/[^a-z0-9_-]/g, '_');
    aId = aId + '-messageDisplayAction-toolbarbutton';
    return window.document.getElementById(aId);
  };
  var extensionId = '{CC1FC7EB-79F7-4A28-B12C-731304F16E53}';
  var button = getBrowserActionButton(extensionId);
  // var button = getMessageDisplayActionButton(extensionId);
  if (button) {
    button.click();
  }
})();
Here is how to trigger the browserAction or messageDisplayAction action using the extension id.

Code: Select all

(function () {
  var enumerator = window.Services.ww.getWindowEnumerator();
  while (enumerator.hasMoreElements()) {
    var win = enumerator.getNext();
    if (win.document && win.document.documentURI == 'chrome://extensions/content/dummy.xhtml') {
      win.document.querySelectorAll('browser').forEach(function (aBrowser) {
        var addonPolicy = aBrowser._contentPrincipal.addonPolicy;
        if (addonPolicy && addonPolicy.extension.manifest.applications.gecko.id == '{CC1FC7EB-79F7-4A28-B12C-731304F16E53}') {
          var action = window.ExtensionParent.apiManager.global.browserActionFor(addonPolicy.extension);
          // var action = window.ExtensionParent.apiManager.global.messageDisplayAction(addonPolicy.extension);
          if (action) {
            action.triggerAction(window);
          }
        }
      });
    }
  }
})();
Here is how to execute the cmd_max-msg-pane or cmd_toggle-folder-pane command using the extension name.

Code: Select all

(function () {
  var enumerator = window.Services.ww.getWindowEnumerator();
  while (enumerator.hasMoreElements()) {
    var win = enumerator.getNext();
    if (win.document && win.document.documentURI == 'chrome://extensions/content/dummy.xhtml') {
      win.document.querySelectorAll('browser').forEach(function (aBrowser) {
        var addonPolicy = aBrowser._contentPrincipal.addonPolicy;
        if (addonPolicy && addonPolicy.extension.manifest.name == 'Maximize Message Pane') {
          addonPolicy.extension.tabManager.addActiveTabPermission();
          addonPolicy.extension.shortcuts.onCommand('cmd_max-msg-pane');
          // addonPolicy.extension.shortcuts.onCommand('cmd_toggle-folder-pane');
        }
      });
    }
  }
})();
Reference (see browserActionFor and triggerAction and onCommand)
http://searchfox.org/comm-esr91/source/ ... rtcuts.jsm
http://searchfox.org/mozilla-esr91/sour ... Parent.jsm
http://searchfox.org/mozilla-esr91/sour ... rtcuts.jsm

Here is how to view the manifest.json files. (display commands key and extension id)

Code: Select all

(function () {
  var enumerator = window.Services.ww.getWindowEnumerator();
  while (enumerator.hasMoreElements()) {
    var win = enumerator.getNext();
    if (win.document && win.document.documentURI == 'chrome://extensions/content/dummy.xhtml') {
      win.document.querySelectorAll('browser').forEach(function (aBrowser) {
        var addonPolicy = aBrowser._contentPrincipal.addonPolicy;
        if (addonPolicy && addonPolicy.isPrivileged == false) {
          var tab = window.tabmail.openTab('contentTab', {
            url: 'view-source:' + addonPolicy.extension.baseURL + 'manifest.json',
            background: true,
          });
          window.setTimeout(function () {
            tab.title = addonPolicy.extension.manifest.name;
            window.tabmail.setTabTitle(tab);
          }, 1000);
        }
      });
    }
  }
})();
The above code snippets do not work with experiment_apis addons without a background page.

e.g.

Quick Folder Move (missing background key)
http://addons.thunderbird.net/thunderbird/addon/12018
http://raw.githubusercontent.com/kewisc ... ifest.json

About manifest keys
http://developer.thunderbird.net/add-on ... ifest-keys
http://webextension-api.thunderbird.net ... mands.html

Similar thread
http://github.com/wshanks/tbkeys/issues/46

Tips: http://forums.mozillazine.org/viewtopic ... #p14872763

---

Similar code snippets for Firefox that may be helpful to Foxy Gestures users:

The following addon has two commands and a browser action button.

* command display-onetab: Alt+Shift+1
* command send-current-tab-to-onetab: not set by default

The button does not execute either of the above commands.

OneTab
http://addons.mozilla.org/firefox/addon/525044

Here is how to click the browserAction button using the extension id.

Code: Select all

(function () {
  var getBrowserActionButton = function (aId) {
    aId = aId.toLowerCase();
    aId = aId.replace(/[^a-z0-9_-]/g, "_");
    aId = aId + "-browser-action";
    return document.getElementById(aId);
  };
  var extensionId = "extension@one-tab.com";
  var button = getBrowserActionButton(extensionId);
  if (button) {
    button.click();
  }
})();
Here is how to trigger the browserAction action using the extension id.

Code: Select all

(function () {
  var scope = {}; Components.utils.import("resource://gre/modules/ExtensionParent.jsm", scope);
  var enumerator = Services.ww.getWindowEnumerator();
  while (enumerator.hasMoreElements()) {
    var win = enumerator.getNext();
    if (win.document && win.document.documentURI == "chrome://extensions/content/dummy.xhtml") {
      win.document.querySelectorAll("browser").forEach(function (aBrowser) {
        var addonPolicy = aBrowser._contentPrincipal.addonPolicy;
        if (addonPolicy && addonPolicy.id == "extension@one-tab.com") {
          var action = scope.ExtensionParent.apiManager.global.browserActionFor(addonPolicy.extension);
          if (action) {
            action.triggerAction(window);
          }
        }
      });
    }
  }
})();
Here is how to execute the display-onetab or send-current-tab-to-onetab command using the extension name.

Code: Select all

(function () {
  var enumerator = Services.ww.getWindowEnumerator();
  while (enumerator.hasMoreElements()) {
    var win = enumerator.getNext();
    if (win.document && win.document.documentURI == "chrome://extensions/content/dummy.xhtml") {
      win.document.querySelectorAll("browser").forEach(function (aBrowser) {
        var addonPolicy = aBrowser._contentPrincipal.addonPolicy;
        if (addonPolicy && addonPolicy.name == "OneTab") {
          addonPolicy.extension.tabManager.addActiveTabPermission();
          addonPolicy.extension.shortcuts.onCommand("display-onetab");
          // addonPolicy.extension.shortcuts.onCommand("send-current-tab-to-onetab");
        }
      });
    }
  }
})();
Reference (see browserActionFor and triggerAction and onCommand)
http://searchfox.org/mozilla-release/so ... Parent.jsm
http://searchfox.org/mozilla-release/so ... rtcuts.jsm

Here is how to view the manifest.json files. (display commands key and extension id)

Code: Select all

(function () {
  var enumerator = Services.ww.getWindowEnumerator();
  while (enumerator.hasMoreElements()) {
    var win = enumerator.getNext();
    if (win.document && win.document.documentURI == "chrome://extensions/content/dummy.xhtml") {
      win.document.querySelectorAll("browser").forEach(function (aBrowser) {
        var addonPolicy = aBrowser._contentPrincipal.addonPolicy;
        if (addonPolicy && addonPolicy.isPrivileged == false) {
          var tab = gBrowser.addTab("view-source:" + addonPolicy.extension.baseURL + "manifest.json", {
            triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
          });
          setTimeout(function () {
            gBrowser._setTabLabel(tab, addonPolicy.name, {});
          }, 1000);
        }
      });
    }
  }
})();
About manifest keys
http://developer.mozilla.org/docs/Mozil ... ifest.json

Similar thread
http://github.com/marklieberman/foxygestures/issues/370
Last edited by morat on February 10th, 2023, 8:55 am, edited 16 times in total.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

Here are two codes which no longer work for me.

To toggle the Today pane:

Code: Select all

window.TodayPane.toggleVisibility(event)
To exit Thunderbird:

Code: Select all

window.goQuitApplication(event)
I have tried both with and without the "window." part. In each case, the error is "event is undefined". I have tried also without the "event", but get the same error.

So, how does one deal with "event"s in code?
Mr. Qwerky
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

The event object needs the window object.

Example
http://github.com/wshanks/tbkeys/issues/65
Last edited by morat on April 18th, 2022, 5:36 am, edited 1 time in total.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

Thank you.

Code: Select all

window.TodayPane.toggleVisibility(window.event)

Code: Select all

window.goQuitApplication(window.event)
both work fine!
Mr. Qwerky
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

Having Thunderbird shortcuts more-or-less configured as desired, I now turn my attention to Firefox. Since Keyconfig no longer works there either, what are some alternatives? I have found "Customizable Shortcuts", which appeared to be excellent, but is now no longer available, although it is still on GitHub--I wish someone would fork it and continue its development!

There is also "Shortkeys", which unfortunately only works in the context of a web page, and not in the context of the browser itself (navigation bar, search bar, etc.). And there is "Saka Key", which I have installed. In addition to restoring the absolutely essential-to-me shortcut of Backspace to go back one page in history (like Alt-Left-Arrow), it has some very unique features which I'm not sure I'll use, but just may do so after playing around with them a bit.

One major question I have, for those experienced with "Saka Key" is this: is it possible to add new keybindings that aren't already there by default. I don't mean to change the shortcuts of existing keybindings, but to add new ones to do things which it presently doesn't have.

For example, Ctrl-L moves the focus to the address bar, and Ctrl-K moves the focus to the search bar. With Keyconfig, I had a shortcut (Ctrl-J) to move the focus back to the content. Is such possible with "Saka Key" or with any other add-on?
Mr. Qwerky
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

You can't create custom shortcuts, AFAICT.

Bind JS scripts/bookmarklets? (for pocket integration)
http://github.com/lusakasa/saka-key/issues/45

Ability to bring focus to the address bar
http://github.com/lusakasa/saka-key/issues/132

Saka Key
http://addons.mozilla.org/firefox/addon/795406
http://key.saka.io/docs/about/introduction

...

Here is a fixed version of keyconfig that may work in the current version of Firefox Developer Edition and Nightly.

XiaoXiaoFlood extensions
http://github.com/xiaoxiaoflood/firefox ... structions
http://github.com/xiaoxiaoflood/firefox ... /keyconfig

I got DownThemAll and keyconfig working a few years ago.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

@morat

Re: Saka Key, as that thread says, Ctrl-L/Ctrl-K will natively focus address bar/search bar without any add-ons, but sadly I don't think the extension has the ability to send the focus back to the page content.

Thanks for those xiaoxiaoflood pages which look extremely interesting. I followed the instructions meticulously, and got keyconfig installed on 99.0.1 stable. Now I'll spend some time trying to recover my old keyconfig settings.

But there is much more of great interest there to explore as well, including Tab Mix Plus!
Mr. Qwerky
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Qwerky

You can create user scripts with Foxy Gestures.

Foxy Gestures
http://addons.mozilla.org/firefox/addon/foxy-gestures/
http://github.com/marklieberman/foxygestures
http://github.com/marklieberman/foxyges ... er-Scripts
http://github.com/marklieberman/foxyges ... er-Scripts

If I could figure out how to observer a Foxy Gestures console log event, then I could easily create custom gestures like opening a local file in Notepad.

More info: http://forums.mozillazine.org/viewtopic ... #p14781405

User script and mozilla.cfg
http://github.com/marklieberman/foxygestures/issues/370
Last edited by morat on May 3rd, 2022, 8:21 am, edited 1 time in total.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

Individual preferences are interesting. Foxy Gestures allows for one to browse without ever taking his hand off the mouse. Contra Saka Key, which allows one to browse, download links, open links in new tabs, etc. by keyboard alone, without ever touching the mouse.

Now, with Keyconfig back, hopefully I shan't need either of those. I found that the code which you previously provided for Thunderbird to close the application:

Code: Select all

window.goQuitApplication(event);
also works in Firefox. And the previous codes I had in keyconfig to focus the address bar and focus the search bar still work:

Code: Select all

openLocation();

Code: Select all

BrowserSearch.webSearch();
However, this code to focus the page content:

Code: Select all

_content.focus();
which worked in previous versions, no longer works. What would be the new code to do this?

Also, given the abilities provided by the userChromeJS which you linked, I'm also going to try restoring some of those earlier add-ons which I liked so much: Status Bar, Tab Groups, Tab Mix Plus and others.
Mr. Qwerky
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

Try this:

Code: Select all

gBrowser.selectedBrowser.focus();
BTW,

The openLocation function uses the event object like the goQuitApplication function.

Reference
http://searchfox.org/mozilla-release/se ... enLocation
http://searchfox.org/mozilla-release/se ... pplication
Last edited by morat on May 3rd, 2022, 5:39 am, edited 1 time in total.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

morat wrote:Try this:

Code: Select all

gBrowser.selectedBrowser.focus();
Thanks. That works fine.
BTW,

The openLocation function uses the event object like the goQuitApplication function.
So one should use:

Code: Select all

openLocation(event);
?

Just a side note: in this new installation of the old keyconfig add-on, there seem to be many functions which don't function if the shortcut is changed; I don't remember whether that was the case with older versions of Firefox. Oh well, it's still great to have keyconfig back!
Mr. Qwerky
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Qwerky

The keyconfig addon adds the ability to modify existing shortcuts defined by a <key> element.

In the past, Firefox use <key> elements to define shortcuts. More often, recent releases use event listeners to define shortcuts.

The tbkeys addon for Thunderbird uses the Mousetrap library for handling shortcuts. Too bad there isn't a similar addon for Firefox.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

Ah, I see. That explains why some of the Firefox shortcuts in keyconfig can be changed, but then do not function.

Would it be possible for someone to write a Firefox add-on that uses Mousetrap? Or would it have the same issues as keyconfig?

Also, the "Customizable Shortcuts" add-on, which appeared to be excellent, is no longer maintained, but it is available to fork, for someone who knows how to write add-ons. Would that one also have the same issue?
Mr. Qwerky
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Qwerky

The Mousetrap library works with the keypress, keydown and keyup event listeners.

Someone would have to completely rewrite the legacy Customizable Shortcuts addon.

I think it would be easiest to convert the experiment_apis tbkeys addon. Sorry, I'm not volunteering. :mrgreen:

P.S.

I got the Foxy Gestures addon to open a local file in Notepad.

User script and mozilla.cfg
http://github.com/marklieberman/foxyges ... 1118004275
Post Reply