From d9be3fe6183eaa9694b186c7a75e1f28bb31dace Mon Sep 17 00:00:00 2001 From: admon84 Date: Sun, 20 Sep 2020 13:56:47 -0600 Subject: [PATCH] feat: custom user agent (#121) Co-authored-by: Jef LeCompte --- .env-example | 1 + README.md | 3 +++ src/config.ts | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.env-example b/.env-example index 9ecce2c..6a5d422 100644 --- a/.env-example +++ b/.env-example @@ -21,3 +21,4 @@ STORES="bestbuy,bandh,nvidia" SCREENSHOT="true" TELEGRAM_ACCESS_TOKEN="" TELEGRAM_CHAT_ID="1234" +USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" diff --git a/README.md b/README.md index 668b4c2..9e9de93 100644 --- a/README.md +++ b/README.md @@ -85,9 +85,12 @@ Here is a list of variables that you can use to customize your newly copied `.en | `SCREENSHOT` | Capture screenshot of page if a card is found | Default: `true` | | `TELEGRAM_ACCESS_TOKEN` | Telegram access token | | `TELEGRAM_CHAT_ID` | Telegram chat ID | +| `USER_AGENT` | Custom User-Agent header for HTTP requests; optional | > :point_right: If you have multi-factor authentication (MFA), you will need to create an [app password](https://myaccount.google.com/apppasswords) and use this instead of your Gmail password. +> :point_right: You can find your computer's user agent by [searching google for "my user agent"](http://google.com/search?q=my+user+agent) + > :point_right: You can test your notification configuration by running `npm run test:notification`. #### Supported stores diff --git a/src/config.ts b/src/config.ts index 9b9c3c1..dd4ce1e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -55,7 +55,7 @@ const page = { width: 1920, height: 1080, navigationTimeout: Number(process.env.PAGE_TIMEOUT ?? 30000), - userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' + userAgent: process.env.USER_AGENT ?? 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' }; const store = {