gitMind-bindKey

gitMind自定义绑定快捷键,插入链接(alt+L),插入备注(alt+B),退出弹出窗(esc)

Verze ze dne 15. 04. 2021. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         gitMind-bindKey
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  gitMind自定义绑定快捷键,插入链接(alt+L),插入备注(alt+B),退出弹出窗(esc)
// @author       zhenhuiSu
// @match        https://gitmind.cn/app/doc/*
// @grant        none
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/node-jquery.min.js
// ==/UserScript==
(function () {
    bindHotKey();

    // ctrl shift alt key
    var bindMap = {
        // 00027 ESC
        27: function () {
            var qlEditor = $('.ql-editor');
            var remarkPop = $('.ne-title');
            if (remarkPop) {
                remarkPop.children('.icon-guanbi').click()
            }

            if (qlEditor) {
                qlEditor.focus();
            }
        },
        // 00166 alt B
        166: function () {
            var remarkEl = $('.icon-beizhu');
            if (remarkEl) {
                remarkEl.click();
            }
        },
        // 00176 alt L
        176: function () {
            var remarkEl = $('.icon-beizhu');
            if (remarkEl) {
                remarkEl.click();
            }
        }
    }

    function bindHotKey() {
        document.onkeydown = function () {
            // gitMind内置快捷键绑定的窗口,退出弹出窗后需要使该组件获取焦点,否则内置快捷键将不可用
            var fun = choiceFun(window.event);
            if (fun) {
                fun.apply();
            }
        };
    }

    function choiceFun(e) {
        var key = 0;
        key = key + e.ctrlKey;
        key = (key * 10) + e.shiftKey;
        key = (key * 10) + e.altKey;
        key = (key * 100) + e.keyCode;
        return bindMap[key];
    }
})();