A Firefox extension that converts web pages to dark mode for better ergonomic viewing experience.
Key Features • Installation • Usage • Contributing • License
- One-click Toggle — Enable/disable the extension with a single click from the toolbar
- Custom Dark Mode — Personalize background color and darkness level to your preference
- System Theme Sync — Automatically follow your OS theme changes
- Lightbox Viewer — Built-in image lightbox with gallery support
- Media Protection — Images, videos, and canvas elements are preserved from inversion
- Performance Optimized — Uses CSS filters for instant, smooth conversion
- Bilingual Support — English and Chinese (Simplified) interface, auto-detects system language
- Settings Persistence — Your preferences are saved automatically across sessions
The easiest way to test without modifying browser settings. The extension will be removed when Firefox restarts.
- Open Firefox
- Navigate to
about:debugging#/runtime/this-firefox - Find the Temporary Extensions section
- Click Load Temporary Add-on...
- Select the
manifest.jsonfile from the project directory - The extension icon will appear in the toolbar immediately
For permanent installation, use Firefox Developer Edition with signature verification disabled.
-
Install Firefox Developer Edition
- Download: mozilla.org/firefox/developer
-
Disable signature verification
- Open
about:config - Click "Accept the Risk and Continue"
- Search for
xpinstall.signatures.required - Set the value to
false
- Open
-
Install the extension
- Navigate to
about:addons - Click the gear icon → "Install Add-on From File..."
- Select
DarkModeSwitch.xpi
- Navigate to
Once signed by Mozilla, install directly from the Firefox Add-ons Store.
- Click the extension icon in the Firefox toolbar
- Toggle Enable Extension to activate the extension
- On any web page, two floating buttons appear in the bottom-right:
- 🖼️ Lightbox button — Click to open the image lightbox viewer
- ⚙️ Settings button — Click to open the settings panel
Access all customization options through the gear button on web pages:
| Setting | Description |
|---|---|
| Enable Dark Mode | Toggle dark mode effect on/off |
| Background Color | Choose custom background color |
| Darkness | Adjust darkness level (0-100%) |
| Follow System Theme | Auto-sync with OS theme |
| Enable Lightbox Viewer | Toggle the image lightbox feature |
| Lightbox Size | Adjust lightbox size (Compact / Standard / Spacious / Immersive) |
| Key | Action |
|---|---|
Esc |
Close lightbox |
← / → |
Previous / Next image |
+ / - |
Zoom in / out |
Space |
Play / pause (video) |
f |
Toggle fullscreen |
m |
Mute / unmute |
TurnOffLight/
├── manifest.json # Extension configuration
├── _locales/ # Internationalization files
│ ├── en/messages.json # English strings
│ └── zh_CN/messages.json # Simplified Chinese strings
├── background/
│ └── background.js # Background script (settings, theme detection)
├── content_scripts/
│ ├── dark-mode.css # Dark mode styles
│ ├── dark-mode.js # Dark mode logic
│ ├── lightbox.css # Lightbox styles
│ └── lightbox.js # Lightbox & settings panel logic
├── popup/
│ ├── popup.html # Popup UI
│ ├── popup.css # Popup styles
│ └── popup.js # Popup logic
├── options/
│ ├── options.html # Options page
│ ├── options.css # Options styles
│ └── options.js # Options logic
├── icons/ # Extension icons
└── build_xpi.py # XPI build script
- Manifest V3 — Latest Firefox extension standard
- CSS Filters — Efficient color inversion with
filter: invert()+hue-rotate() - WebExtensions API —
browser.storage,browser.theme,browser.i18n - Vanilla JavaScript — No framework dependencies, lightweight and fast
| Browser | Minimum Version |
|---|---|
| Firefox | 109+ |
| Manifest | V3 |
| Permission | Purpose |
|---|---|
storage |
Save user preferences locally |
activeTab |
Access current tab for lightbox interaction |
theme |
Detect system theme changes |
<all_urls> |
Apply dark mode to all websites |
Contributions are welcome! Here's how you can help:
- Fork the repository and create your branch
- Make your changes — add features, fix bugs, improve docs
- Test thoroughly on multiple websites
- Submit a Pull Request with a clear description
# Clone the repository
git clone https://github.com/NARCSSU/TurnOffLight.git
cd TurnOffLight
# Build XPI package
python build_xpi.py
# Load in Firefox (temporary)
# about:debugging#/runtime/this-firefox → Load Temporary Add-on → select manifest.json- Create a new directory under
_locales/(e.g.,_locales/ja/) - Copy
_locales/en/messages.jsonas a template - Translate all message values
- Test by changing your Firefox UI language
This project is open source and available for personal and commercial use.
Made with ❤️ for better eye health