Skip to content

Commit

Permalink
pg: dlc: grouped list of dlcs per unlinked store, #180
Browse files Browse the repository at this point in the history
  • Loading branch information
vogler committed Aug 17, 2023
1 parent 5c8f8fc commit e794a33
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions prime-gaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ try {
})));
// console.log(dlcs);

const dlc_unlinked = {};
for (const dlc of dlcs) {
const title = `${dlc.game} - ${dlc.title}`;
const url = dlc.url;
Expand All @@ -329,10 +330,18 @@ try {
page.click('button:has-text("Continue")').catch(_ => { });
const linkAccountModal = page.locator('[data-a-target="LinkAccountModal"]');
const linkAccountButton = linkAccountModal.locator('[data-a-target="LinkAccountButton"]');
let unlinked_store;
if (await linkAccountButton.count()) {
console.error(' Missing account linking:', await linkAccountButton.getAttribute('aria-label'), url);
unlinked_store = await linkAccountButton.getAttribute('aria-label');
unlinked_store = unlinked_store.match(/Link (.*) account/)[1];
} else if(await page.locator('text=Link game account').count()) { // epic-games only?
console.error(' Missing account linking:', await page.locator('button[data-a-target="gms-cta"]').innerText(), url);
console.error(' Missing account linking (epic-games specific button?):', await page.locator('button[data-a-target="gms-cta"]').innerText()); // TODO needed?
unlinked_store = 'epic-games';
}
if (unlinked_store) {
console.error(' Missing account linking:', unlinked_store, url);
dlc_unlinked[unlinked_store] ??= [];
dlc_unlinked[unlinked_store].push(title);
} else {
const code = await page.inputValue('input[type="text"]');
console.log(' Code to redeem game:', code);
Expand All @@ -348,6 +357,7 @@ try {
await page.click('button[data-type="InGameLoot"]');
}
}
console.log('DLC: Unlinked accounts:', dlc_unlinked);
}
} catch (error) {
console.error(error); // .toString()?
Expand Down

0 comments on commit e794a33

Please sign in to comment.