fix: resolve remaining sonar findings
This commit is contained in:
parent
5e0c5263ca
commit
2bc8e958d2
3 changed files with 26 additions and 12 deletions
12
gog.js
12
gog.js
|
|
@ -56,7 +56,11 @@ try {
|
||||||
const email = cfg.gog_email || await prompt({ message: 'Enter email' });
|
const email = cfg.gog_email || await prompt({ message: 'Enter email' });
|
||||||
const password = email && (cfg.gog_password || await prompt({ type: 'password', message: 'Enter password' }));
|
const password = email && (cfg.gog_password || await prompt({ type: 'password', message: 'Enter password' }));
|
||||||
if (email && password) {
|
if (email && password) {
|
||||||
iframe.locator('a[href="/logout"]').click().catch(_ => { }); // Click 'Change account' (email from previous login is set in some cookie)
|
try {
|
||||||
|
await iframe.locator('a[href="/logout"]').click(); // Click 'Change account' (email from previous login is set in some cookie)
|
||||||
|
} catch {
|
||||||
|
// link not present, continue with login flow
|
||||||
|
}
|
||||||
await iframe.locator('#login_username').fill(email);
|
await iframe.locator('#login_username').fill(email);
|
||||||
await iframe.locator('#login_password').fill(password);
|
await iframe.locator('#login_password').fill(password);
|
||||||
await iframe.locator('#login_login').click();
|
await iframe.locator('#login_login').click();
|
||||||
|
|
@ -103,9 +107,7 @@ try {
|
||||||
|
|
||||||
const banner = page.locator('#giveaway');
|
const banner = page.locator('#giveaway');
|
||||||
const hasGiveaway = await banner.count();
|
const hasGiveaway = await banner.count();
|
||||||
if (!hasGiveaway) {
|
if (hasGiveaway) {
|
||||||
console.log('Currently no free giveaway!');
|
|
||||||
} else {
|
|
||||||
const text = await page.locator('.giveaway__content-header').innerText();
|
const text = await page.locator('.giveaway__content-header').innerText();
|
||||||
const match_all = text.match(/Claim (.*) and don't miss the|Success! (.*) was added to/);
|
const match_all = text.match(/Claim (.*) and don't miss the|Success! (.*) was added to/);
|
||||||
const title = match_all[1] ? match_all[1] : match_all[2];
|
const title = match_all[1] ? match_all[1] : match_all[2];
|
||||||
|
|
@ -146,6 +148,8 @@ try {
|
||||||
await page.locator('li:has-text("Marketing communications through Trusted Partners") label').uncheck();
|
await page.locator('li:has-text("Marketing communications through Trusted Partners") label').uncheck();
|
||||||
await page.locator('li:has-text("Promotions and hot deals") label').uncheck();
|
await page.locator('li:has-text("Promotions and hot deals") label').uncheck();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Currently no free giveaway!');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
process.exitCode ||= 1;
|
process.exitCode ||= 1;
|
||||||
|
|
|
||||||
|
|
@ -433,13 +433,13 @@ try {
|
||||||
}
|
}
|
||||||
// Disabled CTA (e.g., needs linking or not available)
|
// Disabled CTA (e.g., needs linking or not available)
|
||||||
if (await disabledCTA.count()) {
|
if (await disabledCTA.count()) {
|
||||||
if (store !== 'epic-games') {
|
if (store === 'epic-games') {
|
||||||
|
console.log(' CTA disabled for epic-games, will still try to link/claim.');
|
||||||
|
} else {
|
||||||
console.log(' CTA is disabled, skipping (likely needs linking/not available).');
|
console.log(' CTA is disabled, skipping (likely needs linking/not available).');
|
||||||
notify_game.status = 'disabled';
|
notify_game.status = 'disabled';
|
||||||
db.data[user][title] ||= { title, time: datetime(), url, store, status: 'disabled' };
|
db.data[user][title] ||= { title, time: datetime(), url, store, status: 'disabled' };
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
console.log(' CTA disabled for epic-games, will still try to link/claim.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (store == 'luna') {
|
if (store == 'luna') {
|
||||||
|
|
@ -664,13 +664,19 @@ try {
|
||||||
await page.goto(url, { waitUntil: 'domcontentloaded' });
|
await page.goto(url, { waitUntil: 'domcontentloaded' });
|
||||||
// most games have a button 'Get in-game content'
|
// most games have a button 'Get in-game content'
|
||||||
// epic-games: Fall Guys: Claim -> Continue -> Go to Epic Games (despite account linked and logged into epic-games) -> not tied to account but via some cookie?
|
// epic-games: Fall Guys: Claim -> Continue -> Go to Epic Games (despite account linked and logged into epic-games) -> not tied to account but via some cookie?
|
||||||
|
const claimAndContinue = async () => {
|
||||||
|
await page.click('.tw-button:has-text("Claim")');
|
||||||
|
try {
|
||||||
|
await page.click('button:has-text("Continue")');
|
||||||
|
} catch {
|
||||||
|
// continue button not always present
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const claimOptions = [
|
const claimOptions = [
|
||||||
page.click('.tw-button:has-text("Get in-game content")'),
|
page.click('.tw-button:has-text("Get in-game content")'),
|
||||||
page.click('.tw-button:has-text("Claim your gift")'),
|
page.click('.tw-button:has-text("Claim your gift")'),
|
||||||
(async () => {
|
claimAndContinue(),
|
||||||
await page.click('.tw-button:has-text("Claim")');
|
|
||||||
await page.click('button:has-text("Continue")').catch(() => {});
|
|
||||||
})(),
|
|
||||||
];
|
];
|
||||||
await Promise.any(claimOptions);
|
await Promise.any(claimOptions);
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,11 @@ try {
|
||||||
console.log(`Signed in as ${user}`);
|
console.log(`Signed in as ${user}`);
|
||||||
db.data[user] ||= {};
|
db.data[user] ||= {};
|
||||||
|
|
||||||
page.locator('button:has-text("Accept All Cookies")').click().catch(_ => { });
|
try {
|
||||||
|
await page.locator('button:has-text("Accept All Cookies")').click();
|
||||||
|
} catch {
|
||||||
|
// button may not be present
|
||||||
|
}
|
||||||
|
|
||||||
const ids = [];
|
const ids = [];
|
||||||
for (const p of await page.locator('article.asset').all()) {
|
for (const p of await page.locator('article.asset').all()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue