keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
darknight13
Posts: 1
Joined: September 17th, 2012, 2:38 am

Re: keyconfig 20110522

Post by darknight13 »

I figured out some of what I want to accomplish but not enough, please help me fill the gaps. Pointers to relevant references are ok, couldn't find much on my own. I may also be wrong about what I'm doing right now since my JS is practically zero.

The following code basically replaces the content of changeMessageViewShortcuts() from previous post (thanks highfalutin!).

Code: Select all

changeKeyStrokeForKeyId("select previous message", "ArrowLeft", null, "alt");
changeKeyStrokeForKeyId("select next message", "ArrowRight", null, "alt");
changeKeyStrokeForKeyId("scroll pane up one line", "ArrowUp", null, "alt");
changeKeyStrokeForKeyId("scroll pane down one line", "ArrowDown", null, "alt");
changeKeyStrokeForKeyId("scroll pane up one page", "PageUp", null, "alt");
changeKeyStrokeForKeyId("scroll pane down one page", "PageDown", null, "alt");
Cleverson
Posts: 16
Joined: March 11th, 2009, 3:09 pm

Re: keyconfig 20110522

Post by Cleverson »

Hello all,

I really hope someone is able to release a version of KeyConfig compatible with Thunderbird 68 and later. Today I use this extension for 3 purposes:
1. I have a custom code for first letter navigation across folders;
2. I have a custom code to jump straight to the next folder containing unread messages;
3. I've disabled some keys like s for starring and a for archiving messages, as well as changed some keys to others which resemble the old MS Outlook Express.

AFAIC, only the first of my needs above could be served by another extension such as QuickFolder.

Until Keyconfig is not ready for TB 68, I'm not upgrading...
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

Hi,
I tried to use the posted keybindings script in TB 68.4.1 to replace the extension that closed the current tab with ESC.

The used oncommand

Code: Select all

"document.getElementById('tabmail').closeTab(document.popupNode);"
works if I enter it in the error console, but in the script it does not work.
I tried VK_ESCAPE, that does nothing
VK_F1 does not unbind F1, pressing F1 still opens TB help.

Code: Select all

    /* Thunderbird userChrome.js */

    (function () {

      /* List of common chrome urls:
       *
       * 3pane window > chrome://messenger/content/messenger.xul
       * message window > chrome://messenger/content/messageWindow.xul
       * compose window > chrome://messenger/content/messengercompose/messengercompose.xul
       * address book window > chrome://messenger/content/addressbook/addressbook.xul
       * prompt window > chrome://global/content/commonDialog.xul
       *
       */

      if (location == "chrome://messenger/content/messenger.xul") {
        setTimeout(function () {
          try {

            /* unbind Help F1 */

            var keyset = document.getElementById("mailKeys");
            var key = document.getElementById("key_openHelp");
            keyset.removeChild(key);

            /* bind Example F1 */

            // window.key_example = function (event) {
              // alert("Example 1");
            };
            var keyset = document.getElementById("mailKeys");
            var key = document.createElement("key");
            key.setAttribute("id", "key_TBcloseTab");
         // key.setAttribute("key", "A"); // A
         // key.setAttribute("modifiers", "control,shift"); // Ctrl+Shift
         // key.setAttribute("modifiers", "alt"); // Alt
            key.setAttribute("keycode", "VK_F1"); // F1
         // key.setAttribute("command", "cmd_toggleQuickFilterBar");
            key.setAttribute("oncommand", "document.getElementById('tabmail').closeTab(document.popupNode);");
         // key.setAttribute("oncommand", "alert('Example 2');");
            keyset.appendChild(key);

          } catch (e) {
            Components.utils.reportError(e);
          };
        }, 1000);
      }
      if (location == "chrome://messenger/content/messageWindow.xul") {}
      if (location == "chrome://messenger/content/messengercompose/messengercompose.xul") {}
      if (location == "chrome://messenger/content/addressbook/addressbook.xul") {}
      if (location == "chrome://global/content/commonDialog.xul") {}

    })();
Can someone help? Thank you very much.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

There is a syntax error in your script because you forgot to comment out the line below the "Example 1" line.

Syntax Validator
http://esprima.org/demo/validate.html

The document.popupNode property should be null outside a context menu.

document.popupNode
http://developer.mozilla.org/docs/Web/A ... /popupNode

Try this:

Code: Select all

/* Thunderbird userChrome.js */

(function () {

  if (location == "chrome://messenger/content/messenger.xul") {
    setTimeout(function () {
      try {

        // unbind Close Quick Filter Bar ESC
        var keyset = document.getElementById("mailKeys");
        var key = document.getElementById("key_qfb_escape");
        keyset.removeChild(key);

        // bind Close Tab Esc
        var keyset = document.getElementById("mailKeys");
        var key = document.createXULElement("key");
        key.setAttribute("id", "__unique_identifier_key_close_tab");
        key.setAttribute("keycode", "VK_ESCAPE");
        key.setAttribute("oncommand", "document.getElementById('tabmail').closeTab();");
        keyset.appendChild(key);

      } catch (e) {
        Components.utils.reportError(e);
      };
    }, 1000);
  }

})();
userChromeJS 0.0.5
Thunderbird 68.4.1
Windows 7 SP1 32-bit

P.S.

Close Tab on ESC
http://addons.thunderbird.net/thunderbird/addon/161748
http://addons.thunderbird.net/thunderbird/addon/987733
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

Thank you so much for your help, morat, both for the code and the validator link.

What does your comment on document.popupNode relate to in this context?

Today I searched for a compatible extension and didn't find it, you did. :smile:
I will stick with your script.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

I was just commenting that the document.popupNode property isn't useful in a keyboard shortcut.
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

morat wrote:
P.S.

You can view the source of a common chrome url using the error console.

i.e. Tools > Developer Tools > Error Console (Ctrl+Shift+J)

Code: Select all

(function () {
  var urls = ["chrome://messenger/content/messenger.xul",
    "chrome://messenger/content/messageWindow.xul",
    "chrome://messenger/content/messengercompose/messengercompose.xul",
    "chrome://messenger/content/addressbook/addressbook.xul",
    "chrome://global/content/commonDialog.xul"];
  document.getElementById("tabmail").openTab("contentTab", {
    contentPage: "view-source:" + urls[0],
  });
})();
What must this look like for Firefox?
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@bege

You can view the source of a chrome url using the location bar in Firefox.

view-source:chrome://browser/content/browser.xul
view-source:chrome://browser/content/browser.xhtml
view-source:chrome://browser/content/places/places.xul
view-source:chrome://browser/content/places/places.xhtml
view-source:chrome://browser/content/pageinfo/pageInfo.xul
view-source:chrome://global/content/commonDialog.xul

Note that browser.xul is renamed to browser.xhtml in Firefox 69.

Note that places.xul is renamed to places.xhtml in Firefox 73.
Oomingmak
Posts: 203
Joined: July 10th, 2004, 7:46 pm
Location: UK

Re: keyconfig 20110522

Post by Oomingmak »

Can anyone please tell me how to assign a hotkey to the Developer Tools 'Eyedropper'?

I searched the thread: http://forums.mozillazine.org/search.ph ... sf=msgonly but the examples shown do not work in Waterfox (which is based on Firefox v56). Mozilla did something to screw up the eye dropper in Firefox v55 and v56 prior to the switch to Quantum in v57.

I did try using that GetCommand thingy to see if there was a new command instead of openEyedropper(); but no dialog pops up when I run it (the GetCommand tooltip at the bottom just says 'Event listener is removed').
Oomingmak
Posts: 203
Joined: July 10th, 2004, 7:46 pm
Location: UK

Re: keyconfig 20110522

Post by Oomingmak »

morat wrote:See the code snippet in the menus.js file ...
Thank you, but I'm in a bit over my head with these links.

I chose the first link (esr 52) seeing as it's pre-quantum and so I assumed this is what would work for Waterfox. I see an oncommand(event) which looks like where the action is, but I'm not sure how much to include either side of that and whether it can just be pasted as is.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

Is the Waterfox 56 source available online?

Waterfox 68...

http://github.com/MrAlex94/Waterfox/blo ... t/menus.js
http://github.com/MrAlex94/Waterfox/blo ... ersion.txt

I probably couldn't figure out the command without installing Waterfox. (too troublesome)
pintassilgo
Posts: 200
Joined: August 30th, 2013, 3:50 pm

Re: keyconfig 20110522

Post by pintassilgo »

morat wrote:Is the Waterfox 56 source available online?
https://github.com/MrAlex94/Waterfox/tree/classic
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@pintassilgo

Thanks.

@Oomingmak

Waterfox 56...

http://github.com/MrAlex94/Waterfox/blo ... t/menus.js
http://github.com/MrAlex94/Waterfox/blo ... /target.js
http://github.com/MrAlex94/Waterfox/blo ... toolbar.js
http://github.com/MrAlex94/Waterfox/blo ... Loader.jsm
http://github.com/MrAlex94/Waterfox/blo ... ersion.txt

view-source:resource://devtools/client/menus.js
view-source:resource://devtools/client/framework/target.js
view-source:resource://devtools/client/shared/developer-toolbar.js
view-source:resource://devtools/shared/Loader.jsm

Try this:

Code: Select all

(function () {

  var { loader } = Components.utils.import("resource://devtools/shared/Loader.jsm", {});

  loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
  loader.lazyRequireGetter(this, "CommandUtils", "devtools/client/shared/developer-toolbar", true);

  var target = TargetFactory.forTab(gBrowser.selectedTab);
  CommandUtils.executeOnTarget(target, "eyedropper --frommenu");

})();
Devtools file loading
http://gist.github.com/juliandescottes/ ... 441542565b
Oomingmak
Posts: 203
Joined: July 10th, 2004, 7:46 pm
Location: UK

Re: keyconfig 20110522

Post by Oomingmak »

morat wrote:Try this:

Code: Select all

(function () {

  var { loader } = Components.utils.import("resource://devtools/shared/Loader.jsm", {});

  loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
  loader.lazyRequireGetter(this, "CommandUtils", "devtools/client/shared/developer-toolbar", true);

  var target = TargetFactory.forTab(gBrowser.selectedTab);
  CommandUtils.executeOnTarget(target, "eyedropper --frommenu");

})();
Success! It works!

Thank you SO much for this. I would have never been able to figure this out for myself.
Post Reply