eg: RECORD=1 to recordVideo & recordHar; fixed: recordVideo can't be false
Strangely `recordHar` can be false instead of undefined, but made it symmetric.
This commit is contained in:
parent
7fc0fbc69c
commit
8f174c4bf0
2 changed files with 9 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ 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 },
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ 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: { dir: 'data/videos/' }, // will record a .webm video for each page navigated
|
||||
recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // 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` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools
|
||||
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
|
||||
|
|
@ -45,6 +46,12 @@ 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue