keyconfig 20110522

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

Re: keyconfig 20110522

Post by morat »

@pacocasc

Are you using tbkeys or tbkeys lite?

tbkeys (allow custom commands)
http://github.com/willsALMANJ/tbkeys

tbkeys lite (does not allow custom commands)
http://addons.thunderbird.net/thunderbird/addon/987885
tbkeys developer wrote:preferences page will not allow invalid JSON to be submitted
Customizing key bindings
http://github.com/wshanks/tbkeys#custom ... y-bindings

Did you remember to remove the newline characters in the code snippet so the input is a valid JSON string?

Did you remember to remove the trailing comma after the last key so the input is a valid JSON string?

valid JSON:

Code: Select all

{
    "j": "cmd:cmd_nextMsg",
    "k": "cmd:cmd_previousMsg"
}
valid JSON:

Code: Select all

{
    "a": "(function () { window.alert('test'); })();"
}
invalid JSON:

Code: Select all

{
    "a": "(function () {
  window.alert('test');
})();"
}
JSON Validator
http://jsonlint.com/
pacocasc
Posts: 10
Joined: November 19th, 2020, 9:38 am

Re: keyconfig 20110522

Post by pacocasc »

morat wrote:@pacocasc

Are you using tbkeys or tbkeys lite?

tbkeys (allow custom commands)
http://github.com/willsALMANJ/tbkeys

tbkeys lite (does not allow custom commands)
http://addons.thunderbird.net/thunderbird/addon/987885
tbkeys developer wrote:preferences page will not allow invalid JSON to be submitted
Customizing key bindings
http://github.com/wshanks/tbkeys#custom ... y-bindings

Did you remember to remove the newline characters in the code snippet so the input is a valid JSON string?

Did you remember to remove the trailing comma after the last key so the input is a valid JSON string?

valid JSON:

Code: Select all

{
    "a": "(function () { window.alert('test'); })();"
}
invalid JSON:

Code: Select all

{
    "a": "(function () {
  window.alert('test');
})();"
}
JSON Validator
http://jsonlint.com/
Thanks, thanks, thanks.
I had forgotten to remove the newline characters.
Now, it work very fine. Thanks a lot
Last edited by pacocasc on November 21st, 2020, 11:53 am, edited 1 time in total.
avada
Posts: 1932
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

morat wrote:The other code is for the legacy DownThemAll! addon.

Code: Select all
- var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
- getInterface(Components.interfaces.nsIDOMWindowUtils);
+ var utils = window.windowUtils;


I doubt the "dta:turbo-link" id exists in the WebExtension DownThemAll! addon.
Thanks! It works. (As does opening a link in a tab)

(Sorry, I think I misunderstood you at first. I didn't know there was a webextension DTA in existence.)
Elhem Enohpi
Posts: 49
Joined: March 19th, 2016, 8:49 am

Re: keyconfig 20110522

Post by Elhem Enohpi »

I'm trying to use tbkeys to toggle the visibility of the mail toolbar and the headers display. The first I've solved from morat's example (thanks!), using this:

Code: Select all

window.document.getElementsByAttribute('label', 'Mail Toolbar')[0].doCommand();
But there's no menu command to hide the headers display, and I can't work out how to do it. I can hide it in userChrome.css with:

Code: Select all

#msgHeaderView { visibility: collapse; }
so I tried:

Code: Select all

window.document.getElementByID('msgHeaderView').setAttribute('style', 'visibility: collapse;');
but that didn't work (and wouldn't have a toggle function if it did). I found an older keyconfig example for Firefox and tried this:

Code: Select all

(function () { var css = []; css.push("#msgHeaderView { visibility: collapse; }"); var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); var uri = ios.newURI("data:text/css," + encodeURIComponent(css.join("\n")), null, null); var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService); if (sss.sheetRegistered(uri, sss.USER_SHEET)) { sss.unregisterSheet(uri, sss.USER_SHEET); } else { sss.loadAndRegisterSheet(uri, sss.USER_SHEET); } })();
but also no luck (and I don't really understand what it's doing). Any suggestions?
morat
Posts: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Elhem Enohpi

The following code is 0 at startup or 1 after opening the View > Toolbars popup. (use error console to test)

Code: Select all

document.getElementsByAttribute("label", "Mail Toolbar").length;
The document method "getElementByID" with capital "D" does not exist.

How to toggle the message header view element:

Code: Select all

(function () {
  var hbox = window.document.getElementById('msgHeaderView');
  hbox.collapsed = !hbox.collapsed;
})();
Elhem Enohpi
Posts: 49
Joined: March 19th, 2016, 8:49 am

Re: keyconfig 20110522

Post by Elhem Enohpi »

morat, thanks for your help... the second example does in fact toggle the message header pane visibility, but it has to be done every time a new message is read. I guess I'd have to figure out how to make it persistent. If I make it collapsed by default in userChrome.css, then the toggle doesn't seem to work to show it. Sorry, my javascript/css knowledge is very limited...
morat
Posts: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Elhem Enohpi

Remember to include the window object in custom commands.

Try this:

Code: Select all

(function () {
  var css = '#msgHeaderView { display: none !important; }';
  var ios = window.Components.classes['@mozilla.org/network/io-service;1'].
    getService(window.Components.interfaces.nsIIOService);
  var uri = ios.newURI('data:text/css,' + window.encodeURIComponent(css), null, null);
  var sss = window.Components.classes['@mozilla.org/content/style-sheet-service;1'].
    getService(window.Components.interfaces.nsIStyleSheetService);
  var type = sss.USER_SHEET;
  if (sss.sheetRegistered(uri, type)) sss.unregisterSheet(uri, type);
  else sss.loadAndRegisterSheet(uri, type);
})();
Elhem Enohpi
Posts: 49
Joined: March 19th, 2016, 8:49 am

Re: keyconfig 20110522

Post by Elhem Enohpi »

Ok, great! In order to get the headers to be hidden by default, I put:

Code: Select all

#msgHeaderView { visibility: collapse; }
in userChrome.css, and changed the second line of your example to use "visibility: visible" - seems to do the trick, thanks very much!

In case someone else wants it, here it is without the newlines, bound to the "h" key, which can be pasted into tbkeys prefs:

Code: Select all

"h": "(function () { var css = '#msgHeaderView { visibility: visible !important; }'; var ios = window.Components.classes['@mozilla.org/network/io-service;1'].getService(window.Components.interfaces.nsIIOService); var uri = ios.newURI('data:text/css,' + window.encodeURIComponent(css), null, null); var sss = window.Components.classes['@mozilla.org/content/style-sheet-service;1'].getService(window.Components.interfaces.nsIStyleSheetService); var type = sss.USER_SHEET; if (sss.sheetRegistered(uri, type)) sss.unregisterSheet(uri, type); else sss.loadAndRegisterSheet(uri, type); })();",
Elhem Enohpi
Posts: 49
Joined: March 19th, 2016, 8:49 am

Re: keyconfig 20110522

Post by Elhem Enohpi »

Last week I wrote that this works to toggle the Mail Toolbar, but it turns out that it only works after you've already done it once by the menu:

Code: Select all

window.document.getElementsByAttribute('label', 'Mail Toolbar')[0].doCommand();
morat, I think you were alluding to that:
The following code is 0 at startup or 1 after opening the View > Toolbars popup. (use error console to test)

Code: Select all

document.getElementsByAttribute("label", "Mail Toolbar").length;
Anyway, using this instead seems to work:

Code: Select all

window.goToggleToolbar('mail-bar3');
morat
Posts: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

Elhem Enohpi wrote:Anyway, using this instead seems to work:

Code: Select all

window.goToggleToolbar('mail-bar3');
Here is how to toggle the status bar.

Code: Select all

window.goToggleToolbar('status-bar', 'menu_showTaskbar');
The status bar uses the hidden attribute.

The mail toolbar uses the collapsed attribute.

Reference
http://searchfox.org/comm-esr78/search? ... gleToolbar

The user interface may not work correctly because the mail toolbar may have "collapsed":"true" and "hidden":"true" set in the xulstore.json file.

By "user interface" I mean:

* View > Toolbars > Mail Toolbar
* right click a toolbar then click Mail Toolbar

Here is how to toggle the mail toolbar.

Code: Select all

(function () {
  var toolbar = window.document.getElementById('mail-bar3');
  var isCollapsed = toolbar.getAttribute('collapsed') == 'true';
  if (isCollapsed) toolbar.removeAttribute('collapsed');
  else toolbar.setAttribute('collapsed', 'true');
  window.Services.xulStore.persist(toolbar, 'collapsed');
})();
adelphiaUK
Posts: 2
Joined: February 3rd, 2021, 10:23 am

Re: keyconfig 20110522

Post by adelphiaUK »

Hi. Excuse me for being a bit forward here, but this is quite a long thread so I don't really know where I should start to catch up from.

I'm interested in making a simple collapse all accounts/folders in my Folders list but, unless I'm very much mistaken, I can't find one and the suggestions to use your keyconfig go awry as I'm using version 78.7.0 of Thunderbird (having just, finally, switched from Outlook).

Could someone suggest where I would start or if there is already a function for that hidden somewhere that I just can't find.

I look forward to any replies and (hopefully polite) suggestions.

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

Re: keyconfig 20110522

Post by morat »

@adelphiaUK

You can create a keyboard shortcut that executes a custom command with the tbkeys addon.

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

Here is how to collapse all tree nodes in the folder pane.

Code: Select all

(function () {
  var f = window.gFolderTreeView;
  for (var i = f.rowCount - 1; i >= 0; i--) {
    if (f.isContainer(i) && f.isContainerOpen(i)) {
      f.toggleOpenState(i);
    }
  }
})();
Tips: http://forums.mozillazine.org/viewtopic ... #p14872763
adelphiaUK
Posts: 2
Joined: February 3rd, 2021, 10:23 am

Re: keyconfig 20110522

Post by adelphiaUK »

Thanks @morat for that (not sure if there's a "Thanks" button in these forums).

I'm completely new to Thunderbird but I like what I see so far, there's just a few tweeks I want to sort before I can say I'm totally OK with it but I've been so fed up with Outlook over the past year or so with bugs entering into the software that drive me crazy.
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Move message to specified folder

Post by bege »

Hello, what is wrong with this code?:
I tried to put the code from an earlier post to tbkeys to move a selected message to a specified folder. But tbkeys (not lite) does not save it.

Code: Select all

"m": "(function () { var targetUri = "mailbox://me%40gmx.de@mail.gmx.net/Trash"; var targetFolder = MailUtils.getFolderForURI(targetUri); MsgMoveMessage(targetFolder); })();",
morat
Posts: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@bege

MailUtils.getFolderForUri was renamed to MailUtils.getExistingFolder.

Reference
http://developer.thunderbird.net/?q=getFolderForURI
Post Reply