Skip to content

About

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.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Dark Mode Toggle Chrome Extension

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.

Features

  • 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

Installation

  1. Download the extension files (or unzip dark-mode-toggle.zip if provided)
  2. Open Chrome and go to chrome://extensions/
  3. Enable Developer mode (toggle in the top right)
  4. Click Load unpacked and select the folder containing the extension files
  5. The extension should now appear in your extensions list

Usage

  1. Visit any website
  2. Right-click anywhere on the page
  3. Select "Toggle Dark Mode" from the context menu
  4. The page will switch to dark mode (or back to light)
  5. Refresh the page — your preference for that domain is preserved

How It Works

  • Uses chrome.storage.local to save settings per hostname
  • Content script runs at document_start for immediate restoration
  • CSS filter-based inversion with specific fixes for images, videos, code blocks, etc.
  • Background service worker manages context menu and messaging

Files

  • manifest.json - Extension configuration
  • background.js - Service worker for context menu and messaging
  • content.js - Handles applying dark mode and persistence in page context
  • icon.png - Extension icons

Limitations

  • 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)

Development

To modify:

  • Edit content.js for styling changes
  • Update background.js for menu behavior
  • Reload the extension in chrome://extensions/ after changes

License

This project is licensed under the MIT License.


Built with ❤️ using Grok for better web accessibility and eye comfort.

About

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.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages