Skip to content

fix(general): restore classic thumbnail metadata under renamed YouTube classes - #4303

Merged
ImprovedTube2 merged 2 commits into
code-charity:masterfrom
tisankanj:fix-classic-thumbnail-metadata-selectors
Oct 24, 2026
Merged

ImprovedTube2 merged 2 commits into
code-charity:masterfrom
tisankanj:fix-classic-thumbnail-metadata-selectors

Conversation

@tisankanj

Copy link
Copy Markdown
Contributor

Summary

Restores the Classic thumbnail metadata feature on the watch page sidebar. Closes #4278.

YouTube renamed its content metadata view-model classes from the hyphenated yt-content-metadata-view-model-wiz__* form to camelCase. The rule in general.css still targeted the old names, so the play-triangle icon in front of the view count came back.

Root cause, measured on a live watch page

Counted in the console on youtube.com/watch:

Selector the CSS targeted Matches Current equivalent Matches
.yt-content-metadata-view-model-wiz__metadata-row 0 .ytContentMetadataViewModelMetadataRow 11
.yt-content-metadata-view-model-wiz__metadata-text 0 .ytContentMetadataViewModelMetadataText 12
.yt-content-metadata-view-model-wiz__metadata-icon 0 .ytContentMetadataViewModelLeadingIcon 4

Every one of the 4 leading icons sits directly inside a metadata row, and the row it belongs to reads 18M 5y ago, which is the views and age row from the report.

The fix

One added selector. The old selectors stay, so any surface still served the previous markup keeps working.

html[it-classic-thumbnail-metadata='true'] .ytContentMetadataViewModelMetadataRow .ytContentMetadataViewModelLeadingIcon

It targets the leading icon by name rather than every icon in the row. The channel verified badge is a separate .ytAttributedStringImageElement inside the metadata text, so it is not hidden.

Verification

Applied the exact rule to a live watch page and measured getComputedStyle before and after:

  • 4 leading icons: flex to none
  • 3 verified badges: inline-flex to inline-flex, unchanged

To reproduce, paste this in the console on a watch page:

document.documentElement.setAttribute('it-classic-thumbnail-metadata', 'true');
const s = document.createElement('style');
s.textContent = "html[it-classic-thumbnail-metadata='true'] .ytContentMetadataViewModelMetadataRow .ytContentMetadataViewModelLeadingIcon{display:none !important}";
document.head.appendChild(s);

npx jest passes: 24 suites, 113 tests.

What I could not check

The home feed did not render for me while signed out, so I confirmed the watch page only. Keeping the old selectors means that surface cannot regress either way.

The block comment above the rule mentions accompanying JS that expands the shortened time-ago text and restores the interpunct delimiter. I found no such JS in the repo, so 1mo ago stays short and the delimiter stays absent. That looks like a separate gap and I left it out of this change.


Tisankan Jeyakumar
Developed and verified

YouTube renamed the content metadata view-model classes from the
hyphenated "yt-content-metadata-view-model-wiz__" form to camelCase.
The classic thumbnail metadata rule still targeted the old names, so
the play-triangle icon in front of the view count came back on the
watch page sidebar.

Add the camelCase leading-icon selector and keep the old selectors for
surfaces still served the previous markup. Target the leading icon by
name instead of every icon in the row, so the channel verified badge
keeps rendering.

Closes code-charity#4278

@wahajahmed010 wahajahmed010 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

Small and focused fix. Adding the new ytContentMetadataViewModelMetadataRow .ytContentMetadataViewModelLeadingIcon selector to extend the existing rule to YouTube's renamed camelCase view-model classes is the right approach — and the decision to target the leading icon by name (instead of yt-icon) instead of all icons is well-considered, because it preserves the channel-verified badge rendering in the row. The expanded comment block above the selector explains the trade-off clearly; that's the kind of context that ages well.

A few small things:

1. No regression coverage

The PR is a CSS-only change, so no unit test would land here, but YouTube's HTML mutates frequently and this is exactly the kind of selector that silently regresses. Worth either:

  • adding a snapshot/visual check in the existing e2e flow that visits a watch page and asserts the leading icon is hidden when the feature toggle is on, or
  • at minimum, a comment in general.css near the selector with the date and a link to YouTube's HTML release notes.

2. !important proliferation

The new selector inherits the existing display: none !important; rule. Both old and new selectors are now in the same rule body, which is fine. But once YouTube ships yet another rename (they do this every few months), this rule will keep growing. Consider whether it's worth splitting into two named rules with the shared !important — easier to grep and to remove selectively when old selectors are no longer needed.

3. Specificity parity

.ytContentMetadataViewModelMetadataRow .ytContentMetadataViewModelLeadingIcon matches the existing class-class specificity of the other selectors in the rule, so there are no specificity conflicts. Confirmed.

4. The new selector assumes the leading icon is always present

If YouTube ever omits ytContentMetadataViewModelLeadingIcon from a row layout (e.g., in a future "compact metadata" variant), this selector will silently no-op and the play-triangle icon will reappear. Consider adding a fallback to .ytContentMetadataViewModelMetadataRow yt-icon:first-child or similar so the rule degrades gracefully.

Overall: ship-it once the visual smoke check confirms the play-triangle is hidden and the verified badge is preserved in both the legacy and the new markup.

Automated review posted via the open-source-contributor pipeline.

@tisankanj

Copy link
Copy Markdown
Contributor Author

Thanks for reading it closely. Taking the four points in turn.

1. No regression coverage. Fair, and taken. The comment above the rule now carries the month the camelCase names were observed and an instruction for the next person: read the row markup and add the new name, rather than widening the rule to every icon. Pushed in 466c125. A visual check in the e2e flow would be better still, but that belongs in its own PR rather than bolted onto a one-selector fix.

2. !important proliferation. Leaving it. Splitting the rule into two named blocks touches four selectors this PR did not otherwise change, and the split only pays off when the legacy names are actually retired. That is the right moment to do it, and it is a separate change.

3. Specificity parity. Agreed, nothing to do.

4. Fallback to yt-icon:first-child. This one I would push back on, because it undoes the thing you identified as correct in your opening paragraph.

The rule already carries a broad legacy selector:

html[it-classic-thumbnail-metadata='true'] .yt-content-metadata-view-model-wiz__metadata-row yt-icon,

That hides every icon in the row on the old markup. Targeting the leading icon by name in the new markup is a deliberate departure from that, and adding yt-icon:first-child alongside it puts the broad behaviour straight back for anything that happens to render first in the row.

The scenario is also hypothetical. I have not seen a compact-metadata variant that omits ytContentMetadataViewModelLeadingIcon, so a fallback for it would be a guess at markup that does not exist yet. If it silently no-ops later, the play triangle reappears and is visible immediately, which is a better failure than quietly hiding the wrong icon. That is the trade the dated comment now records.

Happy to add the fallback if you can point me at a page serving that variant.

@RealKelpTheGreat

Copy link
Copy Markdown

So it looks like this is still awaiting approval, and the guidelines say "Workflow runs that have been awaiting approval for more than 30 days are automatically deleted." So is this getting close to being in danger of automatic deletion? Is there anything I can do to help with this that doesn't require advanced coding (or even basic, really)?

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

Copy link
Copy Markdown
Member

thank you! @tisankanj @RealKelpTheGreat

@RealKelpTheGreat

Copy link
Copy Markdown

@ImprovedTube2 Oh cool! I'd given up hope on this, thanks for sticking with it. I have a couple of problems to report, though:

First, it doesn't actually work. With the option on, the little "play arrow" icon next to the view count disappears, but that's it. It doesn't restore the full, classic formatting. The new formatting is: "► 42k 7mo ago". Before the YT update broke the option for this extension, the option was correctly changing that format to the classic, like: "42k views · 7 months ago". But now it's just putting it to "42k 7mo ago". All that's changed is the arrow is gone.

Second and arguably more importantly, it seems to have some coding bugs in it, or something. I don't know exactly what's going on, all I can report is what happens: with a YT video page open but the video not buffering or playing, opening the extension options and toggling the classic metadata option off quickly increases the load on my CPU - I can hear the fans start to spin faster than normal, the RAM usage of the "Isolated Web Co" process triples, and the CPU usage of the same process goes from ~0.3% to over 8%. This gradually settles down over time, but the mere fact that it happens at all is concerning. Why would deactivating an option so massively drain computer resources? Also, before I took it slowly and experimented with it to be able to write out this bug report, the first time I was trying the option toggle to see if it was working, I clicked it on and off several times, which used even more system resources and outright froze the entire web browser (latest version of Firefox, desktop); I had to kill the processes via the system monitor.

@tisankanj

Copy link
Copy Markdown
Contributor Author

@RealKelpTheGreat you are right on the first point, and the cause is deeper than this PR. Thanks for the detailed report.

Why only the arrow changed. This option is CSS only. Nothing in the extension rewrites the text, so it cannot produce "42k views - 7 months ago" no matter which classes the CSS matches. Checked three ways on current master:

grep "classic.thumbnail.metadata"   -> general.css (the rule) and menu/skeleton-parts/general.js (the toggle). Nothing else.
grep "ContentMetadataViewModel|content-metadata-view-model|metadata-row"  in all .js  -> no matches
grep "months ago"  in all .js  -> appearance.js:918, which belongs to how_long_ago_the_video_was_uploaded on the watch page

The comment above the rule says "The accompanying JS expands the shortened time-ago text and restores the interpunct delimiter". That JS is not in the repo. The comment predates this PR, and I should have checked it rather than trusting it.

So this PR did what its title says, restoring the icon rule after YouTube renamed the classes to camelCase, and that is the arrow you saw disappear. The other half of the feature is missing, which is the behaviour you are describing. I will open a follow-up PR that restores the text, written to run off the existing row markup rather than a new observer per thumbnail.

On the CPU and the freeze. I cannot reproduce that yet, so I will not guess at a cause, but one thing is worth knowing. Toggling any of these options writes an attribute on the html element (js&css/extension/core.js:274), which forces a restyle of the whole document. On a feed with many thumbnails that is expensive, and it is the same cost for every option in this family, not something this selector adds. Whether that alone explains tripled memory and a frozen window I do not know.

Two things would help me pin it: does the same spike happen when you toggle an unrelated CSS-only option, and is it Firefox only. If it happens on any option, it is the toggle path rather than this feature, and it deserves its own issue.


Tisankan Jeyakumar
Verified review

@RealKelpTheGreat

Copy link
Copy Markdown

All right, thanks @tisankanj! Glad you're looking into it and following up on it!

"Two things would help me pin it: does the same spike happen when you toggle an unrelated CSS-only option, and is it Firefox only. If it happens on any option, it is the toggle path rather than this feature, and it deserves its own issue."
I'd be happy to help you pin this down, could you give me a few examples of unrelated CSS-only options that I can try toggling and see if the behavior is similar? There are hundreds of options in the extension and I have no clue which ones would be CSS-only.

@RealKelpTheGreat

Copy link
Copy Markdown

Still willing to help if you're able to tell me what to try! I'll check back again later.

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.

🐞Classic thumbnail metadata toggle no longer working for thumbnail links below a watched video

4 participants