wshanks/tbkeys

How can I set up a keyboard shortcut to call the `copy_link_1` command in cb_thunderlink?

ndbroadbent opened this issue · 4 comments

I want to set up a shortcut for the l key to run the cb_thunderlink command and generate a link to the email.

I found the manifest for this extension, but am struggling to figure out how to set up the shortcut for these commands: https://github.com/CamielBouchier/cb_thunderlink/blob/main/mail_extension/manifest.json

    "commands": {
	"drop_link": {
	    "suggested_key": {
		"default": "Ctrl+Alt+0"
	    },
	    "description": "Paste configurable link from the clipboard"
	},
	"copy_link_1": {
	    "suggested_key": {
		"default": "Ctrl+Alt+1"
	    },
	    "description": "Copy configurable link 1 to the clipboard"
	},
	"copy_link_2": {
	    "suggested_key": {
		"default": "Ctrl+Alt+2"
	    },
	    "description": "Copy configurable link 2 to the clipboard"
	},
...

This didn't work:

    "l": "cmd:copy_link_1"

How can I set up a keyboard shortcut to call copy_link_1?


Another question: How can I see a list of available commands? I opened the Thunderbird Developer Toolbox but couldn't find a way to list all the commands.

Solution 1:

You can change the following cb_thunderlink shortcuts in the Addons Manager tab.

  • Paste configurable link from the clipboard
  • Copy configurable link 1 to the clipboard
  • Copy configurable link 2 to the clipboard
  • Copy configurable link 3 to the clipboard
  • Copy configurable link 4 to the clipboard
  • Copy configurable link 5 to the clipboard

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

Solution 2:

Here is the usage of the cb_thunderlink addon, AFAICT.

  • select message
  • right click on message
  • click cb_thunderlink menu item to copy link
  • select another message
  • click cb_thunderlink button to select original message

I got the following code snippet to execute the copy_link_1 command using the error console. (not tested with tbkeys)

(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 == 'cb_thunderlink') {
          addonPolicy.extension.tabManager.addActiveTabPermission();
          addonPolicy.extension.shortcuts.onCommand('copy_link_1');
        }
      });
    }
  }
})();

MailExtension API support
http://github.com/wshanks/tbkeys/issues/46
http://forums.mozillazine.org/viewtopic.php?p=14922347#p14922347

Are you using tbkey or tbkeys-lite?

You cannot run arbitrary javascript with tbkeys-lite.

You can use the cmd shorthand and func shorthand with tbkeys and tbkeys-lite.

Use the cmd shorthand for calling a command using the goDoCommand method.

For example, "cmd:cmd_nextMsg" is the same as "window.goDoCommand('cmd_nextMsg');".

Use the func shorthand for calling a function on the window object without a parameter.

For example, "func:MsgNewMessage" is the same as "window.MsgNewMessage();".

There is a tbkeys.xpi link on the releases page.

Install tbkeys
http://github.com/wshanks/tbkeys#install

cb_thunderlink
http://addons.thunderbird.net/thunderbird/addon/988228
http://camiel.bouchier.be/en/cb_thunderlink
http://github.com/mikehardy/thunderlink

ThunderLink (obsolete)
http://addons.thunderbird.net/thunderbird/addon/314745

How can I see a list of available commands?

There is a code snippet to show commands using the error console and searchfox links that show commands in the following reply.

Tips
http://forums.mozillazine.org/viewtopic.php?p=14872763#p14872763

Wow, thank you so much for the detailed reply! I also didn't know it was possible to change the shortcuts the normal way (in the Addons Manager tab), so that's very helpful and should be the easiest option. Thanks!

I think the Addons Manager tab requires either the Ctrl or Alt modifier for alphabetic keys, so the Z or Shift+Z shortcut isn't allowed.

I got the code snippet working with tbkeys using the Z shortcut.

Online Multiline to Single Line Converter
http://tools.knowledgewalls.com/online-multiline-to-single-line-converter