您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Focus search bar on SLASH press
当前为
// ==UserScript== // @name slash search bar focus // @namespace http://tampermonkey.net/ // @author limex // @match https://www.bing.com/search* // @icon https://www.google.com/s2/favicons?sz=64&domain=bing.com // @grant none // @description Focus search bar on SLASH press // @version 0.1 // ==/UserScript== // Coment: google seems to work out of the box. (function() { window.addEventListener("keypress", e => { if (['TEXTAREA', 'INPUT'].includes(e.target.nodeName)) return; if (e.key !== "/") return; const searchField = document.querySelector('textarea[type="search"], input[type="search"], input[name="search"], input[placeholder*="Search"]'); if (!searchField) return; searchField.focus(); searchField.setSelectionRange(searchField.value.length, searchField.value.length); e.preventDefault(); }); })();