Skip to content

Commit

Permalink
eg: change back to purchase-cta-button from 'aside button', fixes #374
Browse files Browse the repository at this point in the history
  • Loading branch information
vogler committed Aug 29, 2024
1 parent 1f4af79 commit 7279ba0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions epic-games.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ try {
for (const url of urls) {
if (cfg.time) console.time('claim game');
await page.goto(url); // , { waitUntil: 'domcontentloaded' });
const purcahseBtn = page.locator('aside button').first();
const btnText = (await purcahseBtn.innerText()).toLowerCase(); // barrier to block until page is loaded
const purchaseBtn = page.locator('button[data-testid="purchase-cta-button"]').first();
const btnText = (await purchaseBtn.innerText()).toLowerCase(); // barrier to block until page is loaded

// click Continue if 'This game contains mature content recommended only for ages 18+'
if (await page.locator('button:has-text("Continue")').count() > 0) {
Expand All @@ -179,6 +179,7 @@ try {
if (await page.locator('span:text-is("About Bundle")').count()) {
// console.log(' This is a bundle containing: TODO');
title = (await page.locator('span:has-text("Buy"):left-of([data-testid="purchase-cta-button"])').first().innerText()).replace('Buy ', '');
// h1 first didn't exist for bundles but now it does... However h1 would e.g. be 'Fallout® Classic Collection' instead of 'Fallout Classic Collection'
} else {
title = await page.locator('h1').first().innerText();
}
Expand Down Expand Up @@ -206,7 +207,7 @@ try {
urls.push(url); // add add-on itself again
} else { // GET
console.log(' Not in library yet! Click GET.');
await purcahseBtn.click({ delay: 11 }); // got stuck here without delay (or mouse move), see #75, 1ms was also enough
await purchaseBtn.click({ delay: 11 }); // got stuck here without delay (or mouse move), see #75, 1ms was also enough

// click Continue if 'Device not supported. This product is not compatible with your current device.' - avoided by Windows userAgent?
page.click('button:has-text("Continue")').catch(_ => { }); // needed since change from Chromium to Firefox?
Expand Down

0 comments on commit 7279ba0

Please sign in to comment.