解决Linux中误按Ctrl+q导致Firefox退出的问题

解决Linux中误按Ctrl + q 导致Firefox退出的问题

问题描述:在Ubuntu的火狐浏览器中浏览网页时,经常由于误按Ctrl + q 快捷键导致整个火狐浏览器直接退出而没有任何提示,这严重影响了工作效率,经过一番搜索之后,得出如下可行方案。(本文适用于Firefox Quantum 64.0)

  1. 打开火狐,在地址栏中键入:about:support
  2. Application Basics -> Profile Directory栏中点击Open Directory按钮,打开火狐的配置目录
  3. 在该目录中,新建一个文件夹名为chrome
  4. chrome文件夹中新建三个文件,分别是userChrome.cssuserChrome.xmluserChrome.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();
  1. 重启火狐.

参考自:

firefox-quantum-userchromejs

Disable Ctrl+q with userChrome.js in Firefox Quantum

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值