New: 177 themes, each one tested for readable contrast. Browse them

Article

How dark mode extensions work

By Carolinas Dev · Updated · 4 sources

The short answer

A dark mode extension turns a page dark in one of three ways: it inverts the colours, lays a simple dark stylesheet over the page, or rewrites the page's own colours one by one. Rewriting looks the most natural, inverting reaches pages drawn as pictures, and a simple stylesheet stays light on heavy pages. A good extension uses the right method for each site and keeps photos in their real colours.

Where it starts

A web page is content plus style rules that set the colour of everything on it. A dark mode extension adds a small script to each page you open. Chrome calls these content scripts: files that run inside web pages and can read and change them.

That is why a dark mode extension works on every site: it has to restyle whichever page you open next. What the script does with the page is where extensions differ.

Method 1: invert the colours

One filter flips every colour on the page. White becomes black, and black becomes white.

  • Strong at: reach. It works on pages built in unusual ways, including pages drawn as a single picture.
  • Weak at: anything meant to keep its colour. Photos turn into negatives unless the extension flips them back, brand colours change, and pages that were already dark turn light.

Method 2: a simple dark stylesheet

The extension adds a short list of blanket rules: dark backgrounds, light text, readable links.

  • Strong at: staying light on your computer, which suits slow machines and very large pages.
  • Weak at: nuance. It cannot tell which panel was meant to stand out, so pages can look flat.

Method 3: rewrite the page’s colours

The extension reads the page’s style rules and writes a dark version of each one. A white background becomes your theme’s background. A pale grey panel becomes a slightly lighter dark surface. A red warning stays red.

  • Strong at: fidelity. The page keeps its structure and meaning, and a careful version checks that every line of text stays readable.
  • Weak at: effort. It does the most work, and on busy pages it keeps up as the page changes.

How Dark Mode Alpha does it

Dark Mode Alpha has all three, named Smart, Light-touch and Invert. Smart, the rewriting method, is the default. If a site is too heavy for it, Dark Mode Alpha moves that site to a lighter method and tells you in the popup.

On top of the method, it adds what makes a dark web feel right:

  • Pages are dark before they appear, in your theme’s colour.
  • Photos and video keep their real colours.
  • It leaves sites that are already dark alone.
  • Every site can have its own look. Pick a theme from the gallery in the side panel, for everything or for one site.
  • Changes apply to open tabs without a reload.

Pages drawn as pictures

A few web apps paint their main view onto a canvas, the way a game does. Google Docs, Sheets and Slides work this way. Painted text has no style rules to rewrite, so these apps are shown with inverted colours.

Your documents themselves are never changed. The filter changes what you see, not what is stored, so a file keeps its real colours when you share or print it.

PDFs work the same way. Chrome’s viewer draws each page as a picture, and PDFs in Chrome’s viewer can be inverted or dimmed. Dark Mode Alpha offers both.

Pages Chrome keeps to itself

Chrome reserves a few pages for itself: its settings and other built-in pages, the New Tab page and the Chrome Web Store. Chrome does not allow any extension to change them. For Chrome’s own menus and toolbars, turn on its Dark setting under Customize Chrome.

Files on your own computer take one switch. Turn on “Allow access to file URLs” for the extension in Chrome’s extension settings, and local pages go dark too.

If you set the extension’s site access to chosen sites only, it darkens exactly those sites and leaves the rest as they are.

In short

Rewriting colours looks the most natural on everyday sites. Inverting covers canvas apps and PDFs. A simple stylesheet carries heavy pages.

A good extension picks the method per site, tells you what it picked, and lets you change it. Dark Mode Alpha does all three.

Sources

  1. Content scripts (Chrome for Developers) developer.chrome.com
  2. Permissions (Chrome for Developers reference) developer.chrome.com
  3. Manage PDFs in Chrome (Google Chrome Help) support.google.com
  4. Browse in Dark mode or Dark theme (Google Chrome Help) support.google.com