Skip to content

feat(appearance): focus/zen mode — dim or hide everything except the player (#4093) - #4482

Open
chirag127 wants to merge 3 commits into
code-charity:masterfrom
chirag127:feat/zen
Open

chirag127 wants to merge 3 commits into
code-charity:masterfrom
chirag127:feat/zen

Conversation

@chirag127

Copy link
Copy Markdown

Closes #4093.

What this adds

A Zen mode with two levels, set from Appearance → Zen mode:

  • Dim everything except the player — the sidebar, comments, metadata and header fade to 20% and come back on hover.
  • Hide everything except the player — those same regions are removed and the player area is allowed to fill the width.

When either mode is on, a small Exit Zen pill appears at the top right; Escape also leaves it. Both paths write zen_mode = off through the normal storage bridge, so the menu switch follows.

Why CSS

The page regions are stable YouTube element ids (ytd-masthead, #secondary, #comments, #below, #guide). Doing this in CSS means the setting applies before the page paints, with no layout script, no observer and no per-navigation work. Every rule is scoped to html[it-zen-mode="…"], the attribute the extension already writes for each stored setting; nothing is styled unless the user turns it on.

The only JavaScript is the exit control (features/zen.js), because a CSS-only feature has no way back out.

Where it lives

File Change
js&css/extension/www.youtube.com/features/zen.css new, all rules scoped to html[it-zen-mode]
js&css/web-accessible/www.youtube.com/features/zen.js new, Exit pill + Escape
menu/skeleton-parts/zen.js new menu button under Appearance
_locales/en/messages.json three keys
manifest.json one CSS entry, one resource entry
js&css/extension/init.js, menu/index.html one line each
tests/unit/zen-mode.test.js 5 tests

No existing feature file is edited.

Verification

$ npx jest tests/unit/zen-mode.test.js
Tests: 5 passed, 5 total
  - inactive when off / missing
  - active in dim and hide
  - exit writes {action:"set",key:"zen_mode",value:"off"}
  - every CSS selector contains it-zen-mode
  - the menu exposes off, dim and hide

$ npx jest
Test Suites: 40 passed, 40 total
Tests:       241 passed, 241 total

Live check in Chrome 157 on youtube.com/watch, with the CSS injected and it-zen-mode="hide":

masthead: "none"  secondary: "none"  comments: "none"  below: "none"
Exit Zen button present; clicking it sent
{"action":"set","key":"zen_mode","value":"off"} and removed the button.

Screenshot (hide mode, bright video so the player is visible):

Zen mode

Not tested

  • Firefox and Safari builds. The CSS uses no vendor-specific features; the JS uses document, CustomEvent and the existing message bridge.
  • The bottom-right "Multiselect" pill in the screenshot is a separate userscript in the test browser, not part of this change.

Conflicts

No open PR touches features/zen.css, features/zen.js, menu/skeleton-parts/zen.js or tests/unit/zen-mode.test.js. The shared edits are one line each. The attribute is namespaced (it-zen-mode) and the feature is off by default.

CSS-only dim and hide modes scoped to html[it-zen-mode], plus a floating
Exit Zen control and Escape as ways out. Off by default; no new
permissions and no network requests.
@chirag127
chirag127 marked this pull request as ready for review November 18, 2026 10:23
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.

Focus/Zen mode: dim everything except the video player

1 participant