您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Focuses the search bar when forward slash is pressed, like on most sites
- // ==UserScript==
- // @name Jisho.org forward slash to focus search bar
- // @namespace https://github.com/sahlaysta/
- // @version 0.2
- // @description Focuses the search bar when forward slash is pressed, like on most sites
- // @author sahlaysta
- // @match https://jisho.org/*
- // @icon https://avatars.githubusercontent.com/u/12574115?s=200&v=4
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- const searchBar = document.querySelector('#keyword');
- document.addEventListener('keydown', event => {
- if (!event.altKey && !event.ctrlKey && !event.isComposing && document.activeElement !== searchBar && event.key === '/') {
- searchBar.focus();
- searchBar.setSelectionRange(searchBar.value.length, searchBar.value.length);
- event.preventDefault();
- }
- });
- })();