"Show remote content" hotkey?

User Help for Mozilla Thunderbird
MicheleBS
Posts: 86
Joined: May 11th, 2012, 11:14 am

Re: "Show remote content" hotkey?

Post by MicheleBS »

Hello morat, thank you.

If I edit background.js, have I to compile tbkeys.xpi, then? I'm not so expert.

Couldn't we simply edit the text file shown in Addons/tbkeys/Options? I tried to past your single line code there, but the hotkey doesn't work:

Code: Select all

{
    "j": "window.goDoCommand('cmd_nextMsg')",
    "k": "window.goDoCommand('cmd_previousMsg')",
    "o": "window.goDoCommand('cmd_openMessage')",
    "f": "window.goDoCommand('cmd_forward')",
    "#": "window.goDoCommand('cmd_delete')",
    "r": "window.goDoCommand('cmd_reply')",
    "a": "window.goDoCommand('cmd_replyall')",
    "x": "window.goDoCommand('cmd_archive')",
    "c": "(function () { var kBlockRemoteContent = 1; var kAllowRemoteContent = 2; var msgHdr = gMessageDisplay.displayedMessage; if (msgHdr) { var remoteContentPolicy = msgHdr.getUint32Property('remoteContentPolicy'); if (remoteContentPolicy == kBlockRemoteContent) { setMsgHdrPropertyAndReload('remoteContentPolicy', kAllowRemoteContent); } else if (remoteContentPolicy == kAllowRemoteContent) { setMsgHdrPropertyAndReload('remoteContentPolicy', kNoRemoteContentPolicy); } window.content.focus(); } })();"

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

Re: "Show remote content" hotkey?

Post by morat »

Okay. I tested the tbkeys extension. I can change tbkeys settings in Tools > Addon Options > tbkeys.

Code: Select all

"c": "alert('test')", // fails

Code: Select all

"c": "window.alert('test')", // succeeds

Code: Select all

"c": "(function () { window.alert('test'); })();", // succeeds
Try this:

Code: Select all

"c": "(function () { var kNoRemoteContentPolicy = 0; var kBlockRemoteContent = 1; var kAllowRemoteContent = 2; var msgHdr = window.gMessageDisplay.displayedMessage; if (msgHdr) { var remoteContentPolicy = msgHdr.getUint32Property('remoteContentPolicy'); if (remoteContentPolicy == kBlockRemoteContent) { window.setMsgHdrPropertyAndReload('remoteContentPolicy', kAllowRemoteContent); } else if (remoteContentPolicy == kAllowRemoteContent) { window.setMsgHdrPropertyAndReload('remoteContentPolicy', kNoRemoteContentPolicy); } window.content.focus(); } })();",
note: remove trailing comma if "c" is the last key

How do I reset the tbkeys settings? I guess I would need to get the default settings from the background.js file.

tbkeys
http://github.com/willsALMANJ/tbkeys
http://github.com/willsALMANJ/tbkeys/bl ... kground.js

keyconfig thread about tbkeys
http://github.com/trlkly/dorando-keyconfig/issues/30
MicheleBS
Posts: 86
Joined: May 11th, 2012, 11:14 am

Re: "Show remote content" hotkey?

Post by MicheleBS »

Thank you morat. To reset the hotkeys is simple: you have to clear all of them in the text form and click on Save settings then: the default hotkeys will be reloaded then.
MicheleBS
Posts: 86
Joined: May 11th, 2012, 11:14 am

Re: "Show remote content" hotkey?

Post by MicheleBS »

Dear morat,

it's with some delay that only now I could test you suggestion. Sorry for the delay.

My aim, remember, was to create a "c" hotkey with the tbkeys addon, able to toggle on/off the "Show remote content" command in a message I have received.

Your command works; but, only when the main window of Thunderbird is selected: "c" toggles on/off the command, but for the whole Thunderbird messages. If I open a single message on a separate window, the hotkey "c" doesn't work...

I'd like to toggle on/off the remote content of the single message, after I opened its window and I am viewing it.

Do you think it's possible to enhance your code?

Thank you.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: "Show remote content" hotkey?

Post by morat »

Key bindings for the tbkeys extension do not fire in the message window. The feature is not supported.

Tools > Addons > tbkeys > Options > Settings > Main key bindings
Tools > Addons > tbkeys > Options > Settings > Compose key bindings

The main key bindings fire in the 3pane window.
The compose key bindings fire in the compose window.
MicheleBS
Posts: 86
Joined: May 11th, 2012, 11:14 am

Re: "Show remote content" hotkey?

Post by MicheleBS »

Just as I feared...

Please let me know if you come aware of other addons able to work on the single message...

Thank you!
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: "Show remote content" hotkey?

Post by morat »

You can hack the tbkeys extension, then add a message key binding.

Tools > Addons > tbkeys > Options > Settings > Message key bindings

The message key bindings fire in the message window.

Hack for tbkeys 2.1.0:

* manifest.json

Code: Select all

- "name": "tbkeys",
+ "name": "tbkeys hack",

Code: Select all

- "version": "2.1.0",
+ "version": "2.1.0.1",
* implementation.js

Code: Select all

- "compose": "msgcompose"
+ "compose": "msgcompose", "message": "mail:messageWindow"
* background.js

Code: Select all

- "composekeys": "{}"
+ "composekeys": "{}", "messagekeys": "{}"

Code: Select all

  browser.tbkeys.bindkeys(JSON.parse(settings.composekeys), "compose")
+ browser.tbkeys.bindkeys(JSON.parse(settings.messagekeys), "message")
* options.html

Code: Select all

  <tr>
    <td>
      <label>Compose key bindings</label>
    </td>
    <td>
      <textarea id="composekeys" class="json" rows="20" cols="60"></textarea>
    </td>
  </tr>
+ <tr>
+   <td>
+     <label>Message key bindings</label>
+   </td>
+   <td>
+     <textarea id="messagekeys" class="json" rows="20" cols="60"></textarea>
+   </td>
+ </tr>
Hack for tbkeys 2.2.0: http://forums.mozillazine.org/viewtopic ... #p14919152

tbkeys releases
http://github.com/willsALMANJ/tbkeys/releases

...

I tested the above "Try this:" code snippet in Thunderbird 68. It works in the message window here.

...

I could send a tbkeys_hack.xpi link in a private message, if you don't want to hack the extension.
Last edited by morat on March 7th, 2022, 6:37 am, edited 3 times in total.
MicheleBS
Posts: 86
Joined: May 11th, 2012, 11:14 am

Re: "Show remote content" hotkey?

Post by MicheleBS »

You're kind.

I have made the changes in the original files, but now I can't create the xpi.
I have added all the files to a compressed folder, then I have changed its extension from .zip to .xpi. But when I try to install the addon, Thunderbird says it's corrupted.

Can you tell me how to do to pack all the files into a .xpi folder?

Otherwise, I'll be glad to receive your tbkeys_hack in a private message.

Thank you!
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: "Show remote content" hotkey?

Post by morat »

Okay. I sent a link in a private message.

Remember to uninstall the current version, then restart before installing the hacked version.
MicheleBS
Posts: 86
Joined: May 11th, 2012, 11:14 am

Re: "Show remote content" hotkey?

Post by MicheleBS »

Dear morat, your idea works great. Thank you.

:turn-l:

With the modified extension, I can toggle [on] and [off] the external content of the single message I am reading. This is very comfortable for me. I keep it off by default, and only if I need to see the whole content of the e-mail, I press "c".
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: "Show remote content" hotkey?

Post by morat »

You're welcome.

I posted a reply in the keyconfig thread in case someone else could use the hack.
tallredpaul
Posts: 2
Joined: June 13th, 2021, 7:51 pm

Re: "Show remote content" hotkey?

Post by tallredpaul »

MicheleBS or Morat, could you please send me details on how you implemented the tbkeys solution from Sep 18, 2020? I have tried various ways and I have not been successful. I am a competent programmer but have not been able to get the latest code posted to work in tbkeys. Apparently I am missing something very subtle. Thanks so much for your assistance.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: "Show remote content" hotkey?

Post by morat »

@tallredpaul

Are you talking about the tbkeys.xpi hack that adds key bindings support for the message window?

tbkeys.xpi
http://github.com/wshanks/tbkeys/releases

Thunderbird has a javascript cache, which is not automatically cleared across restarts. To clear the cache when restarting, add a -purgecaches flag to the executable commandline.

i.e.

thunderbird.exe -purgecaches
ThunderbirdPortable.exe -purgecaches

Try purging the javascript cache. If that doesn't work, then I will try hacking the newest version.
MicheleBS
Posts: 86
Joined: May 11th, 2012, 11:14 am

Re: "Show remote content" hotkey?

Post by MicheleBS »

Still I make use of morat's hacked version of tbkeys, everyday, with lots of delight.

Thank you morat for helping tallredpaul.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: "Show remote content" hotkey?

Post by morat »

@tallredpaul

Okay. I sent a link using the 2.1.0 version in a private message.

Remember to (1) (2) (3), then restart before installing the hacked version.

1. backup key bingings just in case
2. uninstall current version
3. set addons to update manually
Post Reply