MozillaZine


keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted April 19th, 2021, 3:58 pm

Hi!

How can I disable alt+[starting character] focusing the menu items on the menu bar? It's a garbage feature, the removes hotkey possibilities essentially randomly. (Based on what characters the menu names start with in your particular locale)

Even XUL addons like keyconfig can't override this apparently.

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

Post Posted April 19th, 2021, 5:54 pm

@avada

You can set ui.key.menuAccessKey to 0 in about:config to disable them.

More info: viewtopic.php?f=38&t=2169503

Also,

Code: Select all
document.getElementById("helpMenu").removeAttribute("accesskey");

Code: Select all
(function () {
  var menus = document.getElementById("main-menubar").children;
  for (var i = 0; i < menus.length; i++) {
    menus[i].removeAttribute("accesskey");
  }
})();

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted April 20th, 2021, 1:30 am

morat wrote:You can set ui.key.menuAccessKey to 0 in about:config to disable them.


Thanks. I assumed I could use -1 ui.key.* keys, one of them was even set to -1.
morat wrote:Also,

Code: Select all
document.getElementById("helpMenu").removeAttribute("accesskey");


Code: Select all
(function () {
var menus = document.getElementById("main-menubar").children;
for (var i = 0; i < menus.length; i++) {
menus[i].removeAttribute("accesskey");
}
})();


I guess this should go into an uc.js file?

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

Post Posted April 20th, 2021, 8:35 am

@avada

Put the code snippet with your initialization code.

e.g. mozilla.cfg or userChrome.js or whatever

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted May 14th, 2021, 10:44 am

Hi!
I have these as keys to open the two variants of quick findbar:
Code: Select all
gFindBar.startFind(gFindBar.FIND_TYPEAHEAD);


Code: Select all
gFindBar.startFind(gFindBar.FIND_LINKS);


They worked find in the past, but now they can only open the quick findbar, if the findbar was opened before manually for that tab. So not really useful like this.

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

Post Posted May 15th, 2021, 3:50 am

@avada

Try this:

Code: Select all
if (gFindBarInitialized) {
  alert("findbar initialized");
  gFindBar.startFind(gFindBar.FIND_TYPEAHEAD);
} else {
  alert("findbar not initialized");
  gFindBarPromise.then(function (fb) {
    fb.startFind(fb.FIND_TYPEAHEAD);
  });
}

Reference
http://searchfox.org/mozilla-release/search?q=gLazyFindCommand

FYI:

These are equivalent...

Code: Select all
gFindBarPromise.then(function (fb) {
  fb.startFind(fb.FIND_TYPEAHEAD);
});

Code: Select all
(async function () {
  var fb = await gFindBarPromise;
  fb.startFind(fb.FIND_TYPEAHEAD);
})();

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted May 16th, 2021, 7:43 am

morat wrote:@avada

Try this:

Code: Select all
if (gFindBarInitialized) {
  alert("findbar initialized");
  gFindBar.startFind(gFindBar.FIND_TYPEAHEAD);
} else {
  alert("findbar not initialized");
  gFindBarPromise.then(function (fb) {
    fb.startFind(fb.FIND_TYPEAHEAD);
  });
}

Reference
http://searchfox.org/mozilla-release/search?q=gLazyFindCommand

FYI:

These are equivalent...

Code: Select all
gFindBarPromise.then(function (fb) {
  fb.startFind(fb.FIND_TYPEAHEAD);
});

Code: Select all
(async function () {
  var fb = await gFindBarPromise;
  fb.startFind(fb.FIND_TYPEAHEAD);
})();

Thanks, it works.

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted June 13th, 2021, 6:54 am

@morat
Hi!
A good while ago got this code from you to hide the UI, reversibly via a hotkey:
Code: Select all
    var css = [];
    css.push("#TabsToolbar { visibility: collapse !important; }");
    //css.push("#navigator-toolbox {visibility: collapse;}");
    //css.push("browser {margin-right: -14px; margin-bottom: -14px;}");
    //css.push("#toolbar-menubar {visibility: collapse;}");
    // css.push("...");
    // css.push("...");
    // css.push("...");
    // css.push("...");
    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);
    }


Which still works fine. I only use it for the tab bar now. What I want to ask is: Can it be changed to be applied by default and be shown via hotkey? I guess not with keyconfig, but maybe the code can be moved to a Custombuttons button.

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

Post Posted June 13th, 2021, 8:46 am

@avada

Run the code in a custom buttons init tab. Run the same code using a keyconfig hotkey.

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted June 21st, 2021, 11:50 am

morat wrote:@avada

Run the code in a custom buttons init tab. Run the same code using a keyconfig hotkey.

I had that thought as well. But it's not reliable. I'm quite sure it runs twice if I have two windows in the session. So it remains visible.

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

Post Posted June 21st, 2021, 7:56 pm

@avada

Try something like:

* <profile folder>\user.js

Code: Select all
user_pref("extensions.custombuttons.css.initialized", false);

About user.js
http://kb.mozillazine.org/User.js_file

* a custom buttons init tab

Code: Select all
var pref = "extensions.custombuttons.css.initialized";
if (Services.prefs.getBoolPref(pref) == false) {
  var css = "#menubar-items { background-color: orange !important; }";
  var ios = Components.classes["@mozilla.org/network/io-service;1"].
    getService(Components.interfaces.nsIIOService);
  var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
  var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
    getService(Components.interfaces.nsIStyleSheetService);
  var type = sss.USER_SHEET;
  if (sss.sheetRegistered(uri, type)) sss.unregisterSheet(uri, type);
  else sss.loadAndRegisterSheet(uri, type);
  Services.prefs.setBoolPref(pref, true);
}

* a keyconfig hotkey

Code: Select all
var css = "#menubar-items { background-color: orange !important; }";
var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
  getService(Components.interfaces.nsIStyleSheetService);
var type = sss.USER_SHEET;
if (sss.sheetRegistered(uri, type)) sss.unregisterSheet(uri, type);
else sss.loadAndRegisterSheet(uri, type);

P.S.

Here is how to run a code snippet once per session in each window.

Run once per session
http://odyseus.github.io/CustomButtons/CBDocumentation.html#nav_getting_started-11

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted June 23rd, 2021, 6:51 am

@morat
Thanks!

godzfire
 
Posts: 126
Joined: September 13th, 2009, 1:12 pm

Post Posted July 1st, 2021, 5:06 pm

I want to map View -> Message Source to something else. It's currently Command+U. I'd like to change it to just the u key, like r is reply and f is forward. How can I do that?

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

Post Posted July 1st, 2021, 6:03 pm

@godzfire

Are you using the tbkeys or tbkey-lite addon?

The command to view message source...

Code: Select all
window.goDoCommand('cmd_viewPageSource');

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();".

Tips: viewtopic.php?p=14872763#p14872763

godzfire
 
Posts: 126
Joined: September 13th, 2009, 1:12 pm

Post Posted July 1st, 2021, 6:51 pm

That works, thanks!

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 1 guest