Custom app · Chrome extension · Developer tooling

Dark Prefer

Color-scheme override · Chrome extension

Prototype

All projects

Split-screen showing a webpage in light mode on the left and dark mode on the right
01The story

Problem, approach, outcome

Email templates and websites switch to their dark theme with a CSS media query, prefers-color-scheme. Checking that the dark version works means flipping that setting, and in Chrome it lives several menus deep: open DevTools, find the Rendering panel, scroll to the media-feature emulation, pick dark, then do it all again to check light. Close DevTools and it resets. When you’re iterating on a template, that routine happens dozens of times a day.

Use the same mechanism DevTools uses, without opening DevTools. The extension talks to the Chrome DevTools Protocol directly and sets the emulated color scheme for that one tab, so the result is identical to the manual route.

Every decision after that was about leaving no trace. The setting is per tab, so other tabs are untouched. Off means fully off: the debugger connection is dropped and everything the extension added to the page is removed. That matters because Chrome shows its own “started debugging” banner whenever an extension uses this API, a safety feature that can’t be hidden. The indicator bar sits in its own Shadow DOM so the page’s styles can’t break it, and it pushes the page down rather than covering the top. Pages Chrome won’t let an extension touch, like its own settings screens, get a clear error instead of a silent failure.

It’s also honest about what it tests: how your CSS responds in a browser, which is how Apple Mail and browser-based previews behave. Gmail and Outlook ignore the media query and apply their own color inversion, so Dark Prefer speeds up development without replacing real email-client testing.

It replaced the DevTools routine, and it’s part of my daily email QA. Whenever I touch dark-mode CSS, it’s what I reach for: one click to check dark, one to check light, one to put the tab back.

02Overview

About Dark Prefer

Dark Prefer is a one-button Chrome extension for anyone writing dark-mode CSS. Click the moon in the toolbar and the current tab behaves as if your computer were set to dark mode. Click again for light, and once more to put the tab back to normal. A thin bar across the top of the page shows which mode you’re in.

It does one thing on purpose. It doesn’t restyle the page or guess at colors. It changes the one setting your CSS is listening to, so what you see is exactly what your own dark-mode rules do.

03Features

What it does

  • One click cycles the current tab through dark, light and off
  • Uses Chrome’s own emulation, so results match DevTools exactly
  • Per tab: every other tab keeps its normal color scheme
  • A small bar at the top of the page shows the active mode, and can be hidden
  • A green check on the toolbar icon whenever a tab is being emulated
  • Off means fully off: the debugger detaches and everything injected is removed
  • A clear error on pages Chrome doesn’t allow extensions to change
  • Collects nothing and makes no network requests
04Stack

How it’s built

  • Chrome extension, Manifest V3
  • A vanilla JavaScript service worker, with no dependencies
  • Chrome DevTools Protocol: Emulation.setEmulatedMediaFeatureValues
  • Shadow DOM for the in-page indicator bar
  • Per-tab state in session storage, cleared when the tab closes
05Roadmap

Where it’s going

  1. Shipped

    One-click dark and light

    Per-tab emulation with an indicator bar and a toolbar badge.

  2. Shipped

    A clean off switch

    Turning it off detaches the debugger and removes everything it added, even if you dismiss Chrome’s banner first.

  3. Next

    Chrome Web Store listing

    One-click install instead of developer mode.

  4. Next

    Keyboard shortcut

    Switch modes without reaching for the toolbar.

  5. Exploring

    A popup instead of click-to-cycle

    Pick dark or light directly, and only attach to the tab when you do.

Have a problem a small, focused tool could solve?

This is the kind of work I do at 321 Enterprise. Tell me what slows your team down and we’ll see what we can build.

Start a conversation See all projects