Great question!
In the rule:
youtube.com##.ytp-quality-menu .ytp-menuitem:has(.ytp-premium-label)
The space between .ytp-quality-menu and .ytp-menuitem is very important in CSS selector logic (which is what uBlock Origin uses for cosmetic rules).
🔍 Meaning of the Space in CSS Selectors
In CSS (and uBlock Origin’s cosmetic filters), a space between two selectors means:
Select a descendant.
So:
.ytp-quality-menu .ytp-menuitem
translates to:
Select all .ytp-menuitem elements that are inside (at any level) an element with the class .ytp-quality-menu.
📚 Selector Breakdown With the Space
Let's break it down again:
.ytp-quality-menu — parent container (the quality menu)
- space — "inside of"
.ytp-menuitem — any menu item inside that menu
And then:
:has(.ytp-premium-label) — only keep the items that have a .ytp-premium-label somewhere inside them
❌ What Happens Without the Space?
If you remove the space (e.g., youtube.com##.ytp-quality-menu.ytp-menuitem:has(...)), then:
- You’re looking for an element that has both classes at the same time —
.ytp-quality-menu and .ytp-menuitem on the same element, which wouldn't apply to YouTube's structure.
This would likely do nothing, because such an element probably doesn’t exist.
✅ Summary
| Selector | Meaning |
|---|
.a .b | Select elements with class .b that are inside elements with class .a. |
.a.b | Select elements that have both class .a and class .b on the same element. |
So in your rule:
youtube.com##.ytp-quality-menu .ytp-menuitem:has(.ytp-premium-label)
The space ensures the adblocker targets .ytp-menuitem elements sitting within the .ytp-quality-menu, not elements that have both classes.
Let me know if you want a visual example or want help inspecting YouTube's HTML structure!