DeepSeek Auto-Regenerate

Automatically retries when DeepSeek shows "server busy" messages

// ==UserScript==
// @name         DeepSeek Auto-Regenerate
// @description  Automatically retries when DeepSeek shows "server busy" messages
// @match        *://*.deepseek.com/*
// @match        *://*.deepseek.ai/*
// @grant        none
// @version 0.0.1.20250304102757
// @namespace http://deepseek.auto.regenerate
// ==/UserScript==

(function() {
    'use strict';
    
    // Create observer to watch for server busy messages
    const observer = new MutationObserver(() => {
        // Look for server busy messages
        document.querySelectorAll('.ds-markdown p').forEach(p => {
            if (p.textContent === "The server is busy. Please try again later.") {
                // Find retry button (second button in container)
                const container = p.closest('.f9bf7997');
                if (container) {
                    const buttons = container.querySelectorAll('.ds-icon-button');
                    if (buttons.length >= 2) {
                        // Click retry button with small delay
                        setTimeout(() => buttons[1].click(), 500);
                    }
                }
            }
        });
    });
    
    // Start observing
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
    
    // Initial check for existing messages
    setTimeout(() => {
        document.querySelectorAll('.ds-markdown p').forEach(p => {
            if (p.textContent === "The server is busy. Please try again later.") {
                const container = p.closest('.f9bf7997');
                if (container) {
                    const buttons = container.querySelectorAll('.ds-icon-button');
                    if (buttons.length >= 2) buttons[1].click();
                }
            }
        });
    }, 1000);
})();