Skip to content

Commit

Permalink
fix: screenshot size, add screenshot config setting (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
admon84 committed Sep 19, 2020
1 parent 971fec2 commit 7cfc7c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .env.example
Expand Up @@ -7,4 +7,5 @@ SLACK_CHANNEL="SlackChannelName"
SLACK_TOKEN="slack-token"
STORES="bestbuy,bandh,nvidia"
PHONE_NUMBER="1234567890"
PHONE_CARRIER="tmobile"
PHONE_CARRIER="tmobile"
SCREENSHOT="true"
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -74,6 +74,7 @@ First, you're going to need to copy the `.env.example` to `.env`. The current op
| `SLACK_CHANNEL` | Slack channel for posting (e.g., `update`); optional |
| `SLACK_TOKEN` | Slack API token; optional
| `STORES` | List of [stores](#Supported-stores) you want to be scraped; optional, default: `nvidia` |
| `SCREENSHOT` | Capture screenshot of page on successful hit; optional, default `true` |

> :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.
Expand Down
7 changes: 4 additions & 3 deletions src/config.ts
Expand Up @@ -21,10 +21,11 @@ const notifications = {
};

const page = {
height: 1920,
capture: process.env.SCREENSHOT ?? 'true',
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',
width: 1080
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
};

const rateLimitTimeout = Number(process.env.RATE_LIMIT_TIMEOUT) ?? 5000;
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Expand Up @@ -68,8 +68,10 @@ async function lookup(store: Store) {
Logger.info(`🚀🚀🚀 [${store.name}] ${graphicsCard} IN STOCK 🚀🚀🚀`);
Logger.info(link.url);

Logger.debug('ℹ saving screenshot');
await page.screenshot({path: `success-${Date.now()}.png`});
if (Config.page.capture === 'true') {
Logger.debug('ℹ saving screenshot');
await page.screenshot({path: `success-${Date.now()}.png`});
}

const givenUrl = store.cartUrl ? store.cartUrl : link.url;
await open(givenUrl);
Expand Down

0 comments on commit 7cfc7c7

Please sign in to comment.