aaaaa
This commit is contained in:
parent
5d1d4e51ac
commit
774a6c118a
@ -341,37 +341,78 @@ class WindsurfRegister {
|
||||
// 如果验证通过,点击Continue按钮进入下一页
|
||||
if (result === 'passed') {
|
||||
logger.info(this.siteName, '[Cloudflare] 点击Continue按钮进入验证码页面...');
|
||||
|
||||
try {
|
||||
const currentUrl = this.page.url();
|
||||
let pageChanged = false;
|
||||
let attempts = 0;
|
||||
const maxAttempts = 10; // 最多尝试10次
|
||||
|
||||
while (!pageChanged && attempts < maxAttempts) {
|
||||
attempts++;
|
||||
|
||||
// 查找并点击Continue按钮
|
||||
const button = await this.page.$('button:not([disabled])');
|
||||
if (button) {
|
||||
logger.info(this.siteName, `[Cloudflare] 第${attempts}次点击Continue...`);
|
||||
await button.click();
|
||||
await this.human.randomDelay(2000, 3000);
|
||||
|
||||
// 等待页面跳转或内容改变
|
||||
try {
|
||||
// 方法1: 等待URL改变
|
||||
await this.page.waitForFunction(
|
||||
(oldUrl) => window.location.href !== oldUrl,
|
||||
{ timeout: 10000 },
|
||||
currentUrl
|
||||
);
|
||||
logger.success(this.siteName, '[Cloudflare] 页面已跳转');
|
||||
} catch (e) {
|
||||
// 方法2: 如果URL没变,等待"Check your inbox"文本出现
|
||||
try {
|
||||
await this.page.waitForFunction(
|
||||
() => document.body.textContent.includes('Check your inbox'),
|
||||
{ timeout: 5000 }
|
||||
);
|
||||
logger.success(this.siteName, '[Cloudflare] 验证码页面已加载');
|
||||
} catch (e2) {
|
||||
logger.warn(this.siteName, '[Cloudflare] 等待页面改变超时,继续...');
|
||||
// 检查是否有错误提示
|
||||
const hasError = await this.page.evaluate(() => {
|
||||
const errorMsg = document.querySelector('p.caption1.text-sk-error');
|
||||
return errorMsg && errorMsg.textContent.includes('An error occurred');
|
||||
});
|
||||
|
||||
if (hasError) {
|
||||
logger.warn(this.siteName, '[Cloudflare] 检测到错误提示,重新尝试...');
|
||||
await this.human.randomDelay(2000, 3000);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查页面是否已改变
|
||||
const checkResult = await this.page.evaluate(() => {
|
||||
// 方法1: 检查是否有"Check your inbox"文本
|
||||
const hasCheckInbox = document.body.textContent.includes('Check your inbox');
|
||||
|
||||
// 方法2: 检查按钮是否被禁用
|
||||
const button = document.querySelector('button');
|
||||
const buttonDisabled = button && button.disabled;
|
||||
|
||||
// 方法3: 检查是否还有"verify that you are human"文本
|
||||
const stillOnVerifyPage = document.body.textContent.includes('verify that you are human');
|
||||
|
||||
return {
|
||||
hasCheckInbox,
|
||||
buttonDisabled,
|
||||
stillOnVerifyPage
|
||||
};
|
||||
});
|
||||
|
||||
logger.info(this.siteName, `[Cloudflare] 页面状态: inbox=${checkResult.hasCheckInbox}, buttonDisabled=${checkResult.buttonDisabled}, stillVerify=${checkResult.stillOnVerifyPage}`);
|
||||
|
||||
// 判断是否成功跳转
|
||||
if (checkResult.hasCheckInbox || (!checkResult.stillOnVerifyPage && checkResult.buttonDisabled)) {
|
||||
pageChanged = true;
|
||||
logger.success(this.siteName, '[Cloudflare] ✓ 已进入验证码页面');
|
||||
break;
|
||||
}
|
||||
|
||||
// 如果还在验证页面,继续等待
|
||||
logger.info(this.siteName, '[Cloudflare] 页面未跳转,继续尝试...');
|
||||
await this.human.randomDelay(2000, 3000);
|
||||
} else {
|
||||
logger.warn(this.siteName, '[Cloudflare] 未找到可点击的按钮');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pageChanged) {
|
||||
logger.warn(this.siteName, `[Cloudflare] ${maxAttempts}次尝试后页面仍未跳转`);
|
||||
}
|
||||
|
||||
// 额外等待确保页面稳定
|
||||
await this.human.randomDelay(2000, 3000);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
logger.warn(this.siteName, `[Cloudflare] 点击按钮失败: ${e.message}`);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user