您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically focuses on the textarea when the page loads.
// ==UserScript== // @name Auto Focus on TextBox in Google Search AI Mode (udm=50) // @namespace https://gf.zukizuki.org/en/users/688917 // @version 1.1 // @description Automatically focuses on the textarea when the page loads. // @author You // @match https://www.google.com/search?udm=50* // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com // @grant none // @run-at document-end // @license MIT // ==/UserScript== (function() { 'use strict'; const textAreaSelector = '#cnt > div.QGG6Id.YNk70c.YzCcne > div:nth-child(2) > section > div > div > div > div.WzWwpc > div.y4VEUd > div > div.AgWCw > div.esoFne > div > textarea'; const textarea = document.querySelector(textAreaSelector); function focusTextarea() { if (textarea) { textarea.focus(); } } // Run immediately focusTextarea(); // Also try again if elements are loaded dynamically new MutationObserver(focusTextarea).observe(document.body, { childList: true, subtree: true }); // Detect user typing and auto-focus the textarea document.addEventListener('keydown', (event) => { if (event.ctrlKey || event.metaKey) { return; // Ignore shortcuts like Ctrl+C, Ctrl+V, Cmd+C, etc. } if (document.activeElement !== textarea) { focusTextarea(); } }); })();