您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Focuses on the shoutbox input field as soon as you start typing anywhere on the page.
// ==UserScript== // @name TorrentBD - Focus Shoutbox on Keypress // @namespace http://tampermonkey.net/ // @version 2.0 // @description Focuses on the shoutbox input field as soon as you start typing anywhere on the page. // @author SameCourage // @match https://www.torrentbd.net/* // @match https://*.torrentbd.com/* // @match https://*.torrentbd.org/* // @match https://*.torrentbd.me/* // @grant none // @run-at document-idle // @license MIT // @copyright 2025, SameCourage // ==/UserScript== (function() { 'use strict'; // The ID of the input field you want to focus on. const targetInputId = 'shout_text'; // This function finds the input field and sets focus to it. function setFocus() { const shoutboxInput = document.getElementById(targetInputId); // We only try to focus if the element exists and isn't already the active element. if (shoutboxInput && document.activeElement !== shoutboxInput) { shoutboxInput.focus(); } } // --- Main Logic: Focus on any keypress --- document.addEventListener('keydown', () => { const activeEl = document.activeElement; // If the user is NOT currently typing in another input or textarea... if (activeEl.tagName !== 'INPUT' && activeEl.tagName !== 'TEXTAREA') { // ... then focus the shoutbox instantly. setFocus(); } }); })();