fix eslint errors
This commit is contained in:
parent
1dbbfaf3ad
commit
6d9a3ad140
7 changed files with 59 additions and 51 deletions
|
|
@ -131,6 +131,8 @@ try {
|
|||
// bottom to top: oldest to newest games
|
||||
internal.reverse();
|
||||
external.reverse();
|
||||
// TODO just use async, no need for Promise? -> type error since now Page | bool instead of any
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
const sameOrNewPage = async url => new Promise(async (resolve, _reject) => {
|
||||
const isNew = page.url() != url;
|
||||
let p = page;
|
||||
|
|
@ -145,11 +147,11 @@ try {
|
|||
const [p, isNew] = await sameOrNewPage(url);
|
||||
const dueDateOrg = await p.locator('.availability-date .tw-bold').innerText();
|
||||
const dueDate = new Date(Date.parse(dueDateOrg + ' 17:00'));
|
||||
const daysLeft = (dueDate.getTime() - Date.now())/1000/60/60/24;
|
||||
const daysLeft = (dueDate.getTime() - Date.now()) / 1000 / 60 / 60 / 24;
|
||||
console.log(' ', await p.locator('.availability-date').innerText(), '->', daysLeft.toFixed(2));
|
||||
if (isNew) await p.close();
|
||||
return daysLeft > cfg.pg_timeLeft;
|
||||
}
|
||||
};
|
||||
console.log('\nNumber of free unclaimed games (Prime Gaming):', internal.length);
|
||||
// claim games in internal store
|
||||
for (const card of internal) {
|
||||
|
|
@ -300,7 +302,7 @@ try {
|
|||
if (j?.events?.cart.length && j.events.cart[0]?.data?.reason == 'UserAlreadyOwnsContent') {
|
||||
redeem_action = 'already redeemed';
|
||||
console.error(' error: UserAlreadyOwnsContent');
|
||||
} else if (true) { // TODO what's returned on success?
|
||||
} else { // TODO what's returned on success?
|
||||
redeem_action = 'redeemed';
|
||||
db.data[user][title].status = 'claimed and redeemed?';
|
||||
console.log(' Redeemed successfully? Please report if not in https://github.com/vogler/free-games-claimer/issues/5');
|
||||
|
|
@ -366,7 +368,7 @@ try {
|
|||
await loot.waitFor();
|
||||
|
||||
process.stdout.write('Loading all DLCs on page...');
|
||||
await scrollUntilStable(() => loot.locator('[data-a-target="item-card"]').count())
|
||||
await scrollUntilStable(() => loot.locator('[data-a-target="item-card"]').count());
|
||||
|
||||
console.log('\nNumber of already claimed DLC:', await loot.locator('p:has-text("Collected")').count());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue