Skip to content

Commit 726db45

Browse files
committed
Current free game title in blue
1 parent 04d1b7e commit 726db45

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

epic-games.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra
22
import { authenticator } from 'otplib';
3+
import chalk from 'chalk';
34
import path from 'path';
45
import { existsSync, writeFileSync, appendFileSync } from 'fs';
56
import { resolve, jsonDb, datetime, stealth, filenamify, prompt, notify, html_game_list, handleSIGINT } from './src/util.js';
@@ -192,7 +193,7 @@ try {
192193
const game_id = page.url().split('/').pop();
193194
const existedInDb = db.data[user][game_id];
194195
db.data[user][game_id] ||= { title, time: datetime(), url: page.url() }; // this will be set on the initial run only!
195-
console.log('Current free game:', title);
196+
console.log('Current free game:', chalk.blue(title));
196197
if (bundle_includes) console.log(' This bundle includes:', bundle_includes);
197198
const notify_game = { title, url, status: 'failed' };
198199
notify_games.push(notify_game); // status is updated below

gog.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra
2+
import chalk from 'chalk';
23
import { resolve, jsonDb, datetime, filenamify, prompt, notify, html_game_list, handleSIGINT } from './src/util.js';
34
import { cfg } from './src/config.js';
45

@@ -102,7 +103,7 @@ try {
102103
const match_all = text.match(/Claim (.*) and don't miss the|Success! (.*) was added to/);
103104
const title = match_all[1] ? match_all[1] : match_all[2];
104105
const url = await banner.locator('a').first().getAttribute('href');
105-
console.log(`Current free game: ${title} - ${url}`);
106+
console.log(`Current free game: ${chalk.blue(title)} - ${url}`);
106107
db.data[user][title] ||= { title, time: datetime(), url };
107108
if (cfg.dryrun) process.exit(1);
108109
// await page.locator('#giveaway:not(.is-loading)').waitFor(); // otherwise screenshot is sometimes with loading indicator instead of game title; #TODO fix, skipped due to timeout, see #240

prime-gaming.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ try {
150150
if (isNew) await p.close();
151151
return daysLeft > cfg.pg_timeLeft;
152152
}
153-
console.log('Number of free unclaimed games (Prime Gaming):', internal.length);
153+
console.log('\nNumber of free unclaimed games (Prime Gaming):', internal.length);
154154
// claim games in internal store
155155
for (const card of internal) {
156156
await card.scrollIntoViewIfNeeded();
157157
const title = await (await card.$('.item-card-details__body__primary')).innerText();
158158
const slug = await (await card.$('a')).getAttribute('href');
159159
const url = 'https://gaming.amazon.com' + slug.split('?')[0];
160-
console.log('Current free game:', title);
160+
console.log('Current free game:', chalk.blue(title));
161161
if (cfg.pg_timeLeft && await skipBasedOnTime(url)) continue;
162162
if (cfg.dryrun) continue;
163163
if (cfg.interactive && !await confirm()) continue;
@@ -168,7 +168,7 @@ try {
168168
// console.log('Image:', img);
169169
await card.screenshot({ path: screenshot('internal', `${filenamify(title)}.png`) });
170170
}
171-
console.log('Number of free unclaimed games (external stores):', external.length);
171+
console.log('\nNumber of free unclaimed games (external stores):', external.length);
172172
// claim games in external/linked stores. Linked: origin.com, epicgames.com; Redeem-key: gog.com, legacygames.com, microsoft
173173
const external_info = [];
174174
for (const card of external) { // need to get data incl. URLs in this loop and then navigate in another, otherwise .all() would update after coming back and .elementHandles() like above would lead to error due to page navigation: elementHandle.$: Protocol error (Page.adoptNode)
@@ -180,7 +180,7 @@ try {
180180
}
181181
// external_info = [ { title: 'Fallout 76 (XBOX)', url: 'https://gaming.amazon.com/fallout-76-xbox-fgwp/dp/amzn1.pg.item.9fe17d7b-b6c2-4f58-b494-cc4e79528d0b?ingress=amzn&ref_=SM_Fallout76XBOX_S01_FGWP_CRWN' } ];
182182
for (const { title, url } of external_info) {
183-
console.log('Current free game:', title); // , url);
183+
console.log('Current free game:', chalk.blue(title)); // , url);
184184
await page.goto(url, { waitUntil: 'domcontentloaded' });
185185
if (cfg.debug) await page.pause();
186186
const item_text = await page.innerText('[data-a-target="DescriptionItemDetails"]');

0 commit comments

Comments
 (0)