keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
morat
Posts: 6188
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@pacocasc

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 GitHub releases page.

Troubleshooting: viewtopic.php?p=14872763#p14872763
pacocasc
Posts: 10
Joined: November 19th, 2020, 9:38 am

Re: keyconfig 20110522

Post by pacocasc »

I use tbkey (no tbkeys-lite). I've been using the function you helped me create (to mark a message as answered), without problems for the last 3 years. Now, when Thunderbird was updated to 115.4.1 it stopped working.

Code: Select all

(function () {
  var msgHdr = window.gFolderDisplay.selectedMessage;
  if (msgHdr.flags & window.Components.interfaces.nsMsgMessageFlags.Replied) {
    msgHdr.folder.msgDatabase.MarkHdrReplied(msgHdr, false, null);
  } else {
    msgHdr.folder.msgDatabase.MarkHdrReplied(msgHdr, true, null);
  }
  msgHdr.folder.msgDatabase = null;
})();
I tried changing to the following (without the newline characters), but marking a message as answered still doesn't work (It doesn't mark it as an error but it doesn't do anything)

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAboutMessage.gMessage;
  if (msgHdr.flags & window.Components.interfaces.nsMsgMessageFlags.Replied) {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, false, null);
  } else {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, true, null);
  }
  msgHdr.folder.msgDatabase = null;
})();
morat wrote:
November 4th, 2023, 3:00 pm
@pacocasc

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 GitHub releases page.

Troubleshooting: viewtopic.php?p=14872763#p14872763
morat
Posts: 6188
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

pacocasc wrote:And the other commands don't seem to work either.
Are you saying that nothing works? I can get various commands working with my setup.

tbkeys 2.2.4
Thunderbird 115.4.1
Windows 10 Pro 21H2 32-bit

Main key bindings:

Code: Select all

{
  "ctrl+1": "window.alert('example');",
  "ctrl+2": "window.alert(window.gTabmail.currentAboutMessage.gMessage.mime2DecodedSubject);",
  "ctrl+3": "(function () { var msgHdr = window.gTabmail.currentAboutMessage.gMessage; if (msgHdr.flags & window.Components.interfaces.nsMsgMessageFlags.Read) { window.alert('message is read'); } else { window.alert('message is unread'); }})();"
}
I can get the following command working with an unreplied message using the error console. (working means purple reply icon shows in subject column)

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAboutMessage.gMessage;
  msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, true, null);
  msgHdr.folder.msgDatabase = null;
})();
Replied indicator icon
http://searchfox.org/comm-esr115/source ... ly-col.svg
http://searchfox.org/comm-esr115/search ... -reply-col

Try asking the tbkeys developer for support.
pacocasc
Posts: 10
Joined: November 19th, 2020, 9:38 am

Re: keyconfig 20110522

Post by pacocasc »

Thanks.
tbkeys 2.2.4
Thunderbird 115.4.1
Windows 10 Home 22H2

From what you send me, only CTRL+1 works OK

Code: Select all

"ctrl+1": "window.alert('example');"
The other two (CTRL2 y CTRL 3) do nothing. And the mark as read function doesn't work either. Yes, what it did before was show the purple reply icon in the subject column and Reply in the status column. Now it doesn't do any of the two things.

I give up for the moment. Thank you so much for your patience


morat wrote:
November 5th, 2023, 1:52 pm
pacocasc wrote:And the other commands don't seem to work either.
Are you saying that nothing works? I can get various commands working with my setup.

tbkeys 2.2.4
Thunderbird 115.4.1
Windows 10 Pro 21H2 32-bit

Main key bindings:

Code: Select all

{
  "ctrl+1": "window.alert('example');",
  "ctrl+2": "window.alert(window.gTabmail.currentAboutMessage.gMessage.mime2DecodedSubject);",
  "ctrl+3": "(function () { var msgHdr = window.gTabmail.currentAboutMessage.gMessage; if (msgHdr.flags & window.Components.interfaces.nsMsgMessageFlags.Read) { window.alert('message is read'); } else { window.alert('message is unread'); }})();"
}
I can get the following command working with an unreplied message using the error console. (working means purple reply icon shows in subject column)

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAboutMessage.gMessage;
  msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, true, null);
  msgHdr.folder.msgDatabase = null;
})();
Replied indicator icon
http://searchfox.org/comm-esr115/source ... ly-col.svg
http://searchfox.org/comm-esr115/search ... -reply-col

Try asking the tbkeys developer for support.
Last edited by pacocasc on November 5th, 2023, 2:57 pm, edited 1 time in total.
pacocasc
Posts: 10
Joined: November 19th, 2020, 9:38 am

Re: keyconfig 20110522

Post by pacocasc »

Surprise:
The function you gave me in CTRL+2 has worked for me and also the function of marking a message as answered.
But they only work with an open message. They don't work, like the function worked for me before, being in the inbox with any message selected.
At least I know that by opening the message I can mark it. It's not as practical as before, but it works.

Even the function previous works with an open message. Before giving up, it occurred to me to try the read-unread alert message with the message open and when I saw that it worked, I tried the others as well.

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAboutMessage.gMessage;
  if (msgHdr.flags & window.Components.interfaces.nsMsgMessageFlags.Replied) {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, false, null);
  } else {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, true, null);
  }
  msgHdr.folder.msgDatabase = null;
})();
morat
Posts: 6188
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@pacocasc

Try these:

Code: Select all

window.alert(window.gTabmail.currentAbout3Pane.gDBView.hdrForFirstSelectedMessage.mime2DecodedSubject);

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAbout3Pane.gDBView.hdrForFirstSelectedMessage;
  if (msgHdr.flags & window.Components.interfaces.nsMsgMessageFlags.Replied) {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, false, null);
  } else {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, true, null);
  }
  msgHdr.folder.msgDatabase = null;
})();
Those code snippets should work with the message pane disabled.

i.e. Menu Bar > View > Layout > [uncheck] Message Pane F8

Similar thread
http://thunderbird.topicbox.com/groups/ ... 51886b57b1
pacocasc
Posts: 10
Joined: November 19th, 2020, 9:38 am

Re: keyconfig 20110522

Post by pacocasc »

Now it works perfectly (with the message pane disabled) like the function I had these past three years.
Thank you very much for your help and your patience.
morat wrote:
November 5th, 2023, 6:32 pm
@pacocasc

Try these:

Code: Select all

window.alert(window.gTabmail.currentAbout3Pane.gDBView.hdrForFirstSelectedMessage.mime2DecodedSubject);

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAbout3Pane.gDBView.hdrForFirstSelectedMessage;
  if (msgHdr.flags & window.Components.interfaces.nsMsgMessageFlags.Replied) {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, false, null);
  } else {
    msgHdr.folder.msgDatabase.markHdrReplied(msgHdr, true, null);
  }
  msgHdr.folder.msgDatabase = null;
})();
Those code snippets should work with the message pane disabled.

i.e. Menu Bar > View > Layout > [uncheck] Message Pane F8

Similar thread
http://thunderbird.topicbox.com/groups/ ... 51886b57b1
Cris486
Posts: 3
Joined: September 12th, 2023, 9:50 am

Re: keyconfig 20110522

Post by Cris486 »

Hi all!

My setup:
- tbkeys 2.2.4
- Thunderbird 115.4.3
- Windows 10 Pro 22H2

I recently started using Thunderbird as a news feed reader. I want to create a shortcut to copy to the clipboard the values of the "Website" header of all currently selected messages.

Image

I don't know where to start. Some advice? Thanks.
morat
Posts: 6188
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Cris486

Here is how to copy the selected message subject to the clipboard.

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAbout3Pane.gDBView.hdrForFirstSelectedMessage;
  if (msgHdr && msgHdr.mime2DecodedSubject) {
    window.Components.classes['@mozilla.org/widget/clipboardhelper;1'].
      getService(window.Components.interfaces.nsIClipboardHelper).
      copyString(msgHdr.mime2DecodedSubject);
    window.Services.prompt.alert(window, 'tbkeys', 'Copied to clipboard.');
  }
})();

Code: Select all

(function () {
  var msgHdrs = window.gTabmail.currentAbout3Pane.gDBView.getSelectedMsgHdrs();
  var out = [];
  for (var i = 0; i < msgHdrs.length; i++) {
    if (msgHdrs[i] && msgHdrs[i].mime2DecodedSubject) {
      out.push(msgHdrs[i].mime2DecodedSubject);
    }
  }
  if (out.length) {
    window.Components.classes['@mozilla.org/widget/clipboardhelper;1'].
      getService(window.Components.interfaces.nsIClipboardHelper).
      copyString(out.join('\r\n'));
    window.Services.prompt.alert(window, 'tbkeys', 'Copied to clipboard.');
  }
})();
Here is how to copy the inner text of the body element to the clipboard.

Code: Select all

(function () {
  var body = window.content && window.content.document.body;
  if (body && body.innerText) {
    window.Components.classes['@mozilla.org/widget/clipboardhelper;1'].
      getService(window.Components.interfaces.nsIClipboardHelper).
      copyString(body.innerText);
    window.Services.prompt.alert(window, 'tbkeys', 'Copied to clipboard.');
  }
})();

Code: Select all

(function () {
  var body = window.gTabmail.currentAboutMessage &&
    window.gTabmail.currentAboutMessage.getMessagePaneBrowser().contentWindow &&
    window.gTabmail.currentAboutMessage.getMessagePaneBrowser().contentWindow.document.body;
  if (body && body.innerText) {
    window.Components.classes['@mozilla.org/widget/clipboardhelper;1'].
      getService(window.Components.interfaces.nsIClipboardHelper).
      copyString(body.innerText);
    window.Services.prompt.alert(window, 'tbkeys', 'Copied to clipboard.');
  }
})();
I don't know what you mean by website header. Is the website header the same as the website title?

i.e. window.content.document.title

Document title property
http://developer.mozilla.org/docs/Web/A ... ment/title
Cris486
Posts: 3
Joined: September 12th, 2023, 9:50 am

Re: keyconfig 20110522

Post by Cris486 »

morat wrote:
November 18th, 2023, 12:14 pm
@Cris486
First of all, thanks for the help.

morat wrote:
November 18th, 2023, 12:14 pm
I don't know what you mean by website header. Is the website header the same as the website title?
I was referring to the text highlighted in green in the image I posted.
Cris486 wrote:
November 18th, 2023, 1:08 am
Image

I found that the code below works.

Code: Select all

(function () {
  var msgHdr = window.gTabmail.currentAbout3Pane.gDBView.hdrForFirstSelectedMessage;
  window.alert(msgHdr.getStringProperty('content-base'));
})();
Now I have to find a way to make it work even with multiple selected messages.
morat
Posts: 6188
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Cris486

Try this:

Code: Select all

(function () {
  var msgHdrs = window.gTabmail.currentAbout3Pane.gDBView.getSelectedMsgHdrs();
  var out = [];
  for (var i = 0; i < msgHdrs.length; i++) {
    if (msgHdrs[i] && msgHdrs[i].getStringProperty('content-base')) {
      out.push(msgHdrs[i].getStringProperty('content-base'));
    }
  }
  if (out.length) {
    var imageUrl = 'chrome://mozapps/skin/extensions/extensionGeneric.svg';
    window.Components.classes['@mozilla.org/widget/clipboardhelper;1'].
      getService(window.Components.interfaces.nsIClipboardHelper).
      copyString(out.join('\r\n'));
    window.Components.classes['@mozilla.org/alerts-service;1'].
      getService(window.Components.interfaces.nsIAlertsService).
      showAlertNotification(imageUrl, 'tbkeys', `Copied to clipboard.\n\nWebsites: ${out.length}`);
  }
})();
The code snippet works for me with Planet Mozilla.

Planet Mozilla RSS Feed
https://planet.mozilla.org/rss20.xml

Online Multiline to Single Line Converter
https://tools.knowledgewalls.com/online ... -converter
Cris486
Posts: 3
Joined: September 12th, 2023, 9:50 am

Re: keyconfig 20110522

Post by Cris486 »

morat wrote:
November 21st, 2023, 9:47 am
@Cris486

Try this:

Code: Select all

(function () {
  var msgHdrs = window.gTabmail.currentAbout3Pane.gDBView.getSelectedMsgHdrs();
  var out = [];
  for (var i = 0; i < msgHdrs.length; i++) {
    if (msgHdrs[i] && msgHdrs[i].getStringProperty('content-base')) {
      out.push(msgHdrs[i].getStringProperty('content-base'));
    }
  }
  if (out.length) {
    var imageUrl = 'chrome://mozapps/skin/extensions/extensionGeneric.svg';
    window.Components.classes['@mozilla.org/widget/clipboardhelper;1'].
      getService(window.Components.interfaces.nsIClipboardHelper).
      copyString(out.join('\r\n'));
    window.Components.classes['@mozilla.org/alerts-service;1'].
      getService(window.Components.interfaces.nsIAlertsService).
      showAlertNotification(imageUrl, 'tbkeys', `Copied to clipboard.\n\nWebsites: ${out.length}`);
  }
})();
It works! Thank you!
morat
Posts: 6188
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Cris486

You're welcome.

Here is how to change the transparent background in the alert notification.

Code: Select all

/* Thunderbird userChrome.css */

@-moz-document url-prefix("chrome://global/content/alerts/alert.xhtml") {
  #alertNotification {
    background: -moz-Dialog !important;
  }
}
Reference
http://searchfox.org/mozilla-esr115/sou ... lert.xhtml
http://searchfox.org/mozilla-esr115/sou ... /alert.css
Post Reply