Colorful Websites is a browser extension that enables users to apply a custom dark or tinted theme to any website. It overrides native color modes to provide a consistent browsing experience based on user-defined color preferences.
- Custom Color Themes: Apply a custom background and accent color to any webpage.
- Adjustable Tint Strength: Control the intensity of the color tint using an overlay alpha slider.
- Theme Presets: Save, manage, and apply multiple color theme presets.
- Per-Site Settings: Save specific theme configurations for individual domains.
- Intelligent Text Color: Automatically calculates and applies a readable text color (black or white) based on contrast ratio.
- Image Inversion: Optionally invert images and media for better dark mode consistency.
- Settings Management: Export and import complete configuration data (presets and per-site settings) as JSON.
The extension functions by injecting content scripts and CSS into the active webpage:
-
User Interaction: The user selects a background color, accent color, and tint strength via the popup interface.
-
Script Injection: The popup script (
popup.js) injectscontent/injector.js,content/helpers.js, andcontent/injected_styles.cssinto the active tab. -
Message Passing:
popup.jssends the user's theme configuration to the content script through Chrome’s message API. -
Style Application:
injector.jsreceives theme data and requests helper functions fromhelpers.jsto compute readable text color.- CSS variables (e.g.,
--dm-bg,--dm-text,--dm-accent) are applied to the root element. - The stylesheet
injected_styles.cssenforces these variables with!importantrules, recoloring the webpage. - A tint overlay (
#dmw-overlay) is added or updated using the accent color and alpha value.
-
Dynamic Content Handling:
injector.jsinitializes aMutationObserverto maintain styling on dynamically loaded content (e.g., single-page apps). -
Disabling: When turned off, injected styles, overlays, and variables are removed to restore the original appearance.
dark-mode-wheel-extension/
├─ manifest.json # Defines the extension, permissions, and entry points
├─ background.js # Service worker for managing defaults and installation setup
├─ content/
│ ├─ injector.js # Applies or reverts themes and observes DOM changes
│ ├─ helpers.js # Color math and DOM utility functions
│ └─ injected_styles.css # Base stylesheet using CSS custom properties
├─ popup/
│ ├─ popup.html # Extension popup interface
│ ├─ popup.js # Handles UI events and sends messages to content scripts
│ └─ popup.css # Popup styling
├─ options/
│ ├─ options.html # Options page interface for presets and settings
│ └─ options.js # Logic for presets, per-site data, and import/export
├─ icons/
│ ├─ icon16.png
│ ├─ icon48.png
│ └─ icon128.png
└─ README.md
Defines the extension as a Manifest V3 project, registers background service workers, declares required permissions (storage, scripting, activeTab), and links to the popup and options pages.
A lightweight service worker responsible for initialization tasks such as setting up default presets and configuration in chrome.storage.sync.
helpers.js– Contains reusable functions for color conversion, contrast ratio calculations, and DOM manipulations.injector.js– Main script that applies color themes, manages overlays, and ensures changes persist with DOM updates.injected_styles.css– Stylesheet injected into web pages, utilizing CSS variables for dark mode application.
popup.html/popup.css– Defines the popup user interface, including color pickers, sliders, and preset buttons.popup.js– Manages popup state, synchronizes storage data, and communicates with content scripts.
options.html/options.css– Provides a dedicated interface for managing presets, global settings, and per-site configurations.options.js– Handles data persistence, preset management, and JSON import/export features.
git clone https://github.com/<your-username>/dark-mode-wheel.git
cd dark-mode-wheelEnsure all files (manifest, popup, content, options) are in place and configured properly for Manifest V3.
To test the extension locally:
For Chrome / Edge (Manifest V3):
- Open
chrome://extensions/ - Enable Developer mode (top-right corner)
- Click Load unpacked
- Select the folder containing the extension (the folder with
manifest.json) - The Dark Mode Wheel icon will appear in the toolbar
Users can back up their configuration by exporting it to a .json file through the Options page. This file can later be imported to restore saved themes, presets, and per-site settings across devices or browser profiles.