第一步:打开到这个界面(待提交)

第二步:在第一部的界面按F12,选择控制台

将代码粘贴进去:
class SoftCopyAutoSubmitter {
constructor() {
this.intervalTime = 1000; // 整体循环间隔1秒
this.maxRetries = 10000; // 最大重试次数
this.currentRetry = 0; // 当前重试次数
this.successUrlPattern = '/opus/success';
this.isRunning = false;
this.confirmSelector = 'body > div.carousel.carouselFixed > div > div > div.hd-msg-box-footer > button.hd-btn.blue.medium';
}
getElementByText(tag, text) {
const elements = document.querySelectorAll(tag);
for (let el of elements) {
if (el.textContent.includes(text)) {
return el;
}
}
return null;
}
getMainSubmitButton() {
let btn = this.getElementByText('button', '确认提交');
if (!btn) btn = this.getElementByText('span', '提交');
return btn;
}
getConfirmButton() {
const btn = document.querySelector(this.confirmSelector);
return btn;
}
checkForError() {
const bodyCheck = document.body.innerText.includes('当前提交人数过多');
return bodyCheck;
}
checkSuccess() {
return window.location.href.includes(this.successUrlPattern);
}
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async start() {
if (this.isRunning) return;
this.isRunning = true;
console.log("自动化提交脚本(双重确认版)已启动...");
while (this.currentRetry < this.maxRetries) {
console.log(`\n------ 第 ${this.currentRetry + 1} 次尝试 ------`);
if (this.checkSuccess()) {
console.log("恭喜!检测到提交成功,脚本停止。");
break;
}
const mainBtn = this.getMainSubmitButton();
if (mainBtn) {
console.log("点击主提交按钮...");
mainBtn.click();
await this.sleep(1000);
const confirmBtn = this.getConfirmButton();
if (confirmBtn) {
console.log("发现确认弹窗,点击确认按钮...");
confirmBtn.click();
} else {
console.warn("点击主按钮后未发现确认弹窗 (可能是还未加载或已被点击)");
}
} else {
console.log("无法找到主提交按钮");
}
await this.sleep(2000);
if (this.checkForError()) {
console.log(`提示"人数过多",将在 ${this.intervalTime / 1000} 秒后重试...`);
} else {
console.log("未检测到错误,继续轮询...");
}
await this.sleep(this.intervalTime);
this.currentRetry++;
}
if (this.currentRetry >= this.maxRetries) {
console.log("达到最大重试次数,脚本停止。");
}
this.isRunning = false;
}
}
const submitter = new SoftCopyAutoSubmitter();
submitter.start();

3334

被折叠的 条评论
为什么被折叠?



