Skip to content

Commit 2f6c228

Browse files
committed
1.1.1: 根據 pixai 畫面改動,修改檢查元素語法
修正重試邏輯 添加認領欄位文字類型,以符合 pixai 任何語系狀況
1 parent 3bae9dd commit 2f6c228

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

app.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,28 @@ async function loginAndScrape(url, username, password, isDocker, headless) {
5252
console.error("訪問 URL 失敗:", error);
5353
tryCount++;
5454
if (tryCount <= tryCountMax) {
55-
return loginAndScrape(url, username, password, isDocker, headless);
55+
return await loginAndScrape(url, username, password, isDocker, headless);
5656
} else {
5757
throw new Error("重試訪問 URL 失敗");
5858
}
5959
}
6060

6161
// 點擊取消初始畫面
6262
try {
63-
await page.waitForSelector('div[id="root"] > div > div > button');
64-
await page.click('div[id="root"] > div > div > button');
63+
// 1.1.1 舊版畫面
64+
// await page.waitForSelector('div[id="root"] > div > div > button');
65+
// await page.click('div[id="root"] > div > div > button');
66+
await page.waitForSelector(
67+
'div[id="root"] > div > div > div > div > form > div > div button:last-of-type'
68+
);
69+
await page.click(
70+
'div[id="root"] > div > div > div > div > form > div > div button:last-of-type'
71+
);
6572
} catch (error) {
6673
console.error("點擊取消初始畫面失敗:", error);
6774
tryCount++;
6875
if (tryCount <= tryCountMax) {
69-
return loginAndScrape(url, username, password, isDocker, headless);
76+
return await loginAndScrape(url, username, password, isDocker, headless);
7077
} else {
7178
throw new Error("重試點擊取消初始畫面失敗");
7279
}
@@ -79,7 +86,7 @@ async function loginAndScrape(url, username, password, isDocker, headless) {
7986
console.error("登入失敗:", error);
8087
tryCount++;
8188
if (tryCount <= tryCountMax) {
82-
return loginAndScrape(url, username, password, isDocker, headless);
89+
return await loginAndScrape(url, username, password, isDocker, headless);
8390
} else {
8491
throw new Error("重試登入失敗");
8592
}
@@ -92,7 +99,7 @@ async function loginAndScrape(url, username, password, isDocker, headless) {
9299
console.error("展開使用者列表失敗:", error);
93100
tryCount++;
94101
if (tryCount <= tryCountMax) {
95-
return loginAndScrape(url, username, password, isDocker, headless);
102+
return await loginAndScrape(url, username, password, isDocker, headless);
96103
} else {
97104
throw new Error("重試展開使用者列表失敗");
98105
}
@@ -105,7 +112,7 @@ async function loginAndScrape(url, username, password, isDocker, headless) {
105112
console.error("點擊檔案列表失敗:", error);
106113
tryCount++;
107114
if (tryCount <= tryCountMax) {
108-
return loginAndScrape(url, username, password, isDocker, headless);
115+
return await loginAndScrape(url, username, password, isDocker, headless);
109116
} else {
110117
throw new Error("重試點擊檔案列表失敗");
111118
}
@@ -118,7 +125,7 @@ async function loginAndScrape(url, username, password, isDocker, headless) {
118125
console.error("領取每日獎勵失敗:", error);
119126
tryCount++;
120127
if (tryCount <= tryCountMax) {
121-
return loginAndScrape(url, username, password, isDocker, headless);
128+
return await loginAndScrape(url, username, password, isDocker, headless);
122129
} else {
123130
throw new Error("重試領取每日獎勵失敗");
124131
}
@@ -291,7 +298,12 @@ async function claimCredit(page) {
291298
await delay(300);
292299

293300
// 確認是不是 "Claimed"
294-
if (updatedClaimBtnText.toLowerCase() === "claimed") {
301+
if (
302+
updatedClaimBtnText.toLowerCase() === "claimed" ||
303+
updatedClaimBtnText.toLowerCase() === "已認領" ||
304+
updatedClaimBtnText.toLowerCase() === "已认领" ||
305+
updatedClaimBtnText.toLowerCase() === "申請済み"
306+
) {
295307
console.log("領取成功");
296308
isClaimed = true;
297309
continue checkIsClaimed;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "auto-pixai",
3-
"version": "1.0.1",
3+
"version": "1.1.1",
44
"description": "自動領取pixai.art獎勵",
55
"main": "app.js",
66
"scripts": {

0 commit comments

Comments
 (0)