feat: use ts, update cd, update README (#12)

Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
Jef LeCompte
2020-09-18 04:27:23 -04:00
committed by GitHub
parent dcbaa6bb2e
commit e9fc0bf5f7
25 changed files with 6632 additions and 228 deletions
+71 -29
View File
@@ -1,44 +1,86 @@
# nvidia-snatcher [![cd](https://github.com/jef/nvidia-snatcher/workflows/cd/badge.svg?branch=master)](https://github.com/jef/nvidia-snatcher/actions?query=workflow%3Acd)
## Description
The purpose of this bot is to get an Nvidia card. It does multiple things to try to do that.
This is going to check Nvidia's website every 5 seconds to see if the 3080 is out of stock in the background. If it comes into stock, then your browser will open and direct you to a cart with the 3080 in it where you can proceed manually.
- Currently, `nvidia-snatcher` is not capable of purchasing a card for you
- Scrapes multiple websites for patterns of being stocked
- Opens browser when stock is available
- Send email to you when away from computer
- Must have Gmail
You may get false positives from time to time, so I apologize for that. If you're getting than more often than not, I would change the `const waitForTimeout = 1000;` to a higher number.
<details>
<summary>What you may see if you're lucky</summary>
**Update 1:** Now includes Best Buy 3080 FE
## Installation and running
Not going to write a full write up here, but I'm going to assume you know Node.js. If you don't then go to Google and look up how to install for your OS.
Here's how to get it running:
- Save this text to a file in a folder on your Desktop. E.g. `nvidia/nvidia.js`
- Open up your favorite terminal (`cmd`, `iTerm`, `Tilix`)
- Run the below
```
npm i puppeteer opn nodemailer
node nvidia.js
```sh
2020-09-18T07:06:28.535Z info :: ✖ [nvidia] nvidia founders edition is still out of stock
2020-09-18T07:06:31.241Z info :: ✖ [nvidia] nvidia founders edition is still out of stock
2020-09-18T07:06:34.212Z info :: ✖ [bestbuy] nvidia founder edition is still out of stock
2020-09-18T07:06:39.878Z info :: ✖ [bandh] gigabyte black is still out of stock
2020-09-18T07:06:43.236Z info :: ✖ [bestbuy] gigabyte black is still out of stock
2020-09-18T07:06:43.318Z info :: ↗ trying stores again
2020-09-18T07:06:43.318Z info :: 🚀🚀🚀 [nvidia] nvidia founders edition IN STOCK 🚀🚀🚀
2020-09-18T07:06:43.318Z info :: https://store.nvidia.com/store/nvidia/en_US/buy/productID.5438481700/clearCart.yes/nextPage.QuickBuyCartPage
```
If you want to get an email as well:
</details>
- If you have two-factor authentication, use https://myaccount.google.com/apppasswords to get your password Google app password
- Otherwise, use your regular password
> :point_right: You may get false positives from time to time, so I apologize for that. The library currently waits for all calls to be completed before parsing, but sometimes this can unknown behavior. Patience is a virtue :)
```
npm i puppeteer opn nodemailer
EMAIL_USERNAME="youremail@gmail.com" EMAIL_PASSWORD="secretpassword" node nvidia.js
```
| | Best Buy | B&H | Newegg | Nvidia |
|:---:|:---:|:---:|:---:|:---:|
| 3090 | | | | |
| 3080 | ✔ | ✔ | | ✔ |
| 3070 | | | | |
## Further customization and hacking
> :point_right: () In the process of getting working. Catchpa problems are intermittent. Use if you'd like, but expect problems.
You can potentially add more `links` and change the `timeout` if you'd like.
[FAQ](#FAQ) | [Discord](https://discord.gg/3duFzwk) | [Issues](https://github.com/jef/nvidia-snatcher/issues)
- `timeout` and `waitForTimeout` are in milliseconds.
- `links` are specific to find the `"out of stock"` verbiage (forced to lowercase).
## Installation and prerequisites
Linux, macOS, and Windows are all capable operating systems.
You do not need any computer skills, smarts, or anything of that nature. You are very capable as you have made it this far. Some basic understanding how a terminal, git, and or Node.js is a bonus, but that does not limit you to getting `nvidia-snatcher` running!
- Download [Node.js 14](https://nodejs.org/en/)
- Download [git](https://git-scm.com/)
- Clone this project `https://github.com/jef/nvidia-snatcher.git`
- Run `npm install`
- Edit the `.env` file to your liking
- More on this in [customization](#Customization)
- Run `npm run start`
Then watch the magic happen!
### Customization
There is not much to configure (as of now), but there are some options that you can choose to utilize.
First, you're going to need to copy the `.env.example` to `.env`. The current options are:
| Environment variable | Description |
|:---:|:---:|
| `EMAIL_USERNAME` | Gmail address; e.g. `jensen.robbed.us@gmail.com` |
| `EMAIL_PASSWORD` | Gmail password; see below if you have MFA |
| `STORES` | List of stores you want to be scraped; optional, default: `nvidia` |
> :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.
## FAQ
**Q: What's Node.js and how do I install it?** Visit [their website](https://nodejs.org/en/) and download and install it. Very straight forward. Otherwise, Google more information related to your system needs.
**Q: Will this harm my computer?** No.
**Q: Have you gotten a card yet?** No. :cry:
**Q: Will I get banned from of the stores?** Perhaps, but getting a card is a nice outcome.
**Q: I got a problem and need help!** File an [issue](https://github.com/jef/nvidia-snatcher/issues/new/choose), I'll do my best to get to you. I work a full time job and this is only a hobby of mine.
**Q: I'd love to contribute, how do I do that?** Make a [pull request](https://github.com/jef/nvidia-snatcher/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc)! All contributions are welcome.
**Q: Why do I have to download all this stuff just to get this bot working?** Well, I would rather you didn't either. See #11.
### Acknowledgements