您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
vim movements
当前为
// ==UserScript== // @name Vim Movements // @namespace http://tampermonkey.net/ // @version 2024-06-01 // @description vim movements // @author You // @match https://*/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; document.documentElement.style.scrollBehavior = 'smooth'; console.log("vim motions loaded"); const scrollAmt = 500; // define function to see if current element is a text box function checkTextBox() { const tag = document.activeElement.tagName; console.log(tag); if (tag == 'TEXTAREA' || tag == 'INPUT') { return true; } return false; } // functions for keys h, j, k, and l document.addEventListener('keypress', (event) => { if (!checkTextBox()) { if (event.key == 'j') { // document.activeElement.scrollBy(0, scrollAmt); window.scrollBy(0, scrollAmt); } else if (event.key == 'k') { // document.activeElement.scrollBy(0, scrollAmt); window.scrollBy(0, -scrollAmt); } else if (event.key == 'u') { history.go(-1); } else if (event.key == 'R' && event.shiftKey) { history.go(1); } } }); })();