您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remaps Enter to Shift+Enter, and Ctrl+Enter to Enter on aistudio.google.com.
// ==UserScript== // @name AI Studio Legacy Keybinds // @namespace Violentmonkey Scripts // @match https://aistudio.google.com/* // @grant none // @license MIT // @version 1.0 // @author smoothxhale // @description Remaps Enter to Shift+Enter, and Ctrl+Enter to Enter on aistudio.google.com. // ==/UserScript== function robustlyClickSendButton() { const sendButton = document.querySelector('button[aria-label="Run"]'); if (!sendButton) { return; } sendButton.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true })); sendButton.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })); sendButton.dispatchEvent(new PointerEvent('pointerup', { bubbles: true })); sendButton.dispatchEvent(new MouseEvent('mouseup', { bubbles: true })); sendButton.dispatchEvent(new MouseEvent('click', { bubbles: true })); } function redefineEvent(event, properties) { Object.defineProperties(event, Object.keys(properties).reduce((acc, key) => { acc[key] = { value: properties[key], writable: false, configurable: true }; return acc; }, {})); } window.addEventListener('keydown', (event) => { if (event.target.tagName !== 'TEXTAREA' || event.isComposing) { return; } if (event.key === 'Enter' && event.ctrlKey && !event.shiftKey) { event.preventDefault(); event.stopImmediatePropagation(); robustlyClickSendButton(); } else if (event.key === 'Enter' && !event.ctrlKey && !event.shiftKey) { event.stopImmediatePropagation(); redefineEvent(event, { shiftKey: true }); } }, true);