mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 02:57:34 +00:00
feat: add incognito mode (#534)
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
@@ -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` |
|
||||
|
||||
@@ -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),
|
||||
|
||||
+5
-2
@@ -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 */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user