ChatGPT Message Queue

Queue messages when ChatGPT is still composing responses

Verze ze dne 18. 03. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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.20250318110102
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

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

    function createQueueDisplay() {
        // Create queue display with clear button
        queueDisplay = document.createElement('div');
        queueDisplay.style.position = 'fixed';
        queueDisplay.style.bottom = '100px';
        queueDisplay.style.right = '20px';
        queueDisplay.style.background = 'rgba(0,0,0,0.7)';
        queueDisplay.style.color = 'white';
        queueDisplay.style.padding = '5px 10px';
        queueDisplay.style.borderRadius = '4px';
        queueDisplay.style.display = 'flex';
        queueDisplay.style.gap = '8px';
        queueDisplay.style.alignItems = 'center';

        const text = document.createElement('span');
        text.textContent = `Queue: ${queueCount}`;
        
        const clearBtn = document.createElement('button');
        clearBtn.textContent = '×';
        clearBtn.style.cursor = 'pointer';
        clearBtn.style.background = 'transparent';
        clearBtn.style.border = 'none';
        clearBtn.style.color = 'inherit';
        clearBtn.style.fontSize = '18px';
        clearBtn.style.padding = '0 4px';
        clearBtn.onclick = () => {
            queueCount = 0;
            text.textContent = `Queue: ${queueCount}`;
        };

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

    // Rest of the original script remains unchanged
    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
    });
})();