User Help for Mozilla Thunderbird
morat
Posts: 4197Joined: February 3rd, 2009, 6:29 pm
Posted October 21st, 2020, 12:41 pm
I changed userChrome.js code to insert the "Example" button on the mail toolbar in the main window only. - Code: Select all
/* Thunderbird userChrome.js */
// Thunderbird 68 uses the messenger.xul page. // Thunderbird 78 uses the messenger.xhtml page.
(function () { if (location == "chrome://messenger/content/messenger.xul" || location == "chrome://messenger/content/messenger.xhtml") { try { var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var toolbarbutton = document.createElementNS(XUL_NS, "toolbarbutton"); var dataUrl = "data:image/png;base64," + "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAACNFBMVEXDRgDweQDnbwC0Ng" + "DCRQC7PQDtpTu+QQD78q3PUwDCRAD//8vbYQDLTgDocAD0iQX1jQbGSgD7iAD4gwDVaw7v" + "dwDyegD+igDweQDlawDyhAXveADmZwDzmBbtcwDwkhHveADmhBTkgxbweADkfRH+igD7hA" + "DXZQX0gADyjA/tfgvveQDiawDQVADRXgfnbwD1jAb9iQD9z0PVZAbxpinykRHtdgD5mRbE" + "RQDDRgDOYArCRAD9iQD3ewDxegD3dwDFRgDAQAD+hgD4fQDucgDtgQftfwTISQDCRQDvdg" + "D5lxb1kRb2qh7wnynkagD766LDRQDDRwDDRQDspjbtpzbuqDbvqzv//8DUZAbCRQD//83p" + "jhvveQbvggW+QQDfcxLlmUb//8veYADMTwDHSADVVwC8PgDwixb78q3oZgDUWADRVADCRQ" + "D9iQDERwDBQQDYVQC+PgC0NgDbYQDWWgDUWADSVQDFSAC+QAC7PAC0NgD+wRL+/kD+/zb+" + "7i3+8Cv+/DX+wBL/+DD/rwz+qgz+rwz/tAz+sQzfbAT+3iP/+jD//Dz1jwP+nwf5iwf7pB" + "z2tRr4lwb/ogfsdQT+2R7/9ET+2iT8yyLmgBL5iQL2egLokhP7zzT60zv1zUr0gAL1ewP5" + "0yn9+UL++EXooyngaAH41EPzowzyySj+xxzlhhHvvyruwjXxvTnUag3+zxrwigP+swz86U" + "/ZXwD75lHqegD6xzb//kn+uhPTXAG3OAD/+UC2vFeJAAAAe3RSTlMAAAAAAAAAAAAAAAAA" + "AAAAAAAAAACfnwAIaelpAAA2+wD7UQAAa3oArKzRzMysnwgAvPQA/gAAw3prw0oALr16vS" + "4AACnF6bspAAAA/mIAADQAAAAAAI8AAEwA0vv7kd2yAuuvr+vKABL23U+8Sk/d9vUDIIAQ" + "AAAQgCAfvupHAAABB0lEQVR4Xi3IU3fDABgA0C+u26FdZ9u2bdu2vZSzbds2/tyac3IfLx" + "jpGyA6MimqY6gHTNgiiNwkwRM1E7EhTrYyTfMzzsh0ZEPiH+D6+u5mV1jEhpe5haVCYW1T" + "4suEvUOkk7PLpVJ5WFnl7hEUDN5LPvsHJ6cazdn13f3DYxu0B35+/Y2qVSr17NzGeUgohI" + "VHLK/PMDa39qKieRATGxd/9cS4uU1MwnmQktqY/qGlaVr7/ZOVDTmQm5df8PwyNj4xOTVd" + "jOM4kCRZOr+wWFa+srpWQVEU8PnV2zu7NbV19UfHDQRBAIfTdNHc0soVdnR2dfdgGAgEvW" + "99/QNc4eDQ8O8Ihv0D77NPgbVLZ6kAAAAASUVORK5CYII="; var props = { id: "__unique_identifier_example_button", class: "toolbarbutton-1 chromeclass-toolbar-additional", label: "Example", tooltiptext: "Example", oncommand: 'Services.prompt.alert(window, "Example 3", document.location.href);', style: 'list-style-image: url("' + dataUrl + '"); -moz-image-region: auto;', }; for (var p in props) toolbarbutton.setAttribute(p, props[p]); var toolbar = document.getElementById("mail-bar3"); var appMenuButton = document.getElementById("button-appmenu"); toolbar.insertBefore(toolbarbutton, appMenuButton.nextSibling); } catch (e) { Components.utils.reportError(e); // [check] Show Content Messages } } })();
The "Example" button inserts after the hamburger button. (also called the app menu button)
user2018
Posts: 87Joined: September 23rd, 2018, 11:07 am
Posted October 21st, 2020, 1:25 pm
No luck for the moment. I tried with the .css file suggested and setting the indicated property, but still no changes.
The output I obtain in the error console using the command indicated is the following:
document.getElementById("mail-toolbar-menubar2").currentSet; --> "menubar-items,__unique_identifier_example_button"
If I interpret it correctly, the added button seems to be the only button in mail-toolbar-menubar2.
With "document.getElementById("menubar-items").currentSet;" I obtain the output "undefined".
morat
Posts: 4197Joined: February 3rd, 2009, 6:29 pm
Posted October 21st, 2020, 8:22 pm
The #menubar-items element is not a toolbar so it doesn't have a currentSet property.
user2018
Posts: 87Joined: September 23rd, 2018, 11:07 am
Posted October 23rd, 2020, 1:34 am
Thank you very much for your help! Now I managed to get the buttons in the correct place. Using the last two suggestions at the same time solved the problem! However, I have some problems executing scripts. The following piece of code was working before but not now: - Code: Select all
var am = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); customizedAlert("List of all servers obtained!");
var allServers = am.allServers; var numServers = allServers.length; customizedAlert("Number of servers: " + numServers); customizedAlert("msgHdr: " + msgHdr); for (var i = 0; i < numServers; i++) { customizedAlert("Server number " + i); if (msgHdr === null) { customizedAlert("Querying server number " + i); var server = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer); customizedAlert("Server to check subfolders: " + server.prettyName); ...
The messages are printed until "Querying server number 0" (included), but I never get the message "Server to check subfolders: 0". It hangs at "allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);". I'm stuck with this, which worked with the previous Thunderbird version. Any idea is welcome.
morat
Posts: 4197Joined: February 3rd, 2009, 6:29 pm
Posted October 23rd, 2020, 3:57 am
Try something like: - Code: Select all
(function () { var allServers = MailServices.accounts.allServers; var counter = 0; for (var server of allServers) { counter++; alert(`Pretty name for server ${counter} of ${allServers.length}: ${server.prettyName}`); } })();
Reference http://searchfox.org/comm-esr78/search?q=allServers
user2018
Posts: 87Joined: September 23rd, 2018, 11:07 am
Posted October 25th, 2020, 4:35 am
Thanks a lot, that solved the problem!! Now I'm stuck with another problem coming in another one of my scripts: - Code: Select all
customizedAlert("Debug - parseAddresses 1"); var hdrParser = Components.classes["@mozilla.org/messenger/headerparser;1"].getService(Components.interfaces.nsIMsgHeaderParser); customizedAlert("Debug - parseAddresses 2"); var uniqueAddresses = hdrParser.removeDuplicateAddresses(addresses, ""); customizedAlert("Debug - parseAddresses 3"); var emailAddresses = {}; var names = {}; var fullNames = {}; customizedAlert("Debug - parseAddresses 4"); var numAddresses = hdrParser.parseHeadersWithArray(uniqueAddresses, emailAddresses, names, fullNames); //customizedAlert(addresses + "\n" + uniqueAddresses); //customizedAlert(emailAddresses.value + "\n" + names.value + "\n" + fullNames.value); customizedAlert("Debug - parseAddresses 5");
This worked with the previous version of Thunderbird (68.12.1), but now it gets stuck at the call to "hdrParser.parseHeadersWithArray": I get the "Debug - parseAddresses 4" message but never the "Debug - parseAddresses 5" message. The "parseHeadersWithArray" function is documented at https://developer.mozilla.org/en-US/doc ... aderParser. Any ideas are welcome.
user2018
Posts: 87Joined: September 23rd, 2018, 11:07 am
Posted October 25th, 2020, 10:20 am
Thank you very much! This seems to solve my problem perfectly!
Return to Thunderbird Support
Who is online
Users browsing this forum: No registered users and 6 guests
|