您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
检测到"服务器繁忙"时自动点击重试按钮
当前为
// ==UserScript== // @name DeepSeek自动重试 // @namespace http://tampermonkey.net/ // @version 0.6 // @description 检测到"服务器繁忙"时自动点击重试按钮 // @author dy // @match https://chat.deepseek.com/* // @grant none // @license none // ==/UserScript== // ==UserScript== // @name 自动重试 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 检测到"服务器繁忙"时自动点击重试按钮 // @author Your name // @match https://chat.deepseek.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // 配置项 const CONFIG = { BUSY_TEXT: '服务器繁忙,请稍后再试', RATE_LIMIT_TEXT: '你发送消息的频率过快,请稍后再发', CHECK_INTERVAL: 1000, MAX_RETRIES: 10, MIN_DELAY: 1500, MAX_DELAY: 3000, DEBOUNCE_DELAY: 5000 // 防抖延迟时间 }; // 状态管理 const state = { retryCount: 0, isRetrying: false, isPaused: false, activeNotification: null, debounceTimer: null, lastRetryTime: 0 }; // 创建提示元素 function createNotification(message, temporary = true) { // 如果已有提示且不是临时的,直接返回 if (state.activeNotification && !temporary) { return state.activeNotification; } const notification = document.createElement('div'); notification.style.cssText = ` position: fixed; top: 20px; right: 20px; background: rgba(0, 0, 0, 0.8); color: white; padding: 10px 20px; border-radius: 5px; z-index: 9999; transition: opacity 0.3s; `; if (!temporary) { const closeButton = document.createElement('span'); closeButton.innerHTML = '×'; closeButton.style.cssText = ` margin-left: 10px; cursor: pointer; font-weight: bold; `; closeButton.onclick = () => { notification.remove(); state.activeNotification = null; state.retryCount = 0; state.isPaused = false; }; notification.appendChild(closeButton); } notification.textContent = message; document.body.appendChild(notification); if (!temporary) { state.activeNotification = notification; } return notification; } // 查找重试按钮 function findRetryButton() { let parent = document.activeElement; while (parent && !parent.querySelector('.ds-icon-button')) { parent = parent.parentElement; } if (!parent) return null; const btns = Array.from(parent.querySelectorAll('.ds-icon-button')); return btns.find(btn => { const svg = btn.querySelector('svg'); return svg && svg.querySelector('#重新生成'); }); } // 自动重试主函数 function autoRetry() { if (state.isPaused) return; // 检查频率限制 const rateLimitElements = Array.from(document.querySelectorAll('*')).filter(el => el.textContent && el.textContent.includes(CONFIG.RATE_LIMIT_TEXT) ); if (rateLimitElements.length > 0) { state.isPaused = true; createNotification('检测到频率过快,稍等一会吧', false); return; } // 检查服务器繁忙 const busyElements = Array.from(document.querySelectorAll('*')).filter(el => el.textContent && el.textContent.includes(CONFIG.BUSY_TEXT) ); if (busyElements.length > 0) { const now = Date.now(); if (!state.isRetrying && (now - state.lastRetryTime) >= CONFIG.DEBOUNCE_DELAY) { state.retryCount++; state.isRetrying = true; state.lastRetryTime = now; const retryButton = findRetryButton(); if (retryButton) { if (state.retryCount >= CONFIG.MAX_RETRIES) { createNotification('已达到最大重试次数,DeepSeek可能当前算力不足', false); return; } const notification = createNotification(`检测到服务器繁忙,即将自动重试(${state.retryCount}/${CONFIG.MAX_RETRIES})...`); // 随机延迟 const delay = Math.floor(Math.random() * (CONFIG.MAX_DELAY - CONFIG.MIN_DELAY + 1)) + CONFIG.MIN_DELAY; clearTimeout(state.debounceTimer); state.debounceTimer = setTimeout(() => { console.log('找到重试按钮,自动点击'); retryButton.dispatchEvent(new MouseEvent('click', { view: window, bubbles: true, cancelable: true })); notification.style.opacity = '0'; setTimeout(() => notification.remove(), 300); state.isRetrying = false; }, delay); } } } else { // 如果不再显示繁忙消息,重置重试状态 state.isRetrying = false; } } // 定期检查页面 setInterval(autoRetry, CONFIG.CHECK_INTERVAL); })();