Assign hotkeys via omni.js

User Help for Mozilla Firefox
Post Reply
userofff
Posts: 4
Joined: November 7th, 2019, 3:59 am

Assign hotkeys via omni.js

Post by userofff »

Early on version 69 this way is work, but in 70 is broken :(

Code: Select all

cd /usr/lib/firefox/browser
cp omni.ja omni.ja.orig
mkdir x; cd x
unzip ../omni.ja

mcedit ./chrome/browser/content/browser/browser.xhtml
Add before <key id="focusURLBar" key="&openCmd.commandkey;" next strings:

Code: Select all

	<key id="key_newNavigatorTab" keycode="VK_F4"  command="cmd_newNavigatorTabNoEvent" reserved="true"/>
	<key id="gregzilla_prevTab" keycode="VK_F1" command="Browser:PrevTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);" reserved="true"/>
	<key id="gregzilla_nextTab" keycode="VK_F2" command="Browser:NextTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);"  reserved="true"/>
	<key id="gregzilla_closeTab" key="x" command="cmd_close" modifiers="alt" reserved="true"/>
And in finnaly pack back omni.ja

Code: Select all

zip -qr0XD ../omni.ja *
Firefox start, but all UI is broken :(

How fix it?
morat
Posts: 6421
Joined: February 3rd, 2009, 6:29 pm

Re: Assign hotkeys via omni.js

Post by morat »

Isn't the omni.ja file signed now? I thought you couldn't hack it anymore.

Similar thread: http://forums.mozillazine.org/viewtopic ... &t=3056091
userofff
Posts: 4
Joined: November 7th, 2019, 3:59 am

Re: Assign hotkeys via omni.js

Post by userofff »

Try to this code:
<key id="key_newNavigatorTab" keycode="VK_F4" command="cmd_newNavigatorTabNoEvent" />
<key id="gregzilla_prevTab" keycode="VK_F1" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);" />
<key id="gregzilla_nextTab" keycode="VK_F2" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);" />
<key id="gregzilla_closeTab" key="x" command="cmd_close" modifiers="alt" />
But ff is not starting :(

OS Manjaro GNOME
userofff
Posts: 4
Joined: November 7th, 2019, 3:59 am

Re: Assign hotkeys via omni.js

Post by userofff »

morat wrote:Isn't the omni.ja file signed now? I thought you couldn't hack it anymore.
Maybe there is another method to assign hotkeys?
morat
Posts: 6421
Joined: February 3rd, 2009, 6:29 pm

Re: Assign hotkeys via omni.js

Post by morat »

userofff
Posts: 4
Joined: November 7th, 2019, 3:59 am

Re: Assign hotkeys via omni.js

Post by userofff »

Can you help me figure out how to make keyboard shortcuts through AutoConfig? Ideally for Linux and so that updates do not break my custom settings.
morat
Posts: 6421
Joined: February 3rd, 2009, 6:29 pm

Re: Assign hotkeys via omni.js

Post by morat »

Can you get the following alert example working? I don't know how to install the files on Linux.

* autoconfig.js (in same folder with channel-prefs.js file)

Code: Select all

// autoconfig.js file needs to start with a comment line

pref("general.config.sandbox_enabled", false);
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);
* mozilla.cfg (in same folder with platform.ini file)

Code: Select all

// mozilla.cfg file needs to start with a comment line

Components.utils.import("resource://gre/modules/Services.jsm");

Services.obs.addObserver(function (aSubject, aTopic, aData) {
  var chromeWindow = aSubject;
  chromeWindow.setTimeout(function () {
    try {
      Services.console.logStringMessage("test mozilla.cfg");
      Services.prompt.alert(chromeWindow, "example", "test mozilla.cfg");
    } catch (e) {
      Components.utils.reportError(e);
    };
  }, 3000);
}, "browser-delayed-startup-finished", false);
nsIPromptService alert example
http://developer.mozilla.org/docs/Mozil ... rt_example
morat
Posts: 6421
Joined: February 3rd, 2009, 6:29 pm

Re: Assign hotkeys via omni.js

Post by morat »

The following code snippet works for me using the browser console.

Code: Select all

(function () {

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

  var key = document.createXULElement("key");
  key.setAttribute("id", "gregzilla_key_prevTab");
  key.setAttribute("keycode", "VK_F1");
  key.setAttribute("oncommand", "gBrowser.tabContainer.advanceSelectedTab(-1, true);");
  keyset.appendChild(key);

  var key = document.createXULElement("key");
  key.setAttribute("id", "gregzilla_key_nextTab");
  key.setAttribute("keycode", "VK_F2");
  key.setAttribute("oncommand", "gBrowser.tabContainer.advanceSelectedTab(1, true);");
  keyset.appendChild(key);

  var key = document.createXULElement("key");
  key.setAttribute("id", "gregzilla_key_newNavigatorTabNoEvent");
  key.setAttribute("keycode", "VK_F4");
  key.setAttribute("oncommand", "BrowserOpenTab();");
  keyset.appendChild(key);

  var key = document.createXULElement("key");
  key.setAttribute("id", "gregzilla_key_close");
  key.setAttribute("key", "x");
  key.setAttribute("modifiers", "alt");
  key.setAttribute("oncommand", "BrowserCloseTabOrWindow(event);");
  keyset.appendChild(key);

})();
Browser Console command line
http://developer.mozilla.org/docs/Tools ... mmand_line

Here is the mozilla.cfg file.

Code: Select all

// mozilla.cfg file needs to start with a comment line

Components.utils.import("resource://gre/modules/Services.jsm");

Services.obs.addObserver(function (aSubject, aTopic, aData) {
  var chromeWindow = aSubject;
  chromeWindow.setTimeout(function () {
    try {
      var keyset = chromeWindow.document.getElementById("mainKeyset");
      var key = chromeWindow.document.createXULElement("key");
      key.setAttribute("id", "gregzilla_key_prevTab");
      key.setAttribute("keycode", "VK_F1");
      key.setAttribute("oncommand", "gBrowser.tabContainer.advanceSelectedTab(-1, true);");
      keyset.appendChild(key);
      var key = chromeWindow.document.createXULElement("key");
      key.setAttribute("id", "gregzilla_key_nextTab");
      key.setAttribute("keycode", "VK_F2");
      key.setAttribute("oncommand", "gBrowser.tabContainer.advanceSelectedTab(1, true);");
      keyset.appendChild(key);
      var key = chromeWindow.document.createXULElement("key");
      key.setAttribute("id", "gregzilla_key_newNavigatorTabNoEvent");
      key.setAttribute("keycode", "VK_F4");
      key.setAttribute("oncommand", "BrowserOpenTab();");
      keyset.appendChild(key);
      var key = chromeWindow.document.createXULElement("key");
      key.setAttribute("id", "gregzilla_key_close");
      key.setAttribute("key", "x");
      key.setAttribute("modifiers", "alt");
      key.setAttribute("oncommand", "BrowserCloseTabOrWindow(event);");
      keyset.appendChild(key);
    } catch (e) {
      Components.utils.reportError(e);
    };
  }, 1000);
}, "browser-delayed-startup-finished", false);
Reference
view-source:chrome://browser/content/browser.xhtml
view-source:chrome://browser/locale/browser.dtd

Firefox 70.0.1
Windows 7 SP1 32-bit
Post Reply