Skip to content

Commit

Permalink
feat: use ts, update cd, update README (#12)
Browse files Browse the repository at this point in the history
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
  • Loading branch information
jef committed Sep 18, 2020
1 parent dcbaa6b commit e9fc0bf
Show file tree
Hide file tree
Showing 25 changed files with 6,628 additions and 224 deletions.
3 changes: 3 additions & 0 deletions .env.example
@@ -0,0 +1,3 @@
EMAIL_USERNAME="youremail@gmail.com"
EMAIL_PASSWORD="secretpassword"
STORES="bestbuy,bandh,nvidia"
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -1 +1 @@
* @jef @andirew @davidlbowman @fuckingrobot @ioncaza @malbert69
* @jef
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -1,7 +1,7 @@
---
name: Bug report
name: 🐛 Bug report
about: Report a bug for this project
title: 'Bug: '
title: 'bug: '
labels: 'bug'
assignees: jef

Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -1,7 +1,7 @@
---
name: Feature request
name: 🚀 Feature request
about: Suggest a feature for this project
title: 'Enhancement: '
title: 'enhancement: '
labels: 'enhancement'
assignees: jef

Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/cd.yaml
Expand Up @@ -16,23 +16,3 @@ jobs:
package-name: nvidia-snatcher
- name: login into github package registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: build nightly docker image
if: ${{ ! steps.release.outputs.release_created }}
run: |
docker build \
-t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}" \
-t "ghcr.io/${GITHUB_REPOSITORY}:nightly" .
- name: publish nightly
if: ${{ ! steps.release.outputs.release_created }}
run: docker push "ghcr.io/${GITHUB_REPOSITORY}"
- name: build latest docker image
if: ${{ steps.release.outputs.release_created }}
run: |
docker build \
-t "ghcr.io/${GITHUB_REPOSITORY}:${TAG_NAME}" \
-t "ghcr.io/${GITHUB_REPOSITORY}:latest" .
env:
TAG_NAME: ${{ steps.release.outputs.tag_name }}
- name: publish latest
if: ${{ steps.release.outputs.release_created }}
run: docker push "ghcr.io/${GITHUB_REPOSITORY}"
10 changes: 4 additions & 6 deletions .github/workflows/ci.yaml
Expand Up @@ -6,19 +6,17 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
name: Lint
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v2.1.1
with:
node-version: ${{ matrix.node-version }}
node-version: 14
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Pull dependencies
run: npm ci
run: |
npm ci
npm run lint
6 changes: 5 additions & 1 deletion .gitignore
@@ -1 +1,5 @@
node_modules/
.idea/
build/
node_modules/

.env
File renamed without changes.
92 changes: 67 additions & 25 deletions README.md
@@ -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.

- 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

<details>
<summary>What you may see if you're lucky</summary>

```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
```

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.
</details>

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.
> :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 :)
**Update 1:** Now includes Best Buy 3080 FE
| | Best Buy | B&H | Newegg | Nvidia |
|:---:|:---:|:---:|:---:|:---:|
| 3090 | | | | |
| 3080 |||||
| 3070 | | | | |

## Installation and running
> :point_right: (ℹ) In the process of getting working. Catchpa problems are intermittent. Use if you'd like, but expect problems.
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.
[FAQ](#FAQ) | [Discord](https://discord.gg/3duFzwk) | [Issues](https://github.com/jef/nvidia-snatcher/issues)

Here's how to get it running:
## Installation and prerequisites

- 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
Linux, macOS, and Windows are all capable operating systems.

```
npm i puppeteer opn nodemailer
node nvidia.js
```
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!

If you want to get an email as well:
- 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`

- If you have two-factor authentication, use https://myaccount.google.com/apppasswords to get your password Google app password
- Otherwise, use your regular password
Then watch the magic happen!

```
npm i puppeteer opn nodemailer
EMAIL_USERNAME="youremail@gmail.com" EMAIL_PASSWORD="secretpassword" node nvidia.js
```
### 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.

## Further customization and hacking
**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.

You can potentially add more `links` and change the `timeout` if you'd like.
**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.

- `timeout` and `waitForTimeout` are in milliseconds.
- `links` are specific to find the `"out of stock"` verbiage (forced to lowercase).
**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

Expand Down

0 comments on commit e9fc0bf

Please sign in to comment.