MozillaZine


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

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

Post Posted October 22nd, 2019, 10:25 am

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: 4852
Joined: February 3rd, 2009, 6:29 pm

Post Posted October 22nd, 2019, 2:58 pm

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.php?p=14845838#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

Post Posted October 23rd, 2019, 12:19 am

morat
Now it works, thank you!

PS Apparently, not signed yet in 68esr.

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

Post Posted October 23rd, 2019, 6:10 am

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

Post Posted August 29th, 2020, 3:37 am

So, can one edit omni.ja in the 78esr?

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

Post Posted August 29th, 2020, 9:51 am

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

Post Posted September 1st, 2020, 3:50 am

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: 4852
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 1st, 2020, 7:28 am

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/search?q=mainKeyset
http://searchfox.org/mozilla-release/search?q=search-find-again-shortcut-alt
http://searchfox.org/mozilla-release/source/browser/config/version.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.php?p=14845838#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

Post Posted September 1st, 2020, 7:45 am

morat wrote:I got the hack working in the browser console in Firefox 80.

awesome, thanks!

dickvl

User avatar
 
Posts: 53552
Joined: July 18th, 2005, 3:25 am

Post Posted September 1st, 2020, 7:54 pm

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

Post Posted September 19th, 2020, 8:36 am

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

Post Posted October 14th, 2021, 10:03 am

I can confirm that editing browser.xhtml and repacking omni.ja works on ESR 91.

therube

User avatar
 
Posts: 20903
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted October 14th, 2021, 11:26 am

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

Return to Firefox Support


Who is online

Users browsing this forum: No registered users and 5 guests