Fin*_*inn 42 firefox firefox-extensions firefox-quantum
由于量子更新所有允许更改 Firefox 中的键绑定的附加组件似乎已停止工作/被支持。
有没有一种方法可以更改 Firefox Quantum 中的默认键绑定?
小智 18
有一种方法。这不是超级官方,但基本上你可以解压browser/omni.ja
,编辑键绑定chrome/browser/content/browser/browser.xul
,重新打包,删除启动缓存,它会工作。
或者,您可以编译您自己的 firefox,然后您不需要解压缩二进制文件,如果您认为解包和重新打包比构建更难。
构建的另一个优点是你可以将你的修改存储在 git 中的官方源之上,并且总是 rebase,就像我在这里做的那样:https : //github.com/errge/gecko-dev/tree/gregzilla-patched-20181223
我建议您首先从二进制选项开始,因为您将在 20 分钟内使用键盘快捷键,而不仅仅是在 mercurial 克隆过程的开始:)
这两种方法都独立于任何扩展程序/网络扩展程序,并且始终有效,即使在地址栏甚至受保护的页面上也是如此(正如您在评论中所问的那样)。所以它们会比重新映射 webextensions 更好地工作。
我写了一篇文章,其中包含您可能感兴趣的所有细节:https : //github.com/nilcons/firefox-hacks
如果您有更多问题,请在github上报告问题。
Ben*_*pel 12
您可以使用AutoConfig更改 Firefox 中的键绑定,而无需解压和修改 Firefox 二进制文件。
创建一个config-prefs.js
和config.js
文件:
在 Windows 上:
C:\Program Files\Mozilla Firefox\defaults\pref\config-prefs.js
C:\Program Files\Mozilla Firefox\defaults\pref\config.js
在 macOS 上:
Firefox.app\Contents\Resources\config.js
Firefox.app\Contents\Resources\defaults\pref\config-prefs.js
在 Linux 上:
/usr/lib/firefox/config.js
/usr/lib/firefox/browser/defaults/preferences/config-prefs.js
包含以下内容:
config-prefs.js
:
pref("general.config.filename", "config.js");
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false);
Run Code Online (Sandbox Code Playgroud)
config.js
:
try {
let { classes: Cc, interfaces: Ci, manager: Cm } = Components;
const Services = globalThis.Services;
const {SessionStore} = Components.utils.import('resource:///modules/sessionstore/SessionStore.jsm');
function ConfigJS() { Services.obs.addObserver(this, 'chrome-document-global-created', false); }
ConfigJS.prototype = {
observe: function (aSubject) { aSubject.addEventListener('DOMContentLoaded', this, {once: true}); },
handleEvent: function (aEvent) {
let document = aEvent.originalTarget; let window = document.defaultView; let location = window.location;
if (/^(chrome:(?!\/\/(global\/content\/commonDialog|browser\/content\/webext-panels)\.x?html)|about:(?!blank))/i.test(location.href)) {
if (window._gBrowser) {
// Place your keyboard shortcut changes here
// ...
// ...
}
}
}
};
if (!Services.appinfo.inSafeMode) { new ConfigJS(); }
} catch(ex) {};
Run Code Online (Sandbox Code Playgroud)
修改这些文件后,您始终必须转到about:support
并运行Clear startup cache
,以使用新配置重新启动浏览器。
您可以做什么的一些示例:
将这些片段放入config.js
我写的地方Place your keyboard shortcut changes here
。
删除现有的键盘快捷键
// remove Ctrl-Shift-X, so that I can map it to 1Password in the 1Password app later
let keySwitchDirection = window.document.getElementById('key_switchTextDirection');
keySwitchDirection.remove();
Run Code Online (Sandbox Code Playgroud)
更改现有键盘快捷键
// remap Ctrl-J to downloads (removing it from focusing the browser bar)
let search2 = window.document.getElementById('key_search2')
search2.remove();
let openDownloads = window.document.getElementById('key_openDownloads')
openDownloads.setAttribute("modifiers", "accel");
openDownloads.setAttribute("key", "J");
Run Code Online (Sandbox Code Playgroud)
创建新的键盘快捷键
// create keyboard shortcut to Toolbar > Settings with Ctrl-,
let settingsKey = window.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'key');
settingsKey.setAttribute("id", "key_Settings");
settingsKey.setAttribute("modifiers", "accel,shift");
settingsKey.setAttribute("key", "U");
settingsKey.setAttribute("oncommand", "openPreferences()");
settingsKey.addEventListener('command', this, false);
mainKeyset.appendChild(settingsKey);
Run Code Online (Sandbox Code Playgroud)
完全定制的东西。(Firefox 引入了 Shift-Ctrl-T 作为通用撤消(更改集),因此不再需要此处的示例。我将其留在这里作为其他自定义的示例。)
// make Ctrl-Shift-T reopen last tab OR last window, depending on which one was closed last
let undoCloseTabKey = window.document.getElementById('key_undoCloseTab');
undoCloseTabKey.removeAttribute('command');
undoCloseTabKey.setAttribute('oncommand', 'undoCloseLastClosedTabOrWindow()');
undoCloseTabKey.addEventListener('command', this, false);
window.undoCloseLastClosedTabOrWindow = function() {
// don't have any tabs to restore
if (SessionStore.getClosedTabCount(window) == 0) {
// we don't need to worry whether there are any windows to restore - undoCloseWindow does that for us
window.undoCloseWindow();
}
// don't have any windows to restore
else if (SessionStore.getClosedWindowCount() == 0) {
// we don't need to worry whether there are any tabs to restore - undoCloseTab does that for us
window.undoCloseTab();
}
// restore whichever was closed more recently
else if (SessionStore.getClosedTabData(window)[0].closedAt > SessionStore.getClosedWindowData()[0].closedAt) {
window.undoCloseTab();
} else {
window.undoCloseWindow();
}
}
Run Code Online (Sandbox Code Playgroud)
指示:
要查找现有的键盘快捷键:
#mainKeyset
查找可以使用键盘快捷键触发的菜单操作
appMenu-settings-button
oncommand
从菜单项中获取属性,并将其用作oncommand
键标签的属性或者
#mainCommandSet
id
,并将其用作command
(而不是oncommand
)键标签的属性。定义键盘快捷键:
modifiers
。您可以使用accel
(Ctrl),shift
并且alt
key
使用属性指定键本身所有这些的来源:Reddit、u/aveyo、通过设置 config.js 恢复 Ctrl+Shift+B = Library
更多详细信息:Firefox 键盘快捷键(网络存档)
如果您使用 macOS,则可以自定义任何 app\xe2\x80\x99s 快捷方式,只要它们出现在应用程序菜单中即可。macOS 13+ 的说明
\n\n\n\n
\n- \n
在 Mac 上,选取 \xef\xa3\xbf 菜单 > “系统设置”,点按边栏中的“键盘” (您可能需要向下滚动),然后点按右侧的“键盘快捷键” 。
\n- \n
选择左侧的“应用程序快捷方式” ,点按“添加”按钮,点按“应用程序”弹出式菜单,然后选取特定应用程序或“所有应用程序”。
\n- \n
在“菜单标题”字段中,键入要为其创建快捷方式的菜单命令,与应用程序中显示的命令完全相同
\n
有关 Apple\xe2\x80\x99s 网站的更多详细信息:https://support.apple.com/guide/mac-help/create-keyboard-shortcuts-for-apps-mchlp2271/mac
\n编辑:现已从 Firefox 支持中删除: https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly:
注意:您可以使用https://addons.mozilla.org/firefox/addon/saka-key/扩展自定义 Firefox 的键盘快捷键。
我希望这是您正在寻找的。
归档时间: |
|
查看次数: |
45333 次 |
最近记录: |