diff --git a/README.md b/README.md index a127d0a0a8..dbb0041e33 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Here is a list of variables that you can use to customize your newly copied `.en | `EMAIL_TO` | Destination Email | Defaults to username if not set. Can be comma separated | | `EMAIL_USERNAME` | Gmail address | E.g.: `jensen.robbed.us@gmail.com` | | `HEADLESS` | Puppeteer to run headless or not | Debugging related, default: `true` | +| `INCOGNITO` | Puppeteer to run incognito or not | Debugging related, default: `false` | | `IN_STOCK_WAIT_TIME` | Time to wait between requests to the same link if it has that card in stock | In seconds, default: `0` | | `LOG_LEVEL` | [Logging levels](https://github.com/winstonjs/winston#logging-levels) | Debugging related, default: `info` | | `LOW_BANDWIDTH` | Blocks images/fonts to reduce traffic | Disables ad blocker, default: `false` | diff --git a/src/config.ts b/src/config.ts index 0c47fa7d2c..27d17fcafc 100644 --- a/src/config.ts +++ b/src/config.ts @@ -109,6 +109,7 @@ function envOrNumberMax(environmentMin: string | undefined, environmentMax: stri const browser = { isHeadless: envOrBoolean(process.env.HEADLESS), + isIncognito: envOrBoolean(process.env.INCOGNITO, false), isTrusted: envOrBoolean(process.env.BROWSER_TRUSTED, false), lowBandwidth: envOrBoolean(process.env.LOW_BANDWIDTH, false), maxBackoff: envOrNumberMax(process.env.PAGE_BACKOFF_MIN, process.env.PAGE_BACKOFF_MAX, 3600000), diff --git a/src/store/lookup.ts b/src/store/lookup.ts index e018b0828c..3d41ffde15 100644 --- a/src/store/lookup.ts +++ b/src/store/lookup.ts @@ -35,7 +35,8 @@ async function lookup(browser: Browser, store: Store) { continue; } - const page = await browser.newPage(); + const context = (config.browser.isIncognito ? await browser.createIncognitoBrowserContext() : browser.defaultBrowserContext()); + const page = (config.browser.isIncognito ? await context.newPage() : await browser.newPage()); page.setDefaultNavigationTimeout(config.page.timeout); await page.setUserAgent(config.page.userAgent); @@ -62,8 +63,10 @@ async function lookup(browser: Browser, store: Store) { // used to detect bot traffic, it introduces a 5 second page delay // before redirecting to the next page await processBackoffDelay(store, link, statusCode); - await closePage(page); + if (config.browser.isIncognito) { + await context.close(); + } } /* eslint-enable no-await-in-loop */ }