diff --git a/.env-example b/.env-example index 8f73f37..8f97681 100644 --- a/.env-example +++ b/.env-example @@ -28,6 +28,8 @@ PAGE_BACKOFF_MIN="" PAGE_BACKOFF_MAX="" PAGE_SLEEP_MIN="" PAGE_SLEEP_MAX="" +PROXY_ADDRESS="" +PROXY_PORT="" SHOW_ONLY_BRANDS="" SHOW_ONLY_MODELS="" SHOW_ONLY_SERIES="" diff --git a/README.md b/README.md index 4e6bf22..a273f42 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ Here is a list of variables that you can use to customize your newly copied `.en | `PAGE_BACKOFF_MAX` | Maximum backoff time between retrying requests for the same store when a forbidden response is received | Default: `3600000` | | `PAGE_SLEEP_MIN` | Minimum sleep time between queries of the same store | In milliseconds, default: `5000` | | `PAGE_SLEEP_MAX` | Maximum sleep time between queries of the same store | In milliseconds, default: `10000` | +| `PROXY_ADDRESS` | IP Address or fqdn of proxy server | +| `PROXY_PORT` | TCP Port number on which the proxy is listening for connections | Default: `80` | | `SCREENSHOT` | Capture screenshot of page if a card is found | Default: `true` | | `SHOW_ONLY_BRANDS` | Filter to show specified brands | Comma separated, e.g.: `evga,zotac` | | `SHOW_ONLY_MODELS` | Filter to show specified models | Comma separated, e.g.: `founders edition,rog strix` | diff --git a/src/config.ts b/src/config.ts index 7f2ac83..1fa28f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -133,6 +133,11 @@ const page = { width: 1920 }; +const proxy = { + address: envOrString(process.env.PROXY_ADDRESS, ''), + port: envOrNumber(process.env.PROXY_PORT, 80) +}; + const store = { country: envOrString(process.env.COUNTRY, 'usa'), microCenterLocation: envOrString(process.env.MICROCENTER_LOCATION, 'web'), @@ -148,5 +153,6 @@ export const Config = { notifications, nvidia, page, + proxy, store }; diff --git a/src/index.ts b/src/index.ts index 0fe2d8d..4336f76 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,6 +36,11 @@ async function main() { args.push('--disable-setuid-sandbox'); } + // Add the address of the proxy server if defined + if (Config.proxy.address) { + args.push(`--proxy-server=http://${Config.proxy.address}:${Config.proxy.port}`); + } + const browser = await puppeteer.launch({ args, defaultViewport: {