您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Submit prompt in ChatGPT when pressing Enter or Ctrl + Enter
// ==UserScript== // @name Auto Submit Enter for ChatGPT // @namespace http://tampermonkey.net/ // @version 0.3 // @license MIT // @description Submit prompt in ChatGPT when pressing Enter or Ctrl + Enter // @author You // @match https://chatgpt.com/ // @match https://chatgpt.com/c/* // @grant none // ==/UserScript== /* # Auto Submit Enter for ChatGPT ## Description: This script automatically submits the prompt in ChatGPT when you press the **Enter** key or the **Ctrl + Enter** key combination. It works on the following pages: - https://chatgpt.com/ - https://chatgpt.com/c/* This is particularly useful for users who prefer using keyboard shortcuts to interact with ChatGPT, including when editing old prompts. ## Features: - **Enter**: Submits the prompt. - **Ctrl + Enter**: Also submits the prompt. - **Prevents default behavior**: The script prevents a new line from being added when you press **Enter** or **Ctrl + Enter**. ## Instructions: 1. Install [Tampermonkey](https://tampermonkey.net/) extension if you don't have it already. 2. Create a new Tampermonkey script. 3. Paste the code above into the script editor. 4. Save the script. 5. Visit ChatGPT at **https://chatgpt.com/** or any **https://chatgpt.com/c/** page. 6. Now, pressing **Enter** or **Ctrl + Enter** will automatically submit your prompt, including edited ones. ## Notes: - This script assumes that the ChatGPT input field is a `textarea` and that editable message text areas have the same or similar structure. If the page structure changes in future updates, you may need to adjust the script. - The script currently only works for the mentioned URLs (`https://chatgpt.com/` and `https://chatgpt.com/c/*`). If you want to extend it to other pages, modify the `@match` directive in the script. */ (function() { 'use strict'; // Wait until the page is loaded window.addEventListener('load', () => { // Helper function to trigger send button click const sendPrompt = () => { const sendButton = document.querySelector("button[type='submit']"); if (sendButton) { sendButton.click(); } }; // Function to handle Enter key events const handleEnterKey = (event) => { // Check if Enter or Ctrl + Enter is pressed if (event.key === 'Enter' || (event.ctrlKey && event.key === 'Enter')) { // Prevent the default action of adding a new line event.preventDefault(); // Trigger sending the prompt sendPrompt(); } }; // Handle the main text input for new prompts const inputField = document.querySelector("textarea"); if (inputField) { inputField.addEventListener('keydown', handleEnterKey); } // Handle editing of older prompts: look for any editable text areas in conversations const editableFields = document.querySelectorAll("textarea, div[contenteditable='true']"); editableFields.forEach(field => { field.addEventListener('keydown', handleEnterKey); }); }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址