Lichess study comment keybind

Press the 'a' key to show comment field in study

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Lichess study comment keybind
// @namespace    http://github.com/flugsio
// @version      0.2
// @description  Press the 'a' key to show comment field in study
// @author       flugsio
// @include        /\.lichess\.org\/study\/\w{8}$/
// @grant none
// ==/UserScript==
// This script is in the public domain / CCO or whatever lol

// You can easily change this keybind,
// here is documentation for special keys and combos:
// https://craig.is/killing/mice
Mousetrap.bind('a', function() {
    var textarea = $('.study_comment_form textarea');
    if (0 < textarea.length) {
        textarea.focus();
    } else {
        window.jQuery('.study_buttons .comment').click();
    }
}, 'keyup');
// note that it triggers on keyup, so key is not added in the comment
// could also return false; but.. not sure if the best