MozillaZine


"Show remote content" hotkey?

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

Post Posted July 19th, 2020, 6:38 pm

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: 4672
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 19th, 2020, 7:29 pm

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/blob/master/addon/background.js

keyconfig thread about tbkeys
http://github.com/trlkly/dorando-keyconfig/issues/30

MicheleBS
 
Posts: 86
Joined: May 11th, 2012, 11:14 am

Post Posted July 20th, 2020, 4:05 am

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

Post Posted September 14th, 2020, 10:49 pm

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: 4672
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 15th, 2020, 5:23 am

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

Post Posted September 15th, 2020, 6:08 am

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: 4672
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 15th, 2020, 10:25 am

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>

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.

MicheleBS
 
Posts: 86
Joined: May 11th, 2012, 11:14 am

Post Posted September 16th, 2020, 6:52 am

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: 4672
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 16th, 2020, 7:34 am

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

Post Posted September 18th, 2020, 2:58 pm

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: 4672
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 18th, 2020, 5:56 pm

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

Post Posted June 13th, 2021, 8:01 pm

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: 4672
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 14th, 2021, 6:46 am

@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

Post Posted June 14th, 2021, 7:12 am

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

Thank you morat for helping tallredpaul.

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

Post Posted June 14th, 2021, 7:53 am

@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

Return to Thunderbird Support


Who is online

Users browsing this forum: No registered users and 2 guests