Bind switching tabs (previous/next) to F2/F3

User Help for Mozilla Firefox
Post Reply
miracleboy
Posts: 40
Joined: September 18th, 2008, 3:05 am

Bind switching tabs (previous/next) to F2/F3

Post by miracleboy »

Tried editing chrome/browser/content/browser/browser.xul in browser/omni.ja archive:

@@ -304,8 +304,8 @@
<key id="key_find" key="&findOnCmd.commandkey;" command="cmd_find" modifiers="accel"/>
<key id="key_findAgain" key="&findAgainCmd.commandkey;" command="cmd_findAgain" modifiers="accel"/>
<key id="key_findPrevious" key="&findAgainCmd.commandkey;" command="cmd_findPrevious" modifiers="accel,shift"/>
- <key keycode="&findAgainCmd.commandkey2;" command="cmd_findAgain"/>
- <key keycode="&findAgainCmd.commandkey2;" command="cmd_findPrevious" modifiers="shift"/>
+ <key id="my_prevTab" key="VK_F2" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);" reserved="true"/>
+ <key id="my_nextTab" key="VK_F3" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);" reserved="true"/>

But can't make it work, both keys just move the tab backwards. Could somebody take a look?
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: Bind switching tabs (previous/next) to F2/F3

Post by morat »

I would do it like so...

Code: Select all

- <key keycode="&findAgainCmd.commandkey2;" command="cmd_findAgain"/>
+ <key keycode="VK_F3" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);"/>
+ <key keycode="VK_F2" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);"/>
Remember to clear the javascript cache by adding the -purgecaches flag to the executable commandline.

I never used the reserved attribute.

Reference
view-source:chrome://browser/content/browser.xhtml
view-source:chrome://browser/locale/browser.dtd

Similar reply
http://forums.mozillazine.org/viewtopic ... #p14845838

P.S.

Isn't the omni.ja file signed now? I thought you couldn't hack it anymore.
miracleboy
Posts: 40
Joined: September 18th, 2008, 3:05 am

Re: Bind switching tabs (previous/next) to F2/F3

Post by miracleboy »

morat
Now it works, thank you!

PS Apparently, not signed yet in 68esr.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: Bind switching tabs (previous/next) to F2/F3

Post by morat »

I tested...

The omni.ja files are not signed for Firefox Portable 68.2.0 esr build.
The omni.ja files are not signed for Firefox Portable 68.0.2 release build.
The omni.ja files are signed for Firefox Portable 69.0.3 release build.
The omni.ja files are signed for Firefox Portable 70.0 release build.

Command Prompt:

Code: Select all

rem testing with unzip by info-zip
unzip -l omni.ja | find "META-INF"
unzip -l browser\omni.ja | find "META-INF"
miracleboy
Posts: 40
Joined: September 18th, 2008, 3:05 am

Re: Bind switching tabs (previous/next) to F2/F3

Post by miracleboy »

So, can one edit omni.ja in the 78esr?
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: Bind switching tabs (previous/next) to F2/F3

Post by morat »

I tested...

The omni.ja files are signed for Firefox Portable 78.2.0 esr build.
The omni.ja files are signed for Firefox Portable 80.0 release build.

The omni.ja file is not signed for Thunderbird Portable 68.12.0 release build.
The omni.ja file is not signed for Thunderbird Portable 78.2.0 test build.

I know I can't hack a signed extension so I assume I can't hack a signed omni.ja file. That's the whole point of signing.
miracleboy
Posts: 40
Joined: September 18th, 2008, 3:05 am

Re: Bind switching tabs (previous/next) to F2/F3

Post by miracleboy »

morat
thank you for testing.

So is there any correct way to implement what I want?
Where is in the code that 'signature activated' flag? Maybe it's a 1 -byte patch in libxul.so?

BTW, ESR editions can disable addon signatures, so omni.ja signature check will then be disabled, too?
If it is, then it's all right. Nothing's changed for me. Gotta check, though.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: Bind switching tabs (previous/next) to F2/F3

Post by morat »

I got the hack working in the browser console in Firefox 80.

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

Code: Select all

(function () {
  var keyset = document.getElementById("mainKeyset");
  var key = document.querySelector('key[keycode="VK_F3"][command="cmd_findAgain"]');
  keyset.removeChild(key);
  var key = document.createXULElement("key");
  key.setAttribute("id", "key_hack_next_tab");
  key.setAttribute("keycode", "VK_F3");
  key.setAttribute("oncommand", "gBrowser.tabContainer.advanceSelectedTab(1, true);");
  keyset.prepend(key);
  var key = document.createXULElement("key");
  key.setAttribute("id", "key_hack_prev_tab");
  key.setAttribute("keycode", "VK_F2");
  key.setAttribute("oncommand", "gBrowser.tabContainer.advanceSelectedTab(-1, true);");
  keyset.prepend(key);
})();
Reference
http://searchfox.org/mozilla-release/se ... mainKeyset
http://searchfox.org/mozilla-release/se ... ortcut-alt
http://searchfox.org/mozilla-release/so ... ersion.txt

Maybe you could use the autoconfig.js and mozilla.cfg files to run the hack at startup.

More info
http://forums.mozillazine.org/viewtopic ... #p14845838

...

I think the Nightly and Developer Edition builds don't sign the omni.ja files. (not tested)
miracleboy
Posts: 40
Joined: September 18th, 2008, 3:05 am

Re: Bind switching tabs (previous/next) to F2/F3

Post by miracleboy »

morat wrote:I got the hack working in the browser console in Firefox 80.
awesome, thanks!
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: Bind switching tabs (previous/next) to F2/F3

Post by dickvl »

Note that you can easily check this in Firefox:
resource:///
resource://gre/

Nightly and DE show the META-INF folder.
miracleboy
Posts: 40
Joined: September 18th, 2008, 3:05 am

Re: Bind switching tabs (previous/next) to F2/F3

Post by miracleboy »

I can confirm that editing (now) browser.xhtml and repacking omni.ja works on ESR 78.
miracleboy
Posts: 40
Joined: September 18th, 2008, 3:05 am

Re: Bind switching tabs (previous/next) to F2/F3

Post by miracleboy »

I can confirm that editing browser.xhtml and repacking omni.ja works on ESR 91.
User avatar
therube
Posts: 21703
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Bind switching tabs (previous/next) to F2/F3

Post by therube »

As omni.ja has META-INF & META-INF has signatures for all the files in omni.ja, why does modifying omni.ja not invalid it?

And yes, I can confirm that mod'd instalDir/omni.ja (93.0, I changed greprefs.js) does work after mod.
(I have the mozilla-EMEfree release, though I don't think that should matter.)

And I suppose that your changes would need to be done again with every new FF release.

Could your changes be done through AutoConfig or policies.json?
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
Post Reply