DeepSeek Auto-Regenerate (Minimal)

Automatically click the “重新生成” button when DeepSeek shows “The server is busy. Please try again later.”

  1. // ==UserScript==
  2. // @name DeepSeek Auto-Regenerate (Minimal)
  3. // @description Automatically click the “重新生成” button when DeepSeek shows “The server is busy. Please try again later.”
  4. // @match *://*.deepseek.com/*
  5. // @match *://*.deepseek.ai/*
  6. // @run-at document-idle
  7. // @version 0.0.1.20250514105945
  8. // @namespace http://deepseek.auto.regenerate
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function tryClickRegen(p) {
  15. // find the next sibling wrapper containing the icon buttons
  16. const wrapper = p.parentElement.nextElementSibling;
  17. if (!wrapper) return;
  18.  
  19. // inside that wrapper, find the SVG <rect> whose id is "重新生成"
  20. const regenRect = wrapper.querySelector('rect[id="重新生成"]');
  21. if (!regenRect) return;
  22.  
  23. // climb up to the clickable .ds-icon-button
  24. const button = regenRect.closest('.ds-icon-button');
  25. if (!button) return;
  26.  
  27. // click with a small delay
  28. setTimeout(() => button.click(), 300);
  29. console.log('DeepSeek Auto: clicked 重新生成');
  30. }
  31.  
  32. function scanForBusy() {
  33. document.querySelectorAll('p.ds-markdown-paragraph').forEach(p => {
  34. if (p.textContent.trim() === 'The server is busy. Please try again later.') {
  35. tryClickRegen(p);
  36. }
  37. });
  38. }
  39.  
  40. // observe DOM changes for new busy messages
  41. const observer = new MutationObserver(scanForBusy);
  42. observer.observe(document.body, { childList: true, subtree: true });
  43.  
  44. // initial scan in case message is already present
  45. setTimeout(scanForBusy, 1000);
  46. })();