A Dockerized Node.js script to automatically maintain your Duolingo streak for multiple users.
This script runs continuously in a Docker container, performs a configurable number of lessons for each enabled user, and then waits 24 hours before repeating the cycle.
This project is a fork of Michael1337/duolingo-autostreak with multi-user support and other improvements.
- Multiple Users: Manage streaks for several Duolingo accounts.
- Dockerized: Easy setup and management using Docker and Docker Compose.
- Configuration File: Uses
config.jsonfor easy setup of users and settings. - Reliability: Includes basic error handling and retry logic for API requests.
- Logging: Logs activities to a file (
logs/duolingo.log) mounted from the host. - Results Tracking: Saves the outcome of each cycle to
results.json. - Simple Management: Includes a
manage.shscript for easy container control.
- Docker
- Docker Compose (Usually included with Docker Desktop)
-
Clone or Download: Get the project files onto your system.
git clone git@github.com:petrochen/duolingo-autostreak.git cd duolingo-autostreak -
Get Duolingo JWT Token: You need a JWT token for each user you want to manage.
- Log in to Duolingo in your web browser.
- Open your browser's developer tools (usually by pressing F12).
- Go to the "Application" (or "Storage") tab.
- Find "Cookies" in the left-hand menu and select
https://www.duolingo.com. - Look for a cookie named
jwt_token(or potentially a similar name containing "jwt"). - Copy the entire value from the "Value" column for that cookie (it's a long string with dots). Important: Keep this token secure, as it grants access to the account.
- Repeat for each Duolingo account.
-
Configure
config.json:- Copy the example configuration file:
cp config.json.example config.json
- Open the newly created
config.jsonfile. - Replace the placeholder usernames (
your_duolingo_username_...) and JWT tokens (YOUR_JWT_TOKEN_HERE_...) with the actual values you obtained in the previous step. Do not commitconfig.jsonto version control as it contains secrets. - Adjust the number of
lessonsand othersettingsif needed.
- Copy the example configuration file:
-
Make Management Script Executable:
chmod +x manage.sh
-
Create Logs Directory: The script expects the
logsdirectory to exist for mounting.mkdir -p logs
Use the manage.sh script to control the container:
-
Build the Docker image: (Only needs to be done once initially or after code changes)
./manage.sh build
-
Start the container: (Runs in detached mode)
./manage.sh start
The script will now run, perform lessons for enabled users, log its activity to
logs/duolingo.log, save results toresults.json, and then wait 24 hours before the next cycle. -
View Logs:
./manage.sh logs
(Press
Ctrl+Cto stop viewing logs) -
Check Container Status:
./manage.sh status
-
Restart the container: (Useful after changing
config.json)./manage.sh restart
-
Stop the container:
./manage.sh stop
Dockerfile: Defines the Docker image build process.docker-compose.yml: Defines the Docker service and its configuration (volumes, network, etc.).duolingo.js: The main Node.js application logic.config.json: User configuration and settings (You create this).package.json/package-lock.json: Node.js dependencies.manage.sh: Helper script for Docker Compose commands.results.json: Stores the results of the last run (Created automatically if missing and volume is mounted).logs/: Directory containing the application log file (Created automatically if missing and volume is mounted).
- Never commit
config.json- It contains your JWT tokens which grant full access to your Duolingo accounts - Never share your JWT tokens - They are equivalent to your password
- Never commit
results.json- It contains your usernames - Keep your logs private - They may contain sensitive information
- Review your code before pushing - Make sure no sensitive data is included
-
Multi-User Support
- Added ability to manage multiple Duolingo accounts simultaneously
- Implemented individual user enable/disable functionality
- Added per-user error handling and retry logic
- Added user-specific results tracking
-
Improved Docker Setup
- Implemented proper volume mounting and logging
- Added container restart policy
-
Better Error Handling
- Added structured logging with timestamps
- Implemented log rotation and critical error tracking
- Added automatic log directory management
-
Enhanced Security
- Implemented non-root user in container
- Added proper file permissions
- Improved configuration file handling