From 9285b520172d78f1fac678b64579a9db69b513b6 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Sun, 25 May 2025 16:31:12 +0200 Subject: [PATCH] respect INTERACTIVE=1 in gog and eg, not just pg --- epic-games.js | 3 ++- gog.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/epic-games.js b/epic-games.js index 500e6cf..603bc33 100644 --- a/epic-games.js +++ b/epic-games.js @@ -3,7 +3,7 @@ import { authenticator } from 'otplib'; import chalk from 'chalk'; import path from 'path'; import { existsSync, writeFileSync, appendFileSync } from 'fs'; -import { resolve, jsonDb, datetime, stealth, filenamify, prompt, notify, html_game_list, handleSIGINT } from './src/util.js'; +import { resolve, jsonDb, datetime, stealth, filenamify, prompt, confirm, notify, html_game_list, handleSIGINT } from './src/util.js'; import { cfg } from './src/config.js'; const screenshot = (...a) => resolve(cfg.dir.screenshots, 'epic-games', ...a); @@ -260,6 +260,7 @@ try { if (cfg.time) console.timeEnd('claim game'); continue; } + if (cfg.interactive && !await confirm()) continue; // Playwright clicked before button was ready to handle event, https://github.com/vogler/free-games-claimer/issues/84#issuecomment-1474346591 await iframe.locator('button:has-text("Place Order"):not(:has(.payment-loading--loading))').click({ delay: 11 }); diff --git a/gog.js b/gog.js index 6269fc2..11fcfec 100644 --- a/gog.js +++ b/gog.js @@ -1,6 +1,6 @@ import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra import chalk from 'chalk'; -import { resolve, jsonDb, datetime, filenamify, prompt, notify, html_game_list, handleSIGINT } from './src/util.js'; +import { resolve, jsonDb, datetime, filenamify, prompt, confirm, notify, html_game_list, handleSIGINT } from './src/util.js'; import { cfg } from './src/config.js'; const screenshot = (...a) => resolve(cfg.dir.screenshots, 'gog', ...a); @@ -106,6 +106,7 @@ try { console.log(`Current free game: ${chalk.blue(title)} - ${url}`); db.data[user][title] ||= { title, time: datetime(), url }; if (cfg.dryrun) process.exit(1); + if (cfg.interactive && !await confirm()) process.exit(0); // 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 await banner.screenshot({ path: screenshot(`${filenamify(title)}.png`) }); // overwrites every time - only keep first?