ChatGPT Message Queue

Queue messages when input isn't cleared after Enter

Tính đến 18-03-2025. Xem phiên bản mới nhất.

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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        ChatGPT Message Queue
// @match       https://chat.openai.com/*
// @match       https://chatgpt.com/*
// @description Queue messages when input isn't cleared after Enter
// @version 0.0.1.20250318143202
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

(function() {
    'use strict';
    
    let queueCount = 0;
    let queueObserver;
    const queueDisplay = document.createElement('div');
    
    // Minimal UI setup
    queueDisplay.innerHTML = `
        <span>Queue: ${queueCount}</span>
        <button onclick="this.previousElementSibling.textContent='Queue: 0'">×</button>
    `;
    queueDisplay.style.cssText = `
        position:fixed; bottom:100px; right:20px;
        background:rgba(0,0,0,0.7); color:white;
        padding:5px 10px; border-radius:4px; display:flex; gap:8px;
    `;
    document.body.appendChild(queueDisplay);

    // Core logic
    new MutationObserver((_, observer) => {
        const textarea = document.getElementById('prompt-textarea');
        if (textarea && !textarea.dataset.queuer) {
            textarea.dataset.queuer = true;
            textarea.addEventListener('keydown', e => {
                if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
                    setTimeout(() => { // Allow DOM update
                        if (textarea.textContent.trim()) {
                            queueDisplay.children[0].textContent = `Queue: ${++queueCount}`;
                            if (!queueObserver) {
                                queueObserver = new MutationObserver(() => {
                                    document.querySelector('[data-testid="send-button"]')?.click();
                                    queueCount--;
                                    queueDisplay.children[0].textContent = `Queue: ${queueCount}`;
                                });
                                queueObserver.observe(document.body, {childList: true, subtree: true});
                            }
                        }
                    }, 50);
                }
            });
        }
    }).observe(document.body, {childList: true, subtree: true});
})();