A VPS restock notification tool based on Node.js and Puppeteer, supporting custom DSL syntax to describe monitoring tasks.
- Bandwagonhost
- DMIT.io
- Real browser simulation based on Puppeteer
- Custom DSL syntax for writing monitoring rules
- Support for multiple provider configurations
- Custom selectors and text matching
- Wait time and error handling support
- Telegram notifications support
- Environment variables configuration
- Node.js >= 20
- npm or yarn
- Telegram Bot Token (for notifications)
- Clone Repository
git clone https://github.com/harrisonwang/vps-restock-notifier.git
cd vps-restock-notifier
- Install Dependencies
npm install
- Configure Environment Variables
cp .env.example .env
# Edit .env file with your Telegram bot token and chat ID
vim .env
- Write Monitoring Rules
test "Check Bandwagonhost Stock" {
open "https://bandwagonhost.com/cart.php?a=add&pid=145"
assert "stock" contains "Out of Stock"
}
- Start Monitoring
npm start
Create a .env
file in the project root:
# Telegram Configuration
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
# Monitor Configuration
CHECK_INTERVAL=300 # check interval in seconds
-
Create a new bot:
- Contact @BotFather on Telegram
- Use the
/newbot
command - Save the bot token
-
Get your chat ID:
- Send a message to your bot
- Visit:
https://api.telegram.org/bot<YourBOTToken>/getUpdates
- Find your
chat.id
in the response
Supported Commands:
test
: Define a test caseopen
: Open specified URLclick
: Click specified elementinput
: Input textassert
: Assertion check
Example:
test "Check Bandwagonhost Stock" {
open "https://bandwagonhost.com/cart.php?a=add&pid=145"
assert "stock" contains "Out of Stock"
}
Current website configurations are located in src/config.js
:
export const SITE_CONFIGS = {
'bandwagonhost.com': {
stockSelector: '#order-web20cart .errorbox',
outOfStockText: 'Out of Stock'
},
'dmit.io': {
stockSelector: '#order-boxes h1',
outOfStockText: 'Out of Stock'
}
};
Project Structure:
src/lexer.js
: DSL lexical analyzersrc/parser.js
: DSL parsersrc/index.js
: Main programsrc/config.js
: Website configurationssrc/services/telegram.js
: Telegram notification servicescripts/vps-restock-notifier.sh
: Execution script
Add to crontab for automatic checking:
# Check every 5 minutes
*/5 * * * * /opt/vps-restock-notifier/scripts/vps-restock-notifier.sh
-
How to add a new provider?
- Add new configuration in
SITE_CONFIGS
- Configure corresponding selector and matching text
- Add new configuration in
-
How to adjust check interval?
- Modify CHECK_INTERVAL in .env file
- Update crontab schedule if using cron
-
Telegram notifications not working?
- Verify bot token and chat ID in .env
- Check bot permissions
- Review application logs
Pull Requests and Issues are welcome!
Harrison Wang
MIT License