Skip to content

Commit

Permalink
fix: Windows需要等待cf的完成
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Aug 4, 2024
1 parent 7c2cb68 commit bdcbeaf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ node .\bypasscf.js

## 使用方法三:GitHub Action 每天 0 点阅读

(可自行修改启动时间和持续时间,代码.github\workflows\cron_read.yaml)
(可自行修改启动时间和持续时间,代码.github\workflows\cron_bypassCF.yaml)

### 1. fork 仓库

Expand Down
18 changes: 17 additions & 1 deletion bypasscf.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,24 @@ async function login(page, username, password) {
async function navigatePage(url, page, browser) {
await page.goto(url, { waitUntil: "domcontentloaded" }); //如果使用默认的load,linux下页面会一直加载导致无法继续执行

// const startTime = Date.now(); // 记录开始时间
const startTime = Date.now(); // 记录开始时间
let pageTitle = await page.title(); // 获取当前页面标题

while (pageTitle.includes("Just a moment")) {
console.log("The page is under Cloudflare protection. Waiting...");

await delayClick(2000); // 每次检查间隔2秒

// 重新获取页面标题
pageTitle = await page.title();

// 检查是否超过15秒
if (Date.now() - startTime > 35000) {
console.log("Timeout exceeded, aborting actions.");
await browser.close();
return; // 超时则退出函数
}
}
console.log("页面标题:", pageTitle);
}

Expand Down

0 comments on commit bdcbeaf

Please sign in to comment.