Repository navigation
1.0.3: no Try offer on sites with a dark theme of their own - #3
Merged
Merged
Conversation
Sites whose own dark theme is switched off in their own settings (YouTube set to light, Stack Overflow, Wikipedia) no longer get the "This page is bright · Try" card or the TRY badge. Before offering, the top frame scans the page's readable style sheets, at idle after load (capped at 3 s), for a dark theme rule aimed at the root: html[dark], body.theme-dark, [data-theme=dark] when the root carries data-theme, or root colors in a matching prefers-color-scheme: dark block that the site's setting gates. Dark section styles (.theme-dark on a promo band, .bg-dark) and blocks libraries ship to every site (Bootstrap's [data-bs-theme=dark], DocSearch's html[data-theme=dark]) don't count. The popup says "Site's own dark theme is off" and keeps Try on this page. All bright sites and sites turned on are adapted as before; the check runs only while the system is dark. Tests: 21 unit, 92/92 fixture e2e. Checked live with the extension: YouTube, Stack Overflow, Wikipedia get no card; HN, BBC, Apple iPhone, IKEA, Microsoft, CNN, Nike, Craigslist keep it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0119pSNmC1KsBQ25Q5us1HoS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sites whose own dark theme is switched off in their own settings no longer get the "This page is bright · Try" card or the TRY badge. YouTube set to its light theme was the report.
How it decides
Before offering, at idle after
load(capped at 3 s), the top frame scans the page's readable style sheets for a dark theme rule aimed at the root:html[dark], Stack Overflowbody.theme-dark, Wikipediahtml.skin-theme-clientpref-night,html.dark body[data-color-mode=dark]withdata-color-modeon<html>.theme-darkbesidebody.theme-beta:root:not(.theme-light)Not counted: dark section styles (
.theme-darkon a promo band on Apple, IKEA or Microsoft;.bg-dark,.btn-dark), and blocks that libraries ship to every site using them (Bootstrap 5.3[data-bs-theme=dark], Algolia DocSearchhtml[data-theme=dark]), unless the site sets that attribute on its root.Behaviour
load(at most 3 s after the first check), not right after DOMContentLoaded.Verification
Limits
light.htmlno longer ships its own dark theme rule; the theme-switch check adds it, because a page that ships one no longer gets the offer.🤖 Generated with Claude Code
https://claude.ai/code/session_0119pSNmC1KsBQ25Q5us1HoS