1
0

works for me

This commit is contained in:
Mute 2024-11-22 05:00:40 +00:00
parent bf2a800c02
commit b47f203364
5 changed files with 161 additions and 2 deletions

0
.gitignore vendored Normal file
View File

View File

@ -1,3 +1,39 @@
# firefox-keyboard-shortcuts # Firefox keyboard shortcuts
Had enough of accidentally hitting a wrong key? Wondering if you can do
something about it? Years of suffering, yet no real progress? Read on.
It's a surprisingly involved process to edit built-in shortcuts (like Ctrl-R) in Firefix, the browser that Hackmaster recommends. ## Quick start
1. Locate your firefox installation folder. On Windows check `C:\Program Files\Mozilla Firefox`.
You need the directory that contains the firefox executable.
2. Navigate to `defaults/pref` subfolder, it will probably contain a `channel-prefs.js` file.
3. Copy the `defaults/pref/autoconfig.js` file there. You will likely have to do this as superuser.
4. Copy the main `autoconfig.js` file (a different one) to the main folder, next to the firefox itself.
5. Restart firefox and enjoy.
## Enjoy what, exactly?
The shipped config completely disables a number of built-in shortcuts. This is the functionality we
find most useful ourselves, if you need something else you'll have to edit the `autoconfig.js` to
suit your own purpose.
## Anything else?
For debugging purposes it sets a superfluous preference that you can find in your `about:config` if
you search for `hackmaster`. If there's nothing, the file didn't load.
## What if I want some of shortcuts back?
Edit the file and delete the ids you want to keep.
## What if I want to disable more shortcuts?
Check out provided `keys.html`, locate the ids you want to disable and add them to the array.
## What if I want to edit a shortcut?
You are in for quite a ride. The shipped config removes the attributes from XML nodes, you will have
to change their values instead. Theoretically, it should work, but please don't ask us for advice or
guidance.
## Grumpy Mute wishes to add
Another sea of bullshit navigated.
Don't you like getting your feet dirty in the crossover between moldy legacy
and undocumented changes? No API reference, shitty DX, unjustifiable complexity,
everything, everywhere, all at once. Delicious.

36
autoconfig.js Normal file
View File

@ -0,0 +1,36 @@
// based on https://support.mozilla.org/en-US/questions/1378404#answer-1510431
try {
const hotkeys_to_disable = [
'openFileKb',
'key_savePage',
'printKb',
'key_close',
'key_closeWindow',
'key_toggleMute',
'key_reload',
'key_reload_skip_cache',
'key_quitApplication',
];
new (class {
attributes_to_remove = ['command', 'key', 'modifiers', 'oncommand', 'data-l10n-id'];
services = globalThis.Services || ChromeUtils.import('resource://gre/modules/Services.jsm').Services;
re_href = /^(chrome:(?!\/\/(global\/content\/commonDialog|browser\/content\/webext-panels)\.x?html)|about:(?!blank))/i; // whatever, I'm not refactoring this
constructor() { if (!this.services.appinfo.inSafeMode) this.services.obs.addObserver(this, 'chrome-document-global-created', false); }
observe(w) { w.addEventListener('DOMContentLoaded', this, {once: true}); } // Tempting to check location here, but we don't have it yet
handleEvent(e) {
const D = e.originalTarget, W = D.defaultView, L = W.location;
if (!L || !this.re_href.test(L.href)) return;
if (!W._gBrowser && !W.Tabbrowser) return; // https://bugzilla.mozilla.org/show_bug.cgi?id=1930654
//displayError('debug', '[ ' + L.href + ' | ' + W.document.getElementById('key_reload') + ' ]');
hotkeys_to_disable.forEach(n => {
const k = W.document.getElementById(n);
//displayError('debug', '[ ' + n + ' | ' + k + ' ]');
if (k !== null) this.attributes_to_remove.forEach(a => k.removeAttribute(a));
});
}
})()
} catch (e) {
displayError('hackmaster', e);
}
lockPref("hackmaster.autoconfig.loaded", "a miracle, really");

View File

@ -0,0 +1,7 @@
// based on https://support.mozilla.org/en-US/questions/1378404#answer-1510431
// apparently, this is a strange subset of JS
// semicolons are required
// basically, do not edit except for the filename below
pref('general.config.filename', 'autoconfig.js');
pref('general.config.obscure_value', 0);
pref('general.config.sandbox_enabled', false);

80
keys.html Normal file
View File

@ -0,0 +1,80 @@
<!-- Dumped from a vanilla Firefox ESR, may change with time -->
<key id="key_newNavigator" data-l10n-id="window-new-shortcut" command="cmd_newNavigator" modifiers="accel" reserved="true" key="N" />
<key id="key_newNavigatorTab" data-l10n-id="tab-new-shortcut" modifiers="accel" command="cmd_newNavigatorTabNoEvent" reserved="true" key="T" />
<key id="focusURLBar" data-l10n-id="location-open-shortcut" command="Browser:OpenLocation" modifiers="accel" key="L" />
<key id="focusURLBar2" data-l10n-id="location-open-shortcut-alt" command="Browser:OpenLocation" modifiers="alt" key="D" />
<key id="key_search" data-l10n-id="search-focus-shortcut" command="Tools:Search" modifiers="accel" key="K" />
<key id="key_search2" data-l10n-id="search-focus-shortcut-alt" modifiers="accel" command="Tools:Search" key="E" />
<key id="key_openDownloads" data-l10n-id="downloads-shortcut" modifiers="accel" command="Tools:Downloads" key="J" />
<key id="key_openAddons" data-l10n-id="addons-shortcut" command="Tools:Addons" modifiers="accel,shift" key="A" />
<key id="openFileKb" data-l10n-id="file-open-shortcut" command="Browser:OpenFile" modifiers="accel" key="O" />
<key id="key_savePage" data-l10n-id="save-page-shortcut" command="Browser:SavePage" modifiers="accel" key="S" />
<key id="printKb" data-l10n-id="print-shortcut" command="cmd_print" modifiers="accel" key="P" />
<key id="key_close" data-l10n-id="close-shortcut" command="cmd_close" modifiers="accel" reserved="true" key="W" />
<key id="key_closeWindow" data-l10n-id="close-shortcut" command="cmd_closeWindow" modifiers="accel,shift" reserved="true" key="W" />
<key id="key_toggleMute" data-l10n-id="mute-toggle-shortcut" command="cmd_toggleMute" modifiers="control" key="M" />
<key id="key_undo" data-l10n-id="text-action-undo-shortcut" modifiers="accel" internal="true" key="Z" />
<key id="key_redo" data-l10n-id="text-action-redo-shortcut" modifiers="accel" internal="true" key="Y" />
<key id="key_cut" data-l10n-id="text-action-cut-shortcut" modifiers="accel" internal="true" key="X" />
<key id="key_copy" data-l10n-id="text-action-copy-shortcut" modifiers="accel" internal="true" key="C" />
<key id="key_paste" data-l10n-id="text-action-paste-shortcut" modifiers="accel" internal="true" key="V" />
<key id="key_delete" keycode="VK_DELETE" command="cmd_delete" reserved="false" />
<key id="key_selectAll" data-l10n-id="text-action-select-all-shortcut" modifiers="accel" internal="true" key="A" />
<key keycode="VK_BACK" command="cmd_handleBackspace" reserved="false" />
<key keycode="VK_BACK" command="cmd_handleShiftBackspace" modifiers="shift" reserved="false" />
<key id="goBackKb" keycode="VK_LEFT" command="Browser:Back" modifiers="alt" />
<key id="goForwardKb" keycode="VK_RIGHT" command="Browser:Forward" modifiers="alt" />
<key id="goHome" keycode="VK_HOME" oncommand="BrowserCommands.home();" modifiers="alt" />
<key keycode="VK_F5" command="Browser:Reload" />
<key id="showAllHistoryKb" data-l10n-id="history-show-all-shortcut" command="Browser:ShowAllHistory" modifiers="accel,shift" key="H" />
<key keycode="VK_F5" command="Browser:ReloadSkipCache" modifiers="accel" />
<key id="key_enterFullScreen" keycode="VK_F11" command="View:FullScreen" />
<key id="key_exitFullScreen" keycode="VK_F11" command="View:FullScreen" reserved="true" disabled="true" />
<key id="key_toggleReaderMode" command="View:ReaderView" data-l10n-id="reader-mode-toggle-shortcut-windows" disabled="true" keycode="VK_F9" />
<key id="key_togglePictureInPicture" data-l10n-id="picture-in-picture-toggle-shortcut" command="View:PictureInPicture" modifiers="accel,shift" key="]" />
<key data-l10n-id="picture-in-picture-toggle-shortcut-alt" command="View:PictureInPicture" modifiers="accel,shift" key="}" />
<key data-l10n-id="nav-reload-shortcut" command="Browser:Reload" modifiers="accel" id="key_reload" key="R" />
<key data-l10n-id="nav-reload-shortcut" command="Browser:ReloadSkipCache" modifiers="accel,shift" id="key_reload_skip_cache" key="R" />
<key id="key_aboutProcesses" command="View:AboutProcesses" keycode="VK_ESCAPE" modifiers="shift" />
<key id="key_viewSource" data-l10n-id="page-source-shortcut" command="View:PageSource" modifiers="accel" key="U" />
<key id="key_viewInfo" data-l10n-id="page-info-shortcut" command="View:PageInfo" modifiers="accel" key="I" />
<key id="key_find" data-l10n-id="find-shortcut" command="cmd_find" modifiers="accel" key="F" />
<key id="key_findAgain" data-l10n-id="search-find-again-shortcut" command="cmd_findAgain" modifiers="accel" key="G" />
<key id="key_findPrevious" data-l10n-id="search-find-again-shortcut" command="cmd_findPrevious" modifiers="accel,shift" key="G" />
<key data-l10n-id="search-find-again-shortcut-alt" command="cmd_findAgain" keycode="VK_F3" />
<key data-l10n-id="search-find-again-shortcut-alt" command="cmd_findPrevious" modifiers="shift" keycode="VK_F3" />
<key id="addBookmarkAsKb" data-l10n-id="bookmark-this-page-shortcut" command="Browser:AddBookmarkAs" modifiers="accel" key="D" />
<key id="bookmarkAllTabsKb" data-l10n-id="bookmark-this-page-shortcut" oncommand="PlacesCommandHook.bookmarkTabs();" modifiers="accel,shift" key="D" />
<key id="manBookmarkKb" data-l10n-id="bookmark-show-library-shortcut" command="Browser:ShowAllBookmarks" modifiers="accel,shift" key="O" />
<key id="viewBookmarksSidebarKb" data-l10n-id="bookmark-show-sidebar-shortcut" modifiers="accel" oncommand="SidebarController.toggle('viewBookmarksSidebar');" key="B" />
<key id="viewBookmarksToolbarKb" data-l10n-id="bookmark-show-toolbar-shortcut" oncommand="BookmarkingUI.toggleBookmarksToolbar('shortcut');" modifiers="accel,shift" key="B" />
<key id="key_stop" keycode="VK_ESCAPE" command="Browser:Stop" />
<key id="key_gotoHistory" data-l10n-id="history-sidebar-shortcut" modifiers="accel" oncommand="SidebarController.toggle('viewHistorySidebar');" key="H" />
<key id="key_fullZoomReduce" data-l10n-id="full-zoom-reduce-shortcut" command="cmd_fullZoomReduce" modifiers="accel" key="-" />
<key data-l10n-id="full-zoom-reduce-shortcut-alt-a" command="cmd_fullZoomReduce" modifiers="accel" key="_" />
<key data-l10n-id="full-zoom-reduce-shortcut-alt-b" command="cmd_fullZoomReduce" modifiers="accel" key="" />
<key id="key_fullZoomEnlarge" data-l10n-id="full-zoom-enlarge-shortcut" command="cmd_fullZoomEnlarge" modifiers="accel" key="+" />
<key data-l10n-id="full-zoom-enlarge-shortcut-alt" command="cmd_fullZoomEnlarge" modifiers="accel" key="=" />
<key data-l10n-id="full-zoom-enlarge-shortcut-alt2" command="cmd_fullZoomEnlarge" modifiers="accel" key="" />
<key id="key_fullZoomReset" data-l10n-id="full-zoom-reset-shortcut" command="cmd_fullZoomReset" modifiers="accel" key="0" />
<key data-l10n-id="full-zoom-reset-shortcut-alt" command="cmd_fullZoomReset" modifiers="accel" key="" />
<key id="key_showAllTabs" keycode="VK_TAB" modifiers="control,shift" />
<key id="key_switchTextDirection" data-l10n-id="bidi-switch-direction-shortcut" command="cmd_switchTextDirection" modifiers="accel,shift" key="X" />
<key id="key_privatebrowsing" command="Tools:PrivateBrowsing" data-l10n-id="private-browsing-shortcut" modifiers="accel,shift" reserved="true" key="P" />
<key id="key_screenshot" data-l10n-id="screenshot-shortcut" command="Browser:Screenshot" modifiers="accel,shift" key="S" />
<key id="key_sanitize" command="Tools:Sanitize" keycode="VK_DELETE" modifiers="accel,shift" />
<key id="key_quitApplication" data-l10n-id="quit-app-shortcut" modifiers="accel,shift" command="cmd_quitApplication" reserved="true" key="Q" />
<key id="key_restoreLastClosedTabOrWindowOrSession" command="History:RestoreLastClosedTabOrWindowOrSession" data-l10n-id="tab-new-shortcut" modifiers="accel,shift" key="T" />
<key id="key_undoCloseWindow" command="History:UndoCloseWindow" data-l10n-id="window-new-shortcut" modifiers="accel,shift" key="N" />
<key id="key_selectTab1" oncommand="gBrowser.selectTabAtIndex(0, event);" key="1" modifiers="accel" />
<key id="key_selectTab2" oncommand="gBrowser.selectTabAtIndex(1, event);" key="2" modifiers="accel" />
<key id="key_selectTab3" oncommand="gBrowser.selectTabAtIndex(2, event);" key="3" modifiers="accel" />
<key id="key_selectTab4" oncommand="gBrowser.selectTabAtIndex(3, event);" key="4" modifiers="accel" />
<key id="key_selectTab5" oncommand="gBrowser.selectTabAtIndex(4, event);" key="5" modifiers="accel" />
<key id="key_selectTab6" oncommand="gBrowser.selectTabAtIndex(5, event);" key="6" modifiers="accel" />
<key id="key_selectTab7" oncommand="gBrowser.selectTabAtIndex(6, event);" key="7" modifiers="accel" />
<key id="key_selectTab8" oncommand="gBrowser.selectTabAtIndex(7, event);" key="8" modifiers="accel" />
<key id="key_selectLastTab" oncommand="gBrowser.selectTabAtIndex(-1, event);" key="9" modifiers="accel" />
<key id="key_wrCaptureCmd" key="#" modifiers="control" command="wrCaptureCmd" />
<key id="key_wrToggleCaptureSequenceCmd" key="^" modifiers="control" command="wrToggleCaptureSequenceCmd" />