Skip to content

Helps you to search for specific DOM elements on web pages and then send a notification to your own Discord server

License

Notifications You must be signed in to change notification settings

devfle/in-stock-check

Repository files navigation

In Stock Check

Welcome to the Stock Check tool. This tool allows you to search for specific DOM elements on web pages and then send a notification to your own Discord server.

01

The tool was originally built to send a notification when a certain product is back in stock in a store.

How to setup

  1. Clone the repo
  2. run npm ci with node 18.X (if you have installed nvm, run "nvm use")
  3. create a .env file in project root
  4. create a shop-list.json file in /src folder
  5. build the project with npm run buildcommand

.env file

To protect sensitive information like API keys the project uses env files.

DISCORD_API_KEY="YOUR DISCORD BOT API KEY"
CHANNEL_ID="THE ID OF THE DISCORD CHANNEL WHERE YOU WANT TO BECOME THE NOTIFICATION"
LOGIN_MSG="OPTIONAL: A CUSTOM LOGIN MESSAGE"

shop-list.json

All metadata for the web pages that are to be analyzed are listed here.

[
  {
    "shopName": "NAME OF THE WEBSITE",
    "productEndpoint": "URL TO THE WEBSITE",
    "searchQuery": "THE SELECTOR YOU WANT TO SEARCH",
    "showProductLink": false
  }
]

Multiple web pages can also be configured:

[
  {
    "shopName": "NAME OF THE WEBSITE",
    "productEndpoint": "URL TO THE WEBSITE",
    "searchQuery": "THE SELECTOR YOU WANT TO SEARCH",
    "showProductLink": false
  },
  {
    "shopName": "NAME OF THE WEBSITE",
    "productEndpoint": "URL TO THE WEBSITE",
    "searchQuery": "THE SELECTOR YOU WANT TO SEARCH",
    "showProductLink": false
  }
]

Docker

The NodeJs script can also run in a Docker environment:

  1. Navigate into project dir
cd in-stock-check
  1. Compile the script:
npm run build
  1. Create .env file with necessary data and pass it as a secret:
docker build -t "in-stock-check" --secret id=in-stock-env,src=.env .

Contributing

Please follow the Prettier, ESLint and TypeScript rules included in this project. You can check your code with the following commands:

Run ESLint:

npm run lint

Run Prettier:

npm run prettier

Compile TypeScript:

npm run build

While commiting, please use one of the following types:

['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test']

Example:

git commit -m "chore: update packages"

About

Helps you to search for specific DOM elements on web pages and then send a notification to your own Discord server

Topics

Resources

License

Stars

Watchers

Forks