DualSub is a powerful Chrome extension that enhances your streaming experience by displaying dual language subtitles simultaneously. Perfect for language learning, accessibility, or simply enjoying content in multiple languages at once.
- Documentation
- Highlights
- Installation & Quick Start
- Development Setup
- Architecture
- Contributing
- Testing
- License
- Changelog
- Dual subtitles on Netflix and Disney+
- Multiple translation providers with smart fallback and batching
- AI Context Analysis (OpenAI, Google Gemini)
- Flexible layouts, appearance controls, and timing offset
- Multi-language UI (EN, ES, JA, KO, ZH-CN, ZH-TW)
See details in: features.md, platforms.md, providers.md.
- Install from the Chrome Web Store or load unpacked (see installation.md).
- Open Netflix or Disney+ and enable subtitles.
- Click the DualSub icon → enable dual subtitles and choose target language.
- Optional: Configure AI Context (provider, API key, model) in Advanced Settings.
Configuration reference: configuration.md. AI docs: ai-context.md.
For Language Learning:
Translation Provider: DeepL Free
Layout: Top/Bottom
Display Order: Original First
Font Size: Large
AI Context: Enabled (OpenAI GPT-4.1 Mini)
Context Types: Cultural, Historical, Linguistic
For Performance:
Translation Batch Size: 5
Request Delay: 100ms
Translation Provider: Google Translate
AI Context: Enabled (Google Gemini Flash)
Context Cache: Enabled
For Advanced Users:
Translation Provider: OpenAI Compatible
AI Context Provider: OpenAI GPT-4.1 Mini
Context Types: All
Rate Limit: 60 requests/minute
Cache TTL: 1 hour
Debug Logging: Enabled
- Node.js 18+ and npm
- Google Chrome with Developer mode enabled
- Git for version control
-
Clone and Install
git clone https://github.com/QuellaMC/DualSub.git cd DualSub npm install -
Development Commands
Note: For richer editor IntelliSense of Chrome extension APIs in this JS-only (JSDoc @ts-check) project, you can optionally install:
npm i -D chrome-typesFiles may include a directive like /// <reference types="chrome" /> to enable those types locally. Messaging reliability utilities live at content_scripts/shared/messaging.js.
```bash
# Code formatting
npm run format
# Linting
npm run lint
npm run lint:fix
# Testing
npm test
npm run test:watch
```
- Load Extension for Testing
- Follow manual installation steps above
- Reload extension after making changes
DualSub/
├── content_scripts/ # Platform-specific content scripts
├── translation_providers/ # Translation service implementations
├── services/ # Core services (config, logging)
├── popup/ # Extension popup interface
├── options/ # Advanced settings page
├── utils/ # Shared utilities
├── test-utils/ # Testing infrastructure
├── _locales/ # Internationalization files
└── icons/ # Extension icons
DualSub uses a modern, modular architecture built on several key design patterns:
- 📐 Template Method Pattern:
BaseContentScriptprovides common functionality with platform-specific implementations - 🔌 Dependency Injection: Dynamic module loading for better testability and loose coupling
- 📡 Event-Driven Design: Extensible message handling with action-based routing
- 🧹 Resource Management: Comprehensive cleanup system preventing memory leaks
- Content Scripts: Platform-specific implementations extending
BaseContentScript - Translation Providers: Modular translation services with automatic fallback
- Configuration Service: Centralized settings management with validation
- Logging System: Cross-context logging with configurable levels
For detailed technical documentation, see:
We welcome contributions! Please follow these guidelines:
- ESLint + Prettier: Code must pass linting and formatting checks
- ES Modules: Use modern JavaScript module syntax
- Testing: All new features require comprehensive tests
- Documentation: Update relevant documentation for changes
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for your changes
- Ensure all tests pass (
npm test) - Format code (
npm run format) - Lint code (
npm run lint:fix) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Create provider in
translation_providers/directory - Implement
async function translate(text, sourceLang, targetLang) - Add to
background.jsproviders object - Update
popup/popup.jsandoptions/options.js - Add comprehensive tests
- Extend
BaseContentScriptclass - Implement required abstract methods
- Create platform-specific configuration
- Update
manifest.jsoncontent scripts - Add platform tests
- All submissions require review
- Tests must pass CI/CD pipeline
- Documentation must be updated
- Breaking changes require discussion
DualSub includes a comprehensive testing framework:
# Run all tests
npm test
# Watch mode for development
npm run test:watch
# Run specific test file
npm test -- background.test.js
# Run tests with coverage
npm test -- --coverage- Unit Tests: Individual component testing
- Integration Tests: Cross-component functionality
- Mock Infrastructure: Chrome API and DOM mocking
- Test Utilities: Shared testing helpers and fixtures
- Coverage: Aim for >80% code coverage
- Isolation: Tests should not depend on each other
- Mocking: Use provided mocks for Chrome APIs
- Assertions: Clear, descriptive test assertions
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0).
- ✅ Share: Copy and redistribute the material
- ✅ Adapt: Remix, transform, and build upon the material
- ❌ Commercial Use: Not permitted
- 📝 Attribution: Must give appropriate credit
- 🔄 ShareAlike: Must distribute under same license
For full license terms, see LICENSE file.
- 🎉 Full React Migration: Popup and options pages migrated to React with 100% functional parity
- ✨ Modern component-based architecture with custom hooks
- 📦 Vite build system for optimized production bundles
- 🐛 Fixed container width consistency and i18n translation keys
- 📝 Comprehensive migration documentation
See CHANGELOG.md for detailed version history.
- Messaging reliability: Refactored messaging utilities to support both callback- and promise-style chrome.runtime.sendMessage, with wake-up retries for MV3 service worker.
- Unified resilient message sending across platform adapters (BasePlatformAdapter + Netflix), improving background communication stability and test determinism.
- AI Context: Provider metrics now correctly reflect success/error; tests updated to tolerate callback/promise messaging; dynamic chrome access prevents stale mocks between tests.
- Internal refactors and stability improvements.
- 🧠 Netflix next-episode preload-aware subtitles: buffers subtitle tracks detected before navigation and applies them immediately after SPA route change to the next episode, fixing cases where subtitles did not update on Next Episode.
- 🧩 Universal improvement: content script now notifies the platform on URL changes, laying the groundwork for cross-platform preload handling.
- 🛠️ Netflix soft navigation fix: Resolves issue where moving to the next episode (SPA navigation) could continue showing previous episode subtitles. Subtitles now reset and rebind to the new video context.
- 🎯 Disney+ progress bar update: Adjusted detection to the updated site UI; timing now reads directly from the progress-bar web component’s shadow DOM via aria attributes for accurate sync.
- 🧩 Modularized documentation with English and Chinese docs under
docs/ - 🧭 AI Context UI/UX refinements (modal, transitions, selection persistence)
- 🧹 Internal refactors and minor fixes
- 📍 Added vertical position control for precise subtitle placement on screen
- 🎨 Enhanced appearance customization with new positioning options
- ⚙️ Improved user interface with vertical position slider control
- 🤖 NEW: AI Context Analysis feature with OpenAI and Google Gemini support
- 🎯 Interactive subtitle text selection with cultural, historical, and linguistic explanations
- 🔑 Comprehensive API key management and provider configuration
- 🚀 Implemented universal batch translation system for improved performance
- ⚡ Added provider-specific batch size optimization (80-90% reduction in API calls)
- 🔧 Enhanced translation efficiency with intelligent batching and delimiter approach
- 📊 Improved subtitle processing with configurable batch sizes and concurrent processing
- 🧠 Advanced caching and rate limiting for AI context requests
- 🚀 Implemented universal batch translation system for improved performance
- ⚡ Added provider-specific batch size optimization (80-90% reduction in API calls)
- 🔧 Enhanced translation efficiency with intelligent batching and delimiter approach
- 📊 Improved subtitle processing with configurable batch sizes and concurrent processing
- ✨ Added Netflix support with official subtitle integration
- 🔄 Implemented multiple translation providers with fallback
- 🌐 Added multi-language UI support (6 languages)
- ⚙️ Introduced advanced options page
- 🏗️ Refactored architecture with Template Method pattern
- 🧪 Added comprehensive testing framework
- 📊 Implemented configurable logging system
- 🔧 Enhanced configuration management
For detailed version history, see GitHub Releases
- 🐛 Bug Reports: GitHub Issues
- 💡 Feature Requests: GitHub Discussions
- 📖 Documentation: Wiki

