DeepSeek Auto-Focus

Automatically focuses the chat input on chat.deepseek.com when you type

当前为 2025-02-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         DeepSeek Auto-Focus
// @namespace    https://greasyfork.org/users/your_username_here
// @version      1.3
// @description  Automatically focuses the chat input on chat.deepseek.com when you type
// @match        https://chat.deepseek.com/*
// @grant        none
// ==/UserScript==

document.addEventListener('keydown', e => {
    const textarea = document.getElementById('chat-input');
    const active = document.activeElement;
    
    if (textarea && !/^textarea|input$/i.test(active.tagName) && 
        e.key.length === 1 && /^[\w]$/i.test(e.key) && !e.ctrlKey && !e.metaKey) {
      
        e.preventDefault();
        textarea.focus();
        
        // Insert text at cursor position properly
        const start = textarea.selectionStart;
        const end = textarea.selectionEnd;
        textarea.setRangeText(e.key, start, end, "end"); 
        
        // Dispatch real input events to trigger React/other framework updates
        textarea.dispatchEvent(new Event('input', { bubbles: true }));
        textarea.dispatchEvent(new Event('change', { bubbles: true }));
    }
});