A simple yet powerful Chrome extension that allows you to toggle dark mode on any webpage via the right-click context menu. The dark mode state is saved per domain, so different websites can have independent settings that persist across page reloads and browser sessions.
- Right-click toggle: Easy access via context menu on any page
- Per-domain persistence: Dark mode for example.com doesn't affect github.com
- Automatic restoration: Remembers your preference and applies it immediately when visiting a site
- Smart CSS inversion: Uses CSS filters for a high-quality dark mode effect with media re-inversion
- Reliable injection: Works on most websites with fallback mechanisms
- Download the extension files (or unzip
dark-mode-toggle.zipif provided) - Open Chrome and go to
chrome://extensions/ - Enable Developer mode (toggle in the top right)
- Click Load unpacked and select the folder containing the extension files
- The extension should now appear in your extensions list
- Visit any website
- Right-click anywhere on the page
- Select "Toggle Dark Mode" from the context menu
- The page will switch to dark mode (or back to light)
- Refresh the page — your preference for that domain is preserved
- Uses
chrome.storage.localto save settings per hostname - Content script runs at
document_startfor immediate restoration - CSS filter-based inversion with specific fixes for images, videos, code blocks, etc.
- Background service worker manages context menu and messaging
manifest.json- Extension configurationbackground.js- Service worker for context menu and messagingcontent.js- Handles applying dark mode and persistence in page contexticon.png- Extension icons
- Some websites with strict CSP or complex styling may have imperfect results
- Works best on standard web pages
- No popup UI (context menu only for simplicity)
To modify:
- Edit
content.jsfor styling changes - Update
background.jsfor menu behavior - Reload the extension in
chrome://extensions/after changes
This project is licensed under the MIT License.
Built with ❤️ using Grok for better web accessibility and eye comfort.