// ==UserScript== // @version 1.0.0 // @name 自动点击 // @namespace https://aic.oceanengine.com/ // @include https://aic.oceanengine.com/* // @description Auto // @author You // @match https://aic.oceanengine.com/tools/commodity_card?bpId=1802895905078362 // @icon https://www.google.com/s2/favicons?sz=64&domain=oceanengine.com // @license MIT // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 定义一个标志,表示是否正在执行流程 let isExecuting = false; // 定义一个标志,表示是否需要停止流程 let shouldStop = false; // 定义一个变量来存储“继续生成”按钮的定时器 let continueIntervalId; // 定义一个函数来查找并点击“立即生成”按钮 function checkAndClickGenerateButton() { if (isExecuting || shouldStop) { // 如果正在执行流程或需要停止流程,暂停检测“立即生成”按钮 return; } const span = Array.from(document.querySelectorAll('span')).find(el => el.textContent.trim() === '立即生成'); if (span) { const button = span.parentElement; if (button) { button.click(); console.log('已点击“立即生成”按钮'); // 开始点击“继续生成”按钮九次 clickContinueButton(9); // 9次 } else { console.error('未找到span的父级button元素'); } } else { console.log('未找到文本内容为“立即生成”的span元素,继续检查...'); } } // 定义一个函数来点击“继续生成”按钮九次 function clickContinueButton(count) { if (shouldStop) { console.log('停止流程'); return; } isExecuting = true; // 设置标志,表示正在执行流程 let remainingClicks = count; continueIntervalId = setInterval(() => { if (shouldStop) { clearInterval(continueIntervalId); isExecuting = false; console.log('停止流程'); return; } // 查找文本内容为“继续生成”的按钮 const continueButton = Array.from(document.querySelectorAll('button')).find(button => button.textContent.trim() === '继续生成'); if (continueButton) { continueButton.click(); remainingClicks -= 1; console.log('已点击“继续生成”按钮,剩余次数:'+remainingClicks); if (remainingClicks === 0) { clearInterval(continueIntervalId); // 停止定时器 console.log('完成9次“继续生成”按钮的点击'); // 等待30秒后,重新开始检查“立即生成”按钮 setTimeout(() => { if (!shouldStop) { isExecuting = false; // 清除标志,表示流程完成 checkAndClickGenerateButton(); } }, 30000); // 等待30000毫秒(30秒) } } else { console.log('未找到“继续生成”按钮,继续检查...'); } }, 10000); // 每次点击间隔1000毫秒(1秒) } // 添加一个自定义按钮来触发整个流程 function addCustomButtons() { const startButton = document.createElement('button'); startButton.textContent = '开始'; startButton.style.position = 'fixed'; startButton.style.top = '10px'; startButton.style.left = '10px'; startButton.style.zIndex = '9999'; startButton.style.padding = '5px 10px'; startButton.style.fontSize = '14px'; startButton.style.backgroundColor = 'green'; startButton.style.color = 'white'; startButton.style.border = 'none'; startButton.style.borderRadius = '50%'; startButton.style.cursor = 'pointer'; startButton.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)'; startButton.style.transition = 'background-color 0.3s'; startButton.addEventListener('mouseover', () => { startButton.style.backgroundColor = 'darkgreen'; }); startButton.addEventListener('mouseout', () => { startButton.style.backgroundColor = 'green'; }); startButton.addEventListener('click', () => { console.log('开始全流程'); shouldStop = false; // 确保流程可以开始 checkAndClickGenerateButton(); }); const stopButton = document.createElement('button'); stopButton.textContent = '停止'; stopButton.style.position = 'fixed'; stopButton.style.top = '10px'; stopButton.style.left = '60px'; stopButton.style.zIndex = '9999'; stopButton.style.padding = '5px 10px'; stopButton.style.fontSize = '14px'; stopButton.style.backgroundColor = 'red'; stopButton.style.color = 'white'; stopButton.style.border = 'none'; stopButton.style.borderRadius = '50%'; stopButton.style.cursor = 'pointer'; stopButton.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)'; stopButton.style.transition = 'background-color 0.3s'; stopButton.addEventListener('mouseover', () => { stopButton.style.backgroundColor = 'darkred'; }); stopButton.addEventListener('mouseout', () => { stopButton.style.backgroundColor = 'red'; }); stopButton.addEventListener('click', () => { console.log('停止全流程'); shouldStop = true; // 设置停止标志 clearInterval(continueIntervalId); // 清除“继续生成”按钮的定时器 isExecuting = false; // 清除执行标志 }); document.body.appendChild(startButton); document.body.appendChild(stopButton); } // 添加自定义按钮 addCustomButtons(); })();