Skip to content

Commit

Permalink
chore: .
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Jul 9, 2024
1 parent 33a1606 commit 6bc3815
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/cron_bypassCF.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Scheduled Node.js CI

on:
# schedule:
# # 每天 UTC 时间 18:00 运行
# - cron: "0 18 * * *"
workflow_dispatch: # 添加这行以允许手动触发

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20 # 设置作业超时时间为20分钟

strategy:
matrix:
node-version: [20.x] # 选择你需要的 Node.js 版本
env:
# 在作业级别设置环境变量
USERNAMES: ${{ secrets.USERNAMES }}
PASSWORDS: ${{ secrets.PASSWORDS }}

steps:
- uses: actions/checkout@v3 # 检出你的仓库
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm install
sudo apt install -y xvfb
- name: Start Xvfb
run: |
# 启动 Xvfb 在 Display :99
sudo Xvfb :99 &
export DISPLAY=:99
- name: Run a script
run: node pteer.js # 替换为你想运行的脚本的实际名称
4 changes: 3 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ node .\pteer.js

```sh
sudo apt-get update
wget -qO- https://deb.nodesource.com/setup_20.x | sudo -E bash - #安装node的最新源
sudo apt install nodejs npm -y
sudo apt-get install -y wget unzip fontconfig locales gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
sudo apt-get install -y wget unzip fontconfig locales gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget xvfb
sudo apt install chromium-browser

```

Expand Down
8 changes: 3 additions & 5 deletions bypasscf.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ async function launchBrowserForUser(username, password) {
// await page.goto(loginUrl);
//登录操作
// await page.goto(loginUrl, { waitUntil: "networkidle0" });
await navigatePage(loginUrl, page, browser);
await delayClick(8000)
await navigatePage(loginUrl, page, browser);
await delayClick(8000);
// 设置额外的 headers
await page.setExtraHTTPHeaders({
"accept-language": "en-US,en;q=0.9",
Expand Down Expand Up @@ -120,9 +120,7 @@ async function launchBrowserForUser(username, password) {
// await page.reload();
}
});
// await page.waitForNavigation({ waitUntil: "networkidle0" });
// //登录操作
// await page.goto(loginUrl, { waitUntil: "networkidle0" });
console.log("登录操作");
// 使用XPath查询找到包含"登录"或"login"文本的按钮
await page.evaluate(() => {
Expand Down Expand Up @@ -204,7 +202,7 @@ async function login(page, username, password) {
await delayClick(500); // 模拟在点击登录按钮前的短暂停顿
try {
await Promise.all([
// page.waitForNavigation({ waitUntil: "domcontentloaded" }), // 等待 页面跳转 DOMContentLoaded 事件
// page.waitForNavigation({ waitUntil: "domcontentloaded" }), // 等待 页面跳转 DOMContentLoaded 事件
page.click("#login-button"), // 点击登录按钮触发跳转
]); //注意如果登录失败,这里会一直等待跳转,导致脚本执行失败
} catch (error) {
Expand Down

0 comments on commit 6bc3815

Please sign in to comment.