ChatGPT Message Queue

Queue messages when ChatGPT is still composing responses

2025-03-18 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        ChatGPT Message Queue
// @match       https://chat.openai.com/*
// @match       https://chatgpt.com/*
// @description Queue messages when ChatGPT is still composing responses
// @version 0.0.1.20250318105806
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

(function() {
    'use strict';
    
    let queueCount = 0;
    let queueObserver;
    let queueDisplay;

    function createQueueDisplay() {
        // Create basic elements without styling
        queueDisplay = document.createElement('div');
        const text = document.createElement('span');
        text.textContent = `Queue: ${queueCount}`;
        
        const clearBtn = document.createElement('button');
        clearBtn.textContent = 'Clear';
        clearBtn.onclick = () => {
            queueCount = 0;
            text.textContent = `Queue: ${queueCount}`;
        };

        queueDisplay.appendChild(text);
        queueDisplay.appendChild(clearBtn);
        document.body.appendChild(queueDisplay);
    }

    function handleSendButton() {
        const sendButton = document.querySelector('[data-testid="send-button"]');
        if (sendButton && queueCount > 0) {
            sendButton.click();
            queueCount--;
            queueDisplay.querySelector('span').textContent = `Queue: ${queueCount}`;
        }
    }

    const textareaObserver = new MutationObserver(() => {
        const textarea = document.getElementById('prompt-textarea');
        if (textarea && !textarea.dataset.queueEnabled) {
            textarea.dataset.queueEnabled = 'true';
            
            textarea.addEventListener('keydown', (e) => {
                if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
                    if (document.querySelector('[data-testid="stop-button"]')) {
                        e.preventDefault();
                        queueCount++;
                        queueDisplay.querySelector('span').textContent = `Queue: ${queueCount}`;
                        
                        if (!queueObserver) {
                            queueObserver = new MutationObserver(handleSendButton);
                            queueObserver.observe(document.body, {
                                childList: true,
                                subtree: true
                            });
                        }
                    }
                }
            });
        }
    });

    // Initialize
    createQueueDisplay();
    textareaObserver.observe(document.body, {
        childList: true,
        subtree: true
    });
})();