Skip to content

Preserve ribbon colour when Dark Reader is active - #16

Merged
fvet merged 1 commit into
mainfrom
dark-reader-compat
Sep 15, 2026
Merged

fvet merged 1 commit into
mainfrom
dark-reader-compat

Conversation

@fvet

@fvet fvet commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Dark Reader injects its own !important stylesheet after the extension's content stylesheet, which lets it win when both rules have equal specificity.

guardRibbon() now sets background-color, background-image and color as inline styles with !important directly on the ribbon band element — inline important beats any stylesheet rule regardless of load order. A MutationObserver watches the band's style attribute and reapplies immediately if Dark Reader (or any other extension) overrides the values, using disconnect-before-paint-reconnect to avoid infinite callbacks.

releaseRibbon() disconnects the guard and removes the three inline properties so BC's original styling is restored cleanly.

Dark Reader injects its own !important stylesheet after the extension's
content stylesheet, which lets it win when both rules have equal specificity.

guardRibbon() now sets background-color, background-image and color as
inline styles with !important directly on the ribbon band element — inline
important beats any stylesheet rule regardless of load order. A
MutationObserver watches the band's style attribute and reapplies
immediately if Dark Reader (or any other extension) overrides the values,
using disconnect-before-paint-reconnect to avoid infinite callbacks.

releaseRibbon() disconnects the guard and removes the three inline
properties so BC's original styling is restored cleanly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fvet
fvet merged commit cabe069 into main Sep 15, 2026
1 check passed
@fvet
fvet deleted the dark-reader-compat branch September 15, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant