keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
bege
Posts: 155
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

@morat
Thank you very much! This is perfect once again.

This is my code now to toggle messages read and to mark folders read with space key when focused.

Code: Select all

"space": "(function () {var tabmail = window.document.getElementById('tabmail'); if (tabmail.currentTabInfo.mode.name == 'mail3PaneTab') { var win = tabmail.currentTabInfo.chromeBrowser.contentWindow; var doc = tabmail.currentTabInfo.chromeBrowser.contentDocument; if (win.folderTree && doc.getElementById('folderPane').contains(doc.activeElement)) { window.gTabmail.currentAbout3Pane.gFolder.markAllMessagesRead(window.msgWindow);} else {window.goDoCommand('cmd_toggleRead');}}})();"
avada
Posts: 1941
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

Hi!

Is there any way to make the urlbar results open in a new background tab without closing the results list? So I could conveniently open multiple urls from the urlbar without having to retype the search term.
Basically overriding how ctrl + enter/LMB works, I think. So the results wont close and urlbar content won't change when I press/click.

I've been searching for a solution since Stay-Open Menu broke, but so far it seems no-one made one. I'm surprised people don't miss a way to open multiple related urls.
morat
Posts: 6683
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@avada

Maybe you can hover on a urlbar result using the mouse, then press F1 key to open the url in a new background tab without closing the menu, but I don't know how to get the hovered urlbar result url.

Stay-Open Menu
http://addons.thunderbird.net/seamonkey/addon/986414

That addon is complicated. AFAICT, there isn't a simple userChrome.js hack to override the default behavior.

P.S.

I can output the urlbar result urls using the browser toolbox console tab, but not the hovered urlbar result url.

Code: Select all

setTimeout(function () {
  document.querySelectorAll("span.urlbarView-url").forEach(function (span) {
    console.log(span.textContent);
  });
  document.querySelectorAll("span.urlbarView-url:hover").forEach(function (span) {
    console.log("test");
    console.log(span.textContent);
  });
}, 5000);
More info
http://stackoverflow.com/a/58922672
avada
Posts: 1941
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

morat wrote: September 29th, 2024, 8:21 am @avada

Maybe you can hover on a urlbar result using the mouse, then press F1 key to open the url in a new background tab without closing the menu, but I don't know how to get the hovered urlbar result url.

Stay-Open Menu
http://addons.thunderbird.net/seamonkey/addon/986414

That addon is complicated. AFAICT, there isn't a simple userChrome.js hack to override the default behavior.
There was a 4.0b1 version that worked right until XUL addon removal. I don't know if it's simpler or not.

Whit is F1 supposed to do? With a clean profile it doesn't seem to do anything for me. (with my default profile it's used by Tree style tab)
morat wrote: September 29th, 2024, 8:21 am That addon is complicated. AFAICT, there isn't a simple userChrome.js hack to override the default behavior.
I was thinking/hoping if it's possible to read the hovered or selected item's URL then the relevant shortcut click or keypress could be hijacked and the url used to open a tab in the background. And not actually modifying the urlbar behavior.
morat
Posts: 6683
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

The F1 keyboard shortcut is just an example. Another keyboard shortcut could be used to execute the key binding.
avada
Posts: 1941
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

morat wrote: September 29th, 2024, 1:39 pm The F1 keyboard shortcut is just an example. Another keyboard shortcut could be used to execute the key binding.
Ah, I misunderstood.
morat wrote: September 29th, 2024, 8:21 am but I don't know how to get the hovered urlbar result url.
Is there no way to get the selected (via arrow keys) item's URL either?
morat
Posts: 6683
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@avada

I noticed the div#urlbarView-row-3 element has the selected="" attribute in the browser toolbox when I select the 3rd row with the arrow keys in the popup, so I searched for "selected" in the /urlbar/ source code.

Code: Select all

console.log(gURLBar.view.selectedElement.parentElement); // div#urlbarView-row-3 element
console.log(gURLBar.view.selectedElement);               // span#urlbarView-row-3-inner element
console.log(gURLBar.view.selectedResult);                // object with payload.url string
console.log(gURLBar.view.selectedRowIndex);              // 2
Try this:

Code: Select all

(function () {
  var url = gURLBar.view.selectedResult && gURLBar.view.selectedResult.payload.url;
  if (url) {
    gBrowser.addTab(url, {
      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
    });
  }
})();
Reference
http://searchfox.org/mozilla-release/se ... ath=urlbar
http://searchfox.org/mozilla-release/se ... ath=urlbar
avada
Posts: 1941
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

morat wrote: September 30th, 2024, 8:54 am @avada

I noticed the div#urlbarView-row-3 element has the selected="" attribute in the browser toolbox when I select the 3rd row with the arrow keys in the popup, so I searched for "selected" in the /urlbar/ source code.

Code: Select all

console.log(gURLBar.view.selectedElement.parentElement); // div#urlbarView-row-3 element
console.log(gURLBar.view.selectedElement);               // span#urlbarView-row-3-inner element
console.log(gURLBar.view.selectedResult);                // object with payload.url string
console.log(gURLBar.view.selectedRowIndex);              // 2
Try this:

Code: Select all

(function () {
  var url = gURLBar.view.selectedResult && gURLBar.view.selectedResult.payload.url;
  if (url) {
    gBrowser.addTab(url, {
      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
    });
  }
})();
Reference
http://searchfox.org/mozilla-release/se ... ath=urlbar
http://searchfox.org/mozilla-release/se ... ath=urlbar
Thanks! You meant in Keyconfig, right? It works.

Do you think it's possible to hijack the ctrl+enter (or alt enter) shortcut? Keyconfig seems to be unable to use any combination with 'enter' here, even if it's not used, such as ctrl+shift+alt+enter.

If not, I guess I'll need to figure out something that's convenient and somewhat logical.
morat
Posts: 6683
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@avada

You could hack the _whereToOpen function.

Code: Select all

gURLBar.view.input._whereToOpen = function (event) {
  return "tabshifted";
};
Try running the code snippet in the browser console, then use the enter key to open a selected urlbar result url in a new background tab.

See KeyEvent.DOM_VK_RETURN in UrlbarController.sys.mjs file.

See handleCommand and handleNavigation and _whereToOpen functions in UrlbarInput.sys.mjs file.

About _whereToOpen function:

"current" means current tab
"tab" means new foreground tab
"tabshifted" means new background tab

Reference
http://searchfox.org/mozilla-release/so ... er.sys.mjs
http://searchfox.org/mozilla-release/so ... ut.sys.mjs

It is too much trouble to hijack the event directly.

More info
http://developer.mozilla.org/docs/Web/A ... entDefault
http://developer.mozilla.org/docs/Web/A ... ropagation
http://developer.mozilla.org/docs/Web/A ... ropagation
avada
Posts: 1941
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

morat wrote: October 1st, 2024, 8:01 am @avada

You could hack the _whereToOpen function.

Code: Select all

gURLBar.view.input._whereToOpen = function (event) {
  return "tabshifted";
};
Try running the code snippet in the browser console, then use the enter key to open a selected urlbar result url in a new background tab.

See KeyEvent.DOM_VK_RETURN in UrlbarController.sys.mjs file.

See handleCommand and handleNavigation and _whereToOpen functions in UrlbarInput.sys.mjs file.

About _whereToOpen function:

"current" means current tab
"tab" means new foreground tab
"tabshifted" means new background tab

Reference
http://searchfox.org/mozilla-release/so ... er.sys.mjs
http://searchfox.org/mozilla-release/so ... ut.sys.mjs
Thanks. Though since the results close with this method, I'll stick with the custom hotkey via keyconfig.
Ah, okay. I was hoping that it's possible to override the hotkey so that the event doesn't even get registered.
Post Reply