DeepSeek Chat 快捷停止

Auto send message on Enter key press, but not on Shift + Enter

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         DeepSeek Chat 快捷停止
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Auto send message on Enter key press, but not on Shift + Enter
// @author       tianyw0
// @license      MIT
// @match        https://chat.deepseek.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 获取输入框元素
    const chatInput = document.getElementById('chat-input');

    // 监听输入框的 keydown 事件
    chatInput.addEventListener('keydown', function(event) {
        // 检查是否按下了 Enter 键且没有按下 Shift 键
        if (event.key === 'Enter' && !event.shiftKey) {
            // 检查输入框内容是否为空
            if (chatInput.value.trim() !== '') {
                // 重新获取发送按钮元素
                const sendButtons = Array.from(document.querySelectorAll('div[role="button"]'))
                    .filter(button => button.classList[0] && button.classList[0].startsWith('_'));

                // 如果有符合条件的按钮,模拟点击第一个按钮
                if (sendButtons.length > 0) {
                    sendButtons[0].click();
                }
            }
        }
    });
})();