解决Linux中误按Ctrl + q 导致Firefox退出的问题
问题描述:在Ubuntu的火狐浏览器中浏览网页时,经常由于误按Ctrl + q 快捷键导致整个火狐浏览器直接退出而没有任何提示,这严重影响了工作效率,经过一番搜索之后,得出如下可行方案。(本文适用于Firefox Quantum 64.0)
- 打开火狐,在地址栏中键入:
about:support
- 在
Application Basics
->Profile Directory
栏中点击Open Directory
按钮,打开火狐的配置目录 - 在该目录中,新建一个文件夹名为
chrome
- 在
chrome
文件夹中新建三个文件,分别是userChrome.css
,userChrome.xml
,userChrome.js
,这三个文件的内容如下:
userChrome.css
/* Copyright (c) 2017 Haggai Nuchi
Available for use under the MIT License:
https://opensource.org/licenses/MIT
*/
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
toolbarbutton#alltabs-button {
-moz-binding: url("userChrome.xml#js");
}
userChrome.xml
<?xml version="1.0"?>
<!-- Copyright (c) 2017 Haggai Nuchi
Available for use under the MIT License:
https://opensource.org/licenses/MIT
-->
<bindings id="generalBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="js" extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton-badged">
<implementation>
<constructor><![CDATA[
function makeRelativePathURI(name) {
let absolutePath = Components.stack.filename;
return absolutePath.substring(0, absolutePath.lastIndexOf("/") + 1) + name;
}
// The following code executes in the browser context,
// i.e. chrome://browser/content/browser.xul
Services.scriptloader.loadSubScript(makeRelativePathURI("userChrome.js"), window);
]]></constructor>
</implementation>
</binding>
</bindings>
userChrome.js
// Copyright (c) 2017 Haggai Nuchi
// Available for use under the MIT License:
// https://opensource.org/licenses/MIT
// Disable the shortcut of Ctrl + q
var kqa = document.getElementById('key_quitApplication');
if (kqa)
kqa.remove();
- 重启火狐.
参考自: