Skip to content

Commit fef5b97

Browse files
committed
eg: wait for purchaseBtn, without it didn't detect bundle as already claimed
1 parent 292aada commit fef5b97

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

epic-games.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ try {
157157
if (cfg.time) console.time('claim game');
158158
await page.goto(url); // , { waitUntil: 'domcontentloaded' });
159159
const purchaseBtn = page.locator('button[data-testid="purchase-cta-button"]').first();
160+
await purchaseBtn.waitFor();
160161
const btnText = (await purchaseBtn.innerText()).toLowerCase(); // barrier to block until page is loaded
161162

162163
// click Continue if 'This game contains mature content recommended only for ages 18+'
@@ -212,7 +213,7 @@ try {
212213
urls.push(baseUrl); // add base game to the list of games to claim
213214
urls.push(url); // add add-on itself again
214215
} else { // GET
215-
console.log(' Not in library yet! Click GET.');
216+
console.log(' Not in library yet! Click', btnText);
216217
await purchaseBtn.click({ delay: 11 }); // got stuck here without delay (or mouse move), see #75, 1ms was also enough
217218

218219
// click Continue if 'Device not supported. This product is not compatible with your current device.' - avoided by Windows userAgent?
@@ -281,7 +282,7 @@ try {
281282
console.error(' Failed to challenge captcha, please try again later.');
282283
await notify('epic-games: failed to challenge captcha. Please check.');
283284
}).catch(_ => { });
284-
await page.locator('text=Thanks for your order!').waitFor({ state: 'attached' }); // TODO Bundle: got stuck here
285+
await page.locator('text=Thanks for your order!').waitFor({ state: 'attached' }); // TODO Bundle: got stuck here, but normal game now as well
285286
db.data[user][game_id].status = 'claimed';
286287
db.data[user][game_id].time = datetime(); // claimed time overwrites failed/dryrun time
287288
console.log(' Claimed successfully!');

0 commit comments

Comments
 (0)