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 password = email && (cfg.gog_password || await prompt({ type: 'password', message: 'Enter 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_password').fill(password);
|
||||
await iframe.locator('#login_login').click();
|
||||
|
|
@ -103,9 +107,7 @@ try {
|
|||
|
||||
const banner = page.locator('#giveaway');
|
||||
const hasGiveaway = await banner.count();
|
||||
if (!hasGiveaway) {
|
||||
console.log('Currently no free giveaway!');
|
||||
} else {
|
||||
if (hasGiveaway) {
|
||||
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 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("Promotions and hot deals") label').uncheck();
|
||||
}
|
||||
} else {
|
||||
console.log('Currently no free giveaway!');
|
||||
}
|
||||
} catch (error) {
|
||||
process.exitCode ||= 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue