Skip to content

Commit

Permalink
pg: use chalk to color game codes blue, closes #250
Browse files Browse the repository at this point in the history
  • Loading branch information
vogler committed Dec 19, 2023
1 parent 76597f4 commit 3c15252
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
53 changes: 36 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"type": "module",
"dependencies": {
"chalk": "^5.3.0",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"enquirer": "^2.4.1",
Expand Down
5 changes: 3 additions & 2 deletions prime-gaming.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra
import { authenticator } from 'otplib';
import chalk from 'chalk';
import { resolve, jsonDb, datetime, stealth, filenamify, prompt, confirm, notify, html_game_list, handleSIGINT } from './util.js';
import { cfg } from './config.js';

Expand Down Expand Up @@ -182,7 +183,7 @@ try {
};
if (store in redeem) { // did not work for linked origin: && !await page.locator('div:has-text("Successfully Claimed")').count()
const code = await Promise.any([page.inputValue('input[type="text"]'), page.textContent('[data-a-target="ClaimStateClaimCodeContent"]').then(s => s.replace('Your code: ', ''))]); // input: Legacy Games; text: gog.com
console.log(' Code to redeem game:', code);
console.log(' Code to redeem game:', chalk.blue(code));
if (store == 'legacy games') { // may be different URL like https://legacygames.com/primeday/puzzleoftheyear/
redeem[store] = await (await page.$('li:has-text("Click here") a')).getAttribute('href'); // full text: Click here to enter your redemption code.
}
Expand Down Expand Up @@ -367,7 +368,7 @@ try {
dlc_unlinked[unlinked_store].push(title);
} else {
const code = await page.inputValue('input[type="text"]');
console.log(' Code to redeem game:', code);
console.log(' Code to redeem game:', chalk.blue(code));
db.data[user][title].code = code;
db.data[user][title].status = 'claimed';
// notify_game.status = `<a href="${redeem[store]}">${redeem_action}</a> ${code} on ${store}`;
Expand Down

0 comments on commit 3c15252

Please sign in to comment.