diff --git a/config.js b/config.js index 32974e1..33016ca 100644 --- a/config.js +++ b/config.js @@ -6,7 +6,6 @@ dotenv.config({ path: 'data/config.env' }); // loads env vars from file - will n // Options - also see table in README.md export const cfg = { debug: process.env.PWDEBUG == '1', // runs non-headless and opens https://playwright.dev/docs/inspector - record: process.env.RECORD == '1', // `recordHar` (network) + `recordVideo` dryrun: process.env.DRYRUN == '1', // don't claim anything show: process.env.SHOW == '1', // run non-headless get headless() { return !this.debug && !this.show }, diff --git a/epic-games.js b/epic-games.js index a107a1f..c38bdfc 100644 --- a/epic-games.js +++ b/epic-games.js @@ -27,8 +27,7 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO Windows UA enough to avoid 'device not supported'? update if browser is updated? // userAgent for firefox: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0 locale: "en-US", // ignore OS locale to be sure to have english text for locators - recordVideo: cfg.record && { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } }, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 - recordHar: cfg.record && { path: `data/record/eg-${datetime()}.har` }, // will record a HAR file with network requests and responses; can be imported in Chrome devtools + // recordVideo: { dir: 'data/videos/' }, // will record a .webm video for each page navigated args: [ // https://peter.sh/experiments/chromium-command-line-switches // don't want to see bubble 'Restore pages? Chrome didn't shut down correctly.' // '--restore-last-session', // does not apply for crash/killed @@ -46,12 +45,6 @@ if (!cfg.debug) context.setDefaultTimeout(cfg.timeout); const page = context.pages().length ? context.pages()[0] : await context.newPage(); // should always exist // console.debug('userAgent:', await page.evaluate(() => navigator.userAgent)); -if (cfg.record && cfg.debug) { - // const filter = _ => true; - const filter = r => r.url().includes('store.epicgames.com'); - page.on('request', request => filter(request) && console.log('>>', request.method(), request.url())); - page.on('response', response => filter(response) && console.log('<<', response.status(), response.url())); -} const notify_games = []; let user;