# anyrouter **Repository Path**: vi-me/anyrouter ## Basic Information - **Project Name**: anyrouter - **Description**: 简单的定时任务 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-22 - **Last Updated**: 2025-09-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Daily Web Opener A cross-platform Node.js tool for scheduling daily website opening at specific times using cron expressions. ## Features - 🌍 **Cross-platform**: Works on Windows, macOS, and Linux - ⏰ **Flexible scheduling**: Uses cron expressions for precise timing - 🖥️ **Multiple browsers**: Opens URLs in system default browser - 🔧 **CLI and API**: Use as command-line tool or Node.js library - ✅ **Well-tested**: Comprehensive test suite with 15+ tests - 📦 **Zero-config**: Works out of the box with sensible defaults ## Installation ```bash npm install -g daily-web-opener ``` Or use locally in your project: ```bash npm install daily-web-opener ``` ## Quick Start ### Command Line Usage ```bash # Start daily scheduler (8 AM every day) daily-web-opener start --url https://github.com # Custom schedule (9 AM, weekdays only) daily-web-opener start --url https://stackoverflow.com --cron "0 9 * * 1-5" # Test immediately daily-web-opener run-once --url https://example.com ``` ### Programmatic Usage ```javascript import { createScheduler, loadConfig } from 'daily-web-opener'; const config = loadConfig({ url: 'https://github.com', cron: '0 8 * * *' // 8 AM daily }); const scheduler = createScheduler(config); scheduler.start(); ``` ## Configuration Options | Option | Type | Default | Description | |--------|------|---------|-------------| | `url` | string | **required** | URL to open | | `cron` | string | `'0 8 * * *'` | Cron expression | | `multiple` | boolean | `false` | Open multiple windows | | `delay` | number | `0` | Delay between windows (ms) | | `browser` | string | `null` | Specific browser (system default) | ## Cron Expression Examples ```bash # Every day at 8 AM "0 8 * * *" # Weekdays at 9 AM "0 9 * * 1-5" # Every hour "0 * * * *" # Every 30 minutes "*/30 * * * *" ``` ## CLI Commands ### `start` - Start Scheduler ```bash daily-web-opener start [options] Options: -u, --url URL to open (required) -c, --cron Cron expression (default: "0 8 * * *") -m, --multiple Open multiple browser windows -d, --delay Delay between multiple windows --dry-run Validate without starting ``` ### `run-once` - Test Immediately ```bash daily-web-opener run-once [options] Options: -u, --url URL to open (required) --dry-run Validate without opening browser ``` ## API Reference ### `createScheduler(config)` Creates a new scheduler instance. ### `loadConfig(userConfig)` Merges user config with defaults. ### `validateConfig(config)` Validates configuration object. ## Platform Support - **Windows**: Uses `start` command - **macOS**: Uses `open` command - **Linux**: Uses `xdg-open` command ## Requirements - Node.js ≥ 18.0.0 - Supported OS: Windows, macOS, Linux ## Examples ### Basic Daily Opening ```javascript import { createScheduler, loadConfig } from 'daily-web-opener'; const config = loadConfig({ url: 'https://news.ycombinator.com', cron: '0 8 * * *' // 8 AM daily }); const scheduler = createScheduler(config); scheduler.start(); // Graceful shutdown process.on('SIGINT', () => { scheduler.stop(); process.exit(0); }); ``` ### Multiple Windows with Delay ```javascript const config = loadConfig({ url: 'https://github.com', cron: '0 9 * * 1-5', // 9 AM weekdays multiple: true, delay: 3000 // 3 second delay }); const scheduler = createScheduler(config); scheduler.start(); ``` ## Security & Best Practices - ⚠️ **Rate Limiting**: Avoid excessive requests to websites - 🔒 **HTTPS Only**: Use HTTPS URLs when possible - 🛡️ **Validation**: All URLs are validated before opening - 📝 **Logging**: Monitor scheduled executions ## Contributing 1. Fork the repository 2. Create feature branch (`git checkout -b feature/amazing-feature`) 3. Run tests (`npm test`) 4. Commit changes (`git commit -m 'Add amazing feature'`) 5. Push to branch (`git push origin feature/amazing-feature`) 6. Open Pull Request ## License MIT License - see [LICENSE](LICENSE) file for details. ## Support - 📖 [Documentation](https://github.com/username/daily-web-opener) - 🐛 [Issue Tracker](https://github.com/username/daily-web-opener/issues) - 💬 [Discussions](https://github.com/username/daily-web-opener/discussions)