MozillaZine


keyconfig 20110522

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

Post Posted October 14th, 2021, 6:09 am

@dondo

Okay. I tested the autoconfig files with Firefox Portable Legacy 78. It works for me.

* C:\FirefoxPortableLegacy78\App\Firefox\defaults\pref\autoconfig.js
* C:\FirefoxPortableLegacy78\App\Firefox\mozilla.cfg
* C:\FirefoxPortableLegacy78\Data\profile\chrome\ToggleBookmarksToolbarFirefoxShortcut.uc.js

Remember to delete the config-prefs.js and config.js files.

Check if the ToggleBookmarksToolbarFirefoxShortcut.uc.js file is really in the chrome folder in the correct profile folder.

Menu Bar > Help > Troubleshooting Information > Update Folder > Open Folder
Menu Bar > Help > Troubleshooting Information > Profile Folder > Open Folder (click here)

Check if the mozilla.cfg file is in the installation folder.

Installation folder
http://kb.mozillazine.org/Installation_directory

You may need a short delay before running the script. Try this:

* <profile directory>\chrome\ToggleBookmarksToolbarFirefoxShortcut.uc.js

Code: Select all
(function () {
  if (location != "chrome://browser/content/browser.xul" &&
      location != "chrome://browser/content/browser.xhtml") return;

  // Ctrl+Shift+B toggles the bookmarks toolbar

  setTimeout(function () {
    var key = document.getElementById("manBookmarkKb");
    key.setAttribute("oncommand", "BookmarkingUI.toggleBookmarksToolbar('bookmark-tools');");
    key.removeAttribute("command");
  }, 1000);
})();

note: 1000 for a 1 second delay

Also, test the script using the browser console.

Instructions:

* open about:config page
* set devtools.chrome.enabled preference to true
* open browser console i.e. tools > web developer > browser console
* copy and paste code into browser console command line
* press enter to run

bege
 
Posts: 144
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted November 3rd, 2021, 11:34 am

This script (not in tbkeys but as a script imported in userChrome.js) worked for a long time to toggle the spell checker in the compose window.
In TB 91 it does not work any more. It just does nothing, the error console shows nothing and when I run the command in the console it just says "undefined".
What do I need to change (maybe as tbkeys entry)?

Code: Select all
(function () {

  if (location == "chrome://messenger/content/messengercompose/messengercompose.xhtml") {
    setTimeout(function () {
      try {

        var keyset = document.getElementById("tasksKeys");

        // bind
        var key3 = document.createXULElement("key");
        key3.setAttribute("id", "key_dict_toggle");
        key3.setAttribute("key", "y");
        key3.setAttribute('modifiers', 'alt');
        key3.setAttribute("oncommand", '(' + onCommand.toString() + ')()');
        keyset.appendChild(key3);

      } catch (e) {
        Components.utils.reportError(e);
      };
    }, 5000);
  }

function onCommand() {
      var lang = document.documentElement.getAttribute("lang");
      if (lang == "en-US") {
        ComposeChangeLanguage("de-DE");
      } else if (lang == "de-DE") {
        ComposeChangeLanguage("en-US");
      };
};
})();

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

Post Posted November 3rd, 2021, 2:32 pm

@bege

I got the `toggle between two languages` function in the other post to work correctly using the developer toolbox console in Thunderbird 91.

Can you run a simple alert using the userChrome.js script?

Code: Select all
- key3.setAttribute("oncommand", '(' + onCommand.toString() + ')()');
+ key3.setAttribute("oncommand", "alert('test')");

Do the other key tweaks, e.g. key1 and key2, work correctly using the userChrome.js script?

Try the following code using the tbkeys addon.

Code: Select all
(function () {
  var lang = window.document.documentElement.getAttribute("lang");
  if (lang == "en-US") {
    window.ComposeChangeLanguage("de-DE");
  } else if (lang == "de-DE") {
    window.ComposeChangeLanguage("en-US");
  }
})();

Troubleshooting for tbkeys: viewtopic.php?p=14872763#p14872763
Last edited by morat on November 7th, 2021, 6:14 am, edited 1 time in total.

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

Post Posted November 5th, 2021, 5:14 am

@bege

I got a simple alert working in Thunderbird 91.

Code: Select all
/* Thunderbird userChrome.js */

// Thunderbird 68 uses .xul pages.
// Thunderbird 78 uses .xhtml pages.
// Thunderbird 91 uses .xhtml pages.

(function () {
  if (location == "chrome://messenger/content/messengercompose/messengercompose.xul" ||
      location == "chrome://messenger/content/messengercompose/messengercompose.xhtml") {
    try {
      var keyset = document.getElementById("tasksKeys");
      var key = document.createXULElement("key");
      key.setAttribute("id", "__unique_identifier_example");
   // key.setAttribute("key", "A"); // A
   // key.setAttribute("modifiers", "control,shift"); // Ctrl+Shift
   // key.setAttribute("modifiers", "alt"); // Alt
      key.setAttribute("keycode", "VK_F2"); // F2
   // key.setAttribute("command", "cmd_print");
      key.setAttribute("oncommand", "alert('test')");
      keyset.appendChild(key);
    } catch (e) {
      Components.utils.reportError(e); // [check] Show Content Messages
    }
  }
})();

userChromeJS by jikamens (compatible with TB 68 and TB 78 and TB 91)
http://addons.thunderbird.net/thunderbird/addon/986610

Instructions:

* install userChromeJS extension
* close email client
* create or edit the userChrome.js file in chrome folder
* open email client

bege
 
Posts: 144
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted November 8th, 2021, 11:47 am

morat wrote:@bege

I got the `toggle between two languages` function in the other post to work correctly using the developer toolbox console in Thunderbird 91.

Can you run a simple alert using the userChrome.js script?

Code: Select all
- key3.setAttribute("oncommand", '(' + onCommand.toString() + ')()');
+ key3.setAttribute("oncommand", "alert('test')");

Do the other key tweaks, e.g. key1 and key2, work correctly using the userChrome.js script?

Try the following code using the tbkeys addon.

Code: Select all
(function () {
  var lang = window.document.documentElement.getAttribute("lang");
  if (lang == "en-US") {
    window.ComposeChangeLanguage("de-DE");
  } else if (lang == "de-DE") {
    window.ComposeChangeLanguage("en-US");
  }
})();

Troubleshooting for tbkeys: viewtopic.php?p=14872763#p14872763


Thank you very much @morat.

Other scripts, also a key binding script, work.
Maybe something has changed in the key sets of TB 91 for the compose window.
The code you suggested works with tbkeys in the compose window section with slight changes (quotation marks and line breaks): =D>
Code: Select all
"alt+y": "(function () { var lang = window.document.documentElement.getAttribute('lang'); if (lang == 'en-US') { window.ComposeChangeLanguage('de-DE'); } else if (lang == 'de-DE') { window.ComposeChangeLanguage('en-US'); }})();"

bege
 
Posts: 144
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted November 8th, 2021, 11:24 pm

I found this code in the add-on "Phoenity Buttons" to open the settings of TB and adapted it for tbkeys:

Code: Select all
"alt+x": "(function () {window.openDialog('chrome://global/content/aboutconfig/aboutconfig.html','','width=1300,height=700');})();"

What must I change to have it not open a new window but a tab in TB as the normal TB command does?

And why is the path different from the one in omni.ja? There it is
Code: Select all
 \chrome\toolkit\content\global\aboutconfig\aboutconfig.html
- the sequence of the folders content and global is twisted, nevertheless the above code works.


Edit:
Ah, I got it with the help of the German speaking Thunderbird forum:
Code: Select all
"alt+x": "(function () {var tabmail = window.document.getElementById('tabmail'); tabmail.openTab('contentTab', { url: 'about:config' });})();"

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

Post Posted November 9th, 2021, 6:09 am

@bege

There is likely a conflict between the userChrome.js key element shortcut and an event listener shortcut. It's difficult to unbind an event listener shortcut so it's best to use the tbkeys addon.

...

I normally figure out the chrome url or about url using the source.

omni.ja path -> chrome/toolkit/content/global/certviewer/certviewer.html
chrome url -> chrome://global/content/certviewer/certviewer.html
about url -> about:certificate

Reference
http://searchfox.org/comm-esr91/search?q=certviewer.html
http://searchfox.org/mozilla-esr91/search?q=certviewer.html (see nsAboutRedirector.cpp file)

I use the following addon to test urls.

BrowseInTab
http://addons.thunderbird.net/thunderbird/addon/987779

I use the following addon to open the config editor.

Config Button
http://addons.thunderbird.net/thunderbird/addon/987784

bege
 
Posts: 144
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted November 15th, 2021, 12:01 pm

morat wrote:@bege

I normally figure out the chrome url or about url using the source.

omni.ja path -> chrome/toolkit/content/global/certviewer/certviewer.html
chrome url -> chrome://global/content/certviewer/certviewer.html
about url -> about:certificate

Reference
http://searchfox.org/comm-esr91/search?q=certviewer.html
http://searchfox.org/mozilla-esr91/search?q=certviewer.html (see nsAboutRedirector.cpp file)

I use the following addon to test urls.

BrowseInTab
http://addons.thunderbird.net/thunderbird/addon/987779

I use the following addon to open the config editor.

Config Button
http://addons.thunderbird.net/thunderbird/addon/987784


@morat Thank you very much for these hints!

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 1 guest