您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Press Alt+1 to focus the first text input on all pages
// ==UserScript== // @name 聚焦第一个文本输入框 // @version 0.6 // @description Press Alt+1 to focus the first text input on all pages // @author hiisme // @match *://*/* // @grant none // @namespace https://gf.qytechs.cn/users/217852 // ==/UserScript== (function() { 'use strict'; // 监听键盘按下事件 document.addEventListener('keydown', function(event) { // 检查是否按下了Alt键和1键 if (event.altKey && event.key === '1') { event.preventDefault(); focusFirstTextInput(); } }, false); // 尝试聚焦第一个文本输入框 function focusFirstTextInput() { // 扩展的选择器,尝试匹配更多类型的输入框 var inputSelector = [ 'input[type="text"]:not([disabled]):not([readonly])', 'input[type="email"]:not([disabled]):not([readonly])', 'input[type="password"]:not([disabled]):not([readonly])', 'input[type="search"]:not([disabled]):not([readonly])', 'input[type="tel"]:not([disabled]):not([readonly])', 'input[type="url"]:not([disabled]):not([readonly])', 'input:not([type]):not([disabled]):not([readonly])', // 无type属性的input也默认为text 'textarea:not([disabled]):not([readonly])', '[contenteditable="true"]:not([disabled]):not([readonly])', // 可编辑区域 '[role="textbox"]:not([disabled]):not([readonly])' // 带有特定角色的元素 ].join(','); // 排除不可见的元素 var allInputs = document.querySelectorAll(inputSelector); var firstVisibleInput = Array.from(allInputs).find(input => { var style = window.getComputedStyle(input); return style.display !== 'none' && style.visibility !== 'hidden'; }); if (firstVisibleInput) { firstVisibleInput.focus(); } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址