Fix custom theme colors not applying due to outdated CSS selectors an…
Issue
Custom theme colors (primary/text) were not applying and remained black/white.
Cause
YouTube updated its internal CSS variables and DOM behavior. The extension relied on the selector: html[it-theme=custom]
However, this attribute is not consistently present, causing styles to never apply.
Fix
- Replaced selector with :root for global application
- Ensured style injection works regardless of attribute presence
- Added fallback and re-injection logic to handle YouTube dynamic updates
- Fixed masthead selector to remove dependency on custom attribute
Result
- Custom theme colors now apply correctly
- Works with latest YouTube UI
- Stable even during SPA navigation
Tested on
- Chrome
- Latest YouTube version
@Ganeshbhargav thanks for the pr!! Can you please attach screenshots or a screen recording
Black mode is only affecting the top bar, not the main video page, which is near-black but still not quite true black (looks the same as YouTube Dark). This is after both checking for updates & refreshing. Oh, and it darkens the uploader's channel name to a light gray instead of white.
EDITED TO ADD: OS: Windows 10 desktop. Browser: Chrome Version 147.0.7727.138 (Official Build) (64-bit)
thank you! @Ganeshbhargav
Sorry for the delay!! The neccessary update was done with css: https://github.com/code-charity/youtube/commit/d8af92cd08548e1e112121e08ba543f0a70dd45b
We could shorten/combine the static theme's css a lot and inject everything conditionally except for the background (and font) which can be as fast as possible & with redundancy