DeepSeek繁忙自动点击重试

DeepSeek提示繁忙,自动点击重试

目前为 2025-02-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         DeepSeek繁忙自动点击重试
// @namespace    http://tampermonkey.net/
// @version      2025-02-11
// @license      MIT
// @description  DeepSeek提示繁忙,自动点击重试
// @author       Dingning
// @include      *://*.deepseek.com/*
// @icon         https://registry.npmmirror.com/@lobehub/icons-static-png/latest/files/dark/deepseek-color.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 初始间隔时间(毫秒)
    let intervalTime = 1000;
    // 重试计数器
    let retryCount = 0;
    // 重试次数阈值,达到该阈值后增加间隔时间
    const threshold = 5;
    // 每次增加的间隔时间(毫秒),正常情况增加2秒
    const normalIntervalIncrement = 2000;
    // 当检测到频率过快提示时每次增加的间隔时间(毫秒),即30秒
    const fastFrequencyIntervalIncrement = 30000;

    const checkAndRetry = () => {
        // 检查是否没有 .ds-loading 元素
        const loadingElements = document.querySelectorAll('.ds-loading');
        const hasLoading = loadingElements.length > 0;

        // 检查页面是否存在 <p>服务器繁忙,请稍后再试。</p>
        const contentList = document.querySelectorAll('.ds-markdown');
        let hasBusyMessage = false;
        for (let i = 0; i < contentList.length; i++) {
            if (contentList[i].innerHTML === '<p>服务器繁忙,请稍后再试。</p>') {
                hasBusyMessage = true;
                break;
            }
        }

        // 如果没有 .ds-loading 元素且没有繁忙提示,重置重试次数和间隔时间
        if (!hasLoading && !hasBusyMessage) {
            retryCount = 0;
            intervalTime = 1000;
            clearInterval(intervalId);
            intervalId = setInterval(checkAndRetry, intervalTime);
            console.log('✅ 已重置重试次数和间隔时间');
        }

        const lastContent = contentList.length > 0 ? contentList[contentList.length - 1].innerHTML : '';
        if (lastContent === '<p>服务器繁忙,请稍后再试。</p>') {
            const btns = document.querySelectorAll('.ds-icon-button');
            const retryBtn = btns.length > 3 ? btns[btns.length - 3] : null;
            if (retryBtn) {
                retryBtn.click();
                retryCount++;
                console.log(`✅ 已点击重试,重试次数: ${retryCount}`);
                let increment = normalIntervalIncrement;

                // 检查是否有频率过快的提示
                const toastContents = document.querySelectorAll('.ds-toast__content');
                for (let i = 0; i < toastContents.length; i++) {
                    if (toastContents[i].textContent === '你发送消息的频率过快,请稍后再发') {
                        increment = fastFrequencyIntervalIncrement;
                        break;
                    }
                }

                // 当重试次数达到阈值时,增加间隔时间
                if (retryCount >= threshold) {
                    intervalTime += increment;
                    clearInterval(intervalId);
                    intervalId = setInterval(checkAndRetry, intervalTime);
                    console.log(`⚠️ 重试次数过多,间隔时间已调整为 ${intervalTime} 毫秒`);
                }
            }
        }
    };

    // 初始间隔定时器
    let intervalId = setInterval(checkAndRetry, intervalTime);

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址