MozillaZine

Assign hotkeys via omni.js

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

Post Posted November 7th, 2019, 4:19 am

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

Post Posted November 7th, 2019, 9:08 am

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

Similar thread: viewtopic.php?f=38&t=3056091

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

Post Posted November 7th, 2019, 1:36 pm

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

Post Posted November 7th, 2019, 1:40 pm

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

Post Posted November 7th, 2019, 2:32 pm


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

Post Posted November 10th, 2019, 5:31 am



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

Post Posted November 10th, 2019, 9:34 am

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

Post Posted November 10th, 2019, 3:39 pm

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

Return to Firefox Support


Who is online

Users browsing this forum: Bing [Bot] and 10 guests