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

