Skip to content

feat: show HDR badge next to video title - #4412

Merged
ImprovedTube2 merged 4 commits into
code-charity:masterfrom
wolfdate25:feat/hdr-badge
Oct 24, 2026
Merged

ImprovedTube2 merged 4 commits into
code-charity:masterfrom
wolfdate25:feat/hdr-badge

Conversation

@wolfdate25

Copy link
Copy Markdown

What

Shows a small HDR badge next to the video title on watch pages when the current video offers HDR streams — even while Windows/Firefox is in SDR mode, so users can decide to switch the OS to HDR before watching.

Why

Firefox 153+ plays YouTube HDR only when Windows itself is in HDR mode. Users who normally stay in SDR have no way to tell an HDR video apart until they switch modes and check the quality menu.

How it works

  • Reads the in-memory player response first (#movie_player.getPlayerResponse()), falls back to window.ytInitialPlayerResponse; watch-page fetch deliberately avoided.
  • Treats a video as HDR when any adaptive format matches: PQ/SMPTE-2084 or HLG transfer, BT.2020/2100 primaries, HDR in qualityLabel, or VP9 Profile 2 codec string.
  • Verifies the response belongs to the current video (videoDetails.videoId vs URL v=) so SPA navigation can't show a stale badge; retries a few times because the player response populates asynchronously.
  • Badge is appended to ytd-watch-metadata #title, cleared on every navigation, and gated behind a new Appearance switch (hdr_badge, default off).

Files

  • js&css/web-accessible/www.youtube.com/appearance.js — ImprovedTube.hdrBadge()
  • js&css/web-accessible/functions.js — hook into videoPageUpdate()
  • menu/skeleton-parts/appearance.js + _locales/en/messages.json — setting + label
  • js&css/extension/www.youtube.com/appearance/details/details.css — badge style
  • tests/unit/hdr-badge.test.js — 9 tests (PQ, HLG, primaries, label, vp9.2, SDR-negative, setting-off, stale-response, non-video page)

Verification

  • npm test: 31 suites / 156 tests pass (147 pre-existing + 9 new)
  • web-ext lint: no new issues (single error is a pre-existing invalid JSON in tests/csslint_rules.json, also present on clean master)
  • Manually injected the same detection + render code into a live HDR watch page (Costa Rica 4K HDR, LXb3EKWsInQ): detection hit SMPTEST2084 and the badge rendered next to the title.

@ImprovedTube2
ImprovedTube2 merged commit f61fd7e into code-charity:master Oct 24, 2026
@ImprovedTube2

Copy link
Copy Markdown
Member

Hi and thank you! @wolfdate25

why switch manually back and forth?

did you see our old feature "Avoid HDR, keep SDR" ?

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.

2 participants