npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stock-checker

v1.0.0

Published

A node package to check a list of websites for changes in stock when called

Downloads

30

Readme

Stock Checker

A node script to run on a cron to check for online stock

I wrote a blog post about the background to this project.

https://jaydlawrence.dev/check-if-items-are-in-stock-online-for-free/

Setup

Sites

Copy sites.json.template to sites.json and fill out the required fields.

Fill out the details for the pages that you want to monitor:

  • url: url for page
  • xPath: xpath for content on page to monitor
  • expected: expected text value of content to be compared against. This can also be an array of expected test values to check against.
  • description: human readable description to be used in notifications
  • wait: [Optional] this is used to wait longer on sites that take a while to async load in their stock data, like Best Buy

To add multiple sites to check, just add multiple entries.

For example:

[
  {
    "url": "",
    "xPath": "",
    "expected": "",
    "description": ""
  },
  {
    "url": "",
    "xPath": "",
    "expected": "",
    "description": ""
  }
]

Config

Copy config.json.template to config.json and fill out the required fields.

See the notifications section next for info on how to set up your preferred notification option.

Notifications

This package has 2 options for notifications when a difference is found on a configured site.

Pushover

This project has the option to use pushover.net for notifications.

To use this option, fill out the following options in the config.json.

  • pushoverApiKey: pushover app key
  • pushoverUserKey: pushover user token
  • pushoverEnabled: set this to true to enable pushover notifications

Gmail

This project also has the option of using Gmail for notifications.

To enable Gmail support, fill out the following options in the config.json.

  • gmailUser: the gmail address that you want to send emails from
  • gmailPassword: the password for this gmail account, see note below about making App Passwords
  • gmailTo: the email address to send these notifications to, this can be the same as the from address
  • gmailEnabled: set this to true to enable gmail notifications

Note: It is recommended and in some cases required to create an App Password for your gmail account to use for this project.

Here is an article from Google about how to set that up:

https://support.google.com/accounts/answer/185833

Testing

To test locally, run:

npm link

This makes the script available locally as an executable

run with

npx check-stock

Installing and running

To run this with a cron, the script needs to be installed:

npm install -g .

This should install it near your node path

eg. ~/.nvm/versions/node/v14.10.0/bin/check-stock

Then copy the run.sh.template to run.sh

replace the path with the absolute paths of your npm bin directory.

Then you can add it to your cron tab if you are on a unix environment.

crontab -e

Then add something like the following:

# run script every 15 minutes
*/15 * * * * /<replace_with_path_to_project>/stock-checker/run.sh

If you are on Windows, something like Windows Task Scheduler should be able to help.

https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10