红豆饭种子自动认领

红豆饭自动认领种子,带美化UI

  1. // ==UserScript==
  2. // @name 红豆饭种子自动认领
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 红豆饭自动认领种子,带美化UI
  6. // @author bitptpt
  7. // @match *://*/userdetails.php*
  8. // @grant none
  9. // @run-at document-end
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 创建优化后的控制面板
  17. function createControlPanel() {
  18. // 创建样式
  19. const style = document.createElement('style');
  20. style.textContent = `
  21. .auto-claim-panel {
  22. position: fixed;
  23. top: 20px;
  24. right: 20px;
  25. z-index: 99999;
  26. background: linear-gradient(135deg, #2b5876, #4e4376);
  27. border-radius: 10px;
  28. box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  29. color: white;
  30. font-family: Arial, sans-serif;
  31. padding: 15px;
  32. width: 220px;
  33. transition: all 0.3s ease;
  34. opacity: 0.95;
  35. }
  36. .auto-claim-panel:hover {
  37. opacity: 1;
  38. box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  39. }
  40. .auto-claim-title {
  41. font-size: 16px;
  42. font-weight: bold;
  43. margin-bottom: 15px;
  44. text-align: center;
  45. padding-bottom: 10px;
  46. border-bottom: 1px solid rgba(255,255,255,0.2);
  47. }
  48. .auto-claim-buttons {
  49. display: flex;
  50. justify-content: space-between;
  51. margin-bottom: 15px;
  52. }
  53. .auto-claim-btn {
  54. padding: 8px 15px;
  55. border: none;
  56. border-radius: 5px;
  57. cursor: pointer;
  58. font-weight: bold;
  59. transition: all 0.2s;
  60. width: 45%;
  61. box-shadow: 0 3px 6px rgba(0,0,0,0.1);
  62. }
  63. .auto-claim-btn:hover {
  64. transform: translateY(-2px);
  65. box-shadow: 0 5px 10px rgba(0,0,0,0.15);
  66. }
  67. .auto-claim-start {
  68. background-color: #4CAF50;
  69. color: white;
  70. }
  71. .auto-claim-start:disabled {
  72. background-color: #888;
  73. cursor: not-allowed;
  74. transform: none;
  75. box-shadow: none;
  76. }
  77. .auto-claim-stop {
  78. background-color: #f44336;
  79. color: white;
  80. }
  81. .auto-claim-status {
  82. background-color: rgba(0,0,0,0.2);
  83. padding: 10px;
  84. border-radius: 5px;
  85. margin-bottom: 10px;
  86. min-height: 20px;
  87. font-size: 14px;
  88. }
  89. .auto-claim-stats {
  90. display: flex;
  91. justify-content: space-between;
  92. margin-top: 15px;
  93. padding-top: 10px;
  94. border-top: 1px solid rgba(255,255,255,0.2);
  95. }
  96. .auto-claim-stat {
  97. text-align: center;
  98. flex: 1;
  99. }
  100. .auto-claim-stat-value {
  101. font-size: 20px;
  102. font-weight: bold;
  103. margin-bottom: 5px;
  104. }
  105. .auto-claim-stat-label {
  106. font-size: 12px;
  107. opacity: 0.8;
  108. }
  109. .auto-claim-footer {
  110. font-size: 11px;
  111. text-align: center;
  112. margin-top: 15px;
  113. opacity: 0.7;
  114. }
  115. .auto-claim-progress {
  116. height: 6px;
  117. background-color: rgba(255,255,255,0.2);
  118. border-radius: 3px;
  119. margin: 10px 0;
  120. overflow: hidden;
  121. }
  122. .auto-claim-progress-bar {
  123. height: 100%;
  124. background-color: #4CAF50;
  125. width: 0%;
  126. transition: width 0.3s ease;
  127. }
  128. .blink-status {
  129. animation: blink 1s linear infinite;
  130. }
  131. @keyframes blink {
  132. 0% { opacity: 1; }
  133. 50% { opacity: 0.5; }
  134. 100% { opacity: 1; }
  135. }
  136. `;
  137. document.head.appendChild(style);
  138.  
  139. // 创建面板
  140. const panel = document.createElement('div');
  141. panel.className = 'auto-claim-panel';
  142.  
  143. panel.innerHTML = `
  144. <div class="auto-claim-title">自动认领工具</div>
  145. <div class="auto-claim-buttons">
  146. <button class="auto-claim-btn auto-claim-start">开始认领</button>
  147. <button class="auto-claim-btn auto-claim-stop">停止</button>
  148. </div>
  149. <div class="auto-claim-status">状态: 准备就绪</div>
  150. <div class="auto-claim-progress">
  151. <div class="auto-claim-progress-bar"></div>
  152. </div>
  153. <div class="auto-claim-stats">
  154. <div class="auto-claim-stat">
  155. <div class="auto-claim-stat-value" id="claimed-count">0</div>
  156. <div class="auto-claim-stat-label">已认领</div>
  157. </div>
  158. <div class="auto-claim-stat">
  159. <div class="auto-claim-stat-value" id="remaining-count">0</div>
  160. <div class="auto-claim-stat-label">待认领</div>
  161. </div>
  162. </div>
  163. <div class="auto-claim-footer" 自动化认领工具 v1.2</div>
  164. `;
  165.  
  166. document.body.appendChild(panel);
  167.  
  168. return {
  169. panel,
  170. startButton: panel.querySelector('.auto-claim-start'),
  171. stopButton: panel.querySelector('.auto-claim-stop'),
  172. statusText: panel.querySelector('.auto-claim-status'),
  173. claimedCount: panel.querySelector('#claimed-count'),
  174. remainingCount: panel.querySelector('#remaining-count'),
  175. progressBar: panel.querySelector('.auto-claim-progress-bar')
  176. };
  177. }
  178.  
  179. // 主要功能函数
  180. function initAutoClaimButtons() {
  181. let intervalId = null;
  182. let waitTime = 1000; // 初始等待时间1秒
  183. let currentState = 'idle'; // 状态:idle, claiming, waitingForPopup, confirmingPopup
  184. let running = false;
  185. let claimedCount = 0;
  186. let processingAnimation = null;
  187.  
  188. const {
  189. startButton,
  190. stopButton,
  191. statusText,
  192. claimedCount: claimedCountElement,
  193. remainingCount: remainingCountElement,
  194. progressBar
  195. } = createControlPanel();
  196.  
  197. // 更新认领统计
  198. function updateStats() {
  199. // 计算剩余可认领数量
  200. const remainingButtons = document.querySelectorAll('button[data-action="addClaim"][style*="display: flex"]').length;
  201. remainingCountElement.textContent = remainingButtons;
  202.  
  203. // 更新进度条(如果有可认领按钮)
  204. const totalButtons = claimedCount + remainingButtons;
  205. if (totalButtons > 0) {
  206. const progress = (claimedCount / totalButtons) * 100;
  207. progressBar.style.width = `${progress}%`;
  208. }
  209. }
  210.  
  211. // 点击认领按钮
  212. function clickClaimButton() {
  213. // 更新统计
  214. updateStats();
  215.  
  216. // 寻找所有显示的认领按钮
  217. const claimButtons = document.querySelectorAll('button[data-action="addClaim"][style*="display: flex"]');
  218.  
  219. if (claimButtons.length > 0) {
  220. currentState = 'claiming';
  221. statusText.textContent = `状态: 正在点击认领按钮...`;
  222. statusText.classList.add('blink-status');
  223.  
  224. // 点击第一个可见的认领按钮
  225. claimButtons[0].click();
  226.  
  227. // 等待确认弹窗出现
  228. currentState = 'waitingForPopup';
  229. waitTime = 500; // 短暂等待确认弹窗
  230. } else {
  231. statusText.textContent = `状态: 未找到认领按钮`;
  232. statusText.classList.remove('blink-status');
  233. waitTime = 1000; // 重置等待时间
  234. }
  235. }
  236.  
  237. // 处理确认弹窗
  238. function handleConfirmPopup() {
  239. // 查找确认弹窗中的OK按钮
  240. const confirmButtons = document.querySelectorAll('.layui-layer-btn .layui-layer-btn0');
  241.  
  242. if (confirmButtons.length > 0) {
  243. statusText.textContent = '状态: 确认认领中...';
  244. confirmButtons[0].click();
  245. claimedCount++;
  246. claimedCountElement.textContent = claimedCount;
  247.  
  248. // 更新统计
  249. updateStats();
  250.  
  251. // 确认完成后,设置状态为idle,短暂等待后继续寻找下一个认领按钮
  252. currentState = 'idle';
  253. waitTime = 1000; // 确认后等待1秒再继续
  254. } else {
  255. // 如果没找到确认按钮,可能弹窗未加载或已消失
  256. if (currentState === 'waitingForPopup') {
  257. // 继续等待弹窗出现
  258. waitTime = 300; // 短暂等待
  259. statusText.textContent = '状态: 等待确认框出现...';
  260. } else {
  261. // 重置状态
  262. currentState = 'idle';
  263. waitTime = 1000;
  264. }
  265. }
  266. }
  267.  
  268. // 主循环函数
  269. function mainLoop() {
  270. if (!running) return;
  271.  
  272. switch (currentState) {
  273. case 'idle':
  274. clickClaimButton();
  275. break;
  276. case 'waitingForPopup':
  277. case 'claiming':
  278. handleConfirmPopup();
  279. break;
  280. default:
  281. currentState = 'idle';
  282. }
  283.  
  284. // 设置下一次执行
  285. clearTimeout(intervalId);
  286. intervalId = setTimeout(mainLoop, waitTime);
  287. }
  288.  
  289. // 开始自动点击
  290. startButton.addEventListener('click', function() {
  291. if (running) return;
  292.  
  293. running = true;
  294. currentState = 'idle';
  295. statusText.textContent = '状态: 开始自动认领';
  296. startButton.disabled = true;
  297.  
  298. // 更新初始统计
  299. updateStats();
  300.  
  301. // 开始主循环
  302. mainLoop();
  303.  
  304. // 定时更新统计信息
  305. processingAnimation = setInterval(updateStats, 2000);
  306. });
  307.  
  308. // 停止自动点击
  309. stopButton.addEventListener('click', function() {
  310. if (intervalId) {
  311. clearTimeout(intervalId);
  312. intervalId = null;
  313. }
  314.  
  315. if (processingAnimation) {
  316. clearInterval(processingAnimation);
  317. processingAnimation = null;
  318. }
  319.  
  320. running = false;
  321. currentState = 'idle';
  322. startButton.disabled = false;
  323. statusText.textContent = '状态: 已停止';
  324. statusText.classList.remove('blink-status');
  325. });
  326.  
  327. // 初始统计
  328. updateStats();
  329. }
  330.  
  331. // 初始化
  332. if (window.location.href.includes('details.php') || window.location.href.includes('userdetails.php')) {
  333. // 确保页面完全加载后再初始化
  334. window.addEventListener('load', function() {
  335. setTimeout(initAutoClaimButtons, 500);
  336. });
  337. }
  338. })();

QingJ © 2025

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