Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception when trying to claim a bundle game in Epic Store #321

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion epic-games.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,22 @@ try {
await page.waitForTimeout(2000);
}

const title = await page.locator('h1').first().innerText();
const game_id = page.url().split('/').pop();
const page_url_array = page.url().split('/');
const page_type = page_url_array[page_url_array.length - 2];

// Detect type of page: blundle or single game
// When bundle, title is set as game_id
let title;
if(page_type == 'bundles'){
console.log('branch: ' + 'bundles');
title = game_id;
} else if(page_type == 'p'){
console.log('branch: ' + 'p');
title = await page.locator('h1').first().innerText();
}else
console.log('Uknown page type');

db.data[user][game_id] ||= { title, time: datetime(), url: page.url() }; // this will be set on the initial run only!
console.log('Current free game:', title);
const notify_game = { title, url, status: 'failed' };
Expand Down