Greasy Fork

Greasy Fork is available in English.

YouTube Layout Plus

Home: collapse guide, fixed hero layout for the first 5 videos, then 4/5 col grid below, hide Shorts. Flat chip bar. Watch: hide recommendations sidebar and center the player/content, while preserving live chat on streams/replays and engagement panels. Adds topbar theme and home grid switchers.

这些是此脚本变更过代码的版本。 显示所有版本。

  • v0.4.1 2026-05-04

    窄布局 bug 修正

  • v0.4 2026-05-04
  • v0.3.53 2026-05-04

    更新页面缩放以后的显示体验

  • v0.3.26 2026-05-03

    修改首页布局

  • v0.2.20 2026-04-28

    更新日志(0.2.18 → 0.2.20)
    0.2.20 — 剧场模式播放器尺寸修复
    🐛 修复
    剧场模式下播放器没填满,右侧出现大块黑边:syncWatchPlayerSize 之前固定测量 #player(默认布局的播放器容器),但剧场模式下 #movie_player 已经被移到 #player-theater-container 里,#player 还残留在 #primary 里被我们的 width: min(1400px, ...) 约束着 → 测出 1400px → 强行调用 setInternalSize(1400, ...) 把已经在全宽剧场容器里的播放器又缩回 1400,于是右边露出剧场容器的黑底。 改为 moviePlayer.closest('#player-theater-container, #player-full-bleed-container, #player') 跟着 #movie_player 当前所在容器测量,剧场拿剧场容器,默认拿默认容器,迷你播放器 / 无匹配容器直接 return。
    ✨ 改进
    全屏时不再越权:syncWatchPlayerSize 加 document.fullscreenElement 守卫,全屏交给 YouTube 自己处理,避免和原生全屏逻辑打架。
    状态切换强制重测:剧场 / 章节面板 / 聊天面板状态翻转时主动 lastPlayerSyncKey = '',下一次 sync 一定执行。
    剧场动画兼容:进出剧场时排两次 sync(120ms + 360ms),分别 catch YouTube 剧场动画进行中和结束后两个时间点。
    syncKey 加入容器 ID:剧场进出会让 key 自然变化,触发重新测量。
    schedulePlayerSync 行为修正:之前重复调用会互相 cancel,现在 delay>0 允许多次叠加。
    0.2.19 — 剧场模式开关可读性 & T 键支持
    🐛 修复
    Light 主题 + 剧场模式下顶栏开关变黑底黑字看不见:剧场模式下 YouTube 把 masthead 区域涂暗(不管 Light/Dark 主题都会暗),但我们的开关用的是 --yt-spec-text-primary(Light 模式下是黑色 #0f0f0f)→ 黑字盖在黑底上失明。 新增检测 ytd-watch-flexy[theater] → 切换 tm-youtube-layout-plus-watch-theater class → CSS 强制把开关的边框、文字、hover、active 配色全部换成"亮色 on 暗底",不管当前主题。
    ✨ 改进
    T 键监听:用键盘 T 切换剧场模式时也能即时响应(除了点剧场按钮)。在输入框 / 可编辑区域内按 T 不触发。
    状态翻转时同步播放器尺寸:剧场切换时也调用 syncWatchPlayerSize(虽然 0.2.20 才发现尺寸算错了…)。
    路由切换清理:离开观看页时主动清除 tm-youtube-layout-plus-watch-theater class 和 lastTheaterMode 状态。
    0.2.18 — 章节 / 转写 / 描述 / 评论面板保留
    🐛 修复
    观看页章节按钮、转写、描述、评论面板被一起隐藏:之前 CSS 把整个 #secondary 列直接 display: none,连带把所有 engagement panel 都藏了,用户点章节按钮没反应。 改为:
    #related / ytd-watch-next-secondary-results-renderer(推荐列表)始终隐藏 —— 这是脚本的核心目的,不变。
    #secondary / #secondary-inner 仅在没有 engagement panel 展开时隐藏。一旦有 panel 打开(章节 / 转写 / 描述 / 评论 / 剪辑创建器都用 ytd-engagement-panel-section-list-renderer[visibility="ENGAGEMENT_PANEL_VISIBILITY_EXPANDED"]),CSS 让 YouTube 原生两栏布局接管,panel 正常显示。
    ✨ 改进
    新增 hasOpenEngagementPanel() + updateWatchEngagementPanelState():检测 panel 是否展开并切换 tm-youtube-layout-plus-watch-panel-open class;状态翻转时同步播放器尺寸。
    多重触发:applyWatchLayout 调用 + startWatchChatStateSync 500ms 轮询兜底 + 点击任何按钮后 120ms 复查,覆盖各种打开 / 关闭 panel 的入口。
    路由切换清理:离开观看页时清除 WATCH_PANEL_OPEN_CLASS 和 lastEngagementPanelOpen。

  • v0.2.18 2026-04-24

    修正章节无法弹出的 bug

  • v0.2.17 2026-04-23

    更新日志 / Changelog
    0.2.17 — 2026-04-23
    🐛 修复
    主题状态识别不准:PREF cookie 的 f6 字段改为按位解码(0x80 偏好位 / 0x400 暗色位 / 0x80000 亮色位),彻底修复了某些 f6 组合下顶栏按钮高亮错位、或误判为 Auto 的问题。
    Auto 模式下误报切换失败:验证逻辑不再要求 与系统 prefers-color-scheme 一致,只校验 cookie。避免系统主题过渡期内误弹红色错误提示。
    直播回放提示节点被跨视频残留:改用 CSS class 隐藏,路由切换时统一清理;解决旧视频的 "Live chat replay" 提示在新视频上继续隐藏正常 teaser 的问题。
    live_chat iframe 跨域访问隐患:新增 safeGetIframeDocument() 包装,避免 YouTube 未来若把 iframe 换到不同源时整个脚本抛错。
    ⚡ 性能
    首页滚动时的 CPU 占用:MutationObserver 回调从"每次 rAF 立即 apply"改为 150ms debounce,首页缩略图懒加载高频触发的情况下,apply 次数降低一个数量级。
    避免无谓的 DOM 写入:updateThemeSwitcherUI / updateHomeGridSwitcherUI / persistThemeMode 加 last-rendered 缓存,状态未变时直接返回;localStorage 不再被每帧反复写入同一个值。
    去除布局 class 的抖动:applyLayout 改为 diff 式切换(setLayoutModeClasses),只添加/移除真正变更的 class,不再先全量清空再重加,消除了 CSS 过渡的无谓重触发。
    ✨ 改进
    列数切换即时生效:点击 4/5 列按钮后自动 dispatch resize 事件,触发 YouTube 原生 ytd-rich-grid-renderer 的重新测量,不必再滚动或调整窗口大小才能生效。
    路由轮询降级:yt-navigate-finish 和 popstate 已覆盖所有 SPA 路由,兜底轮询间隔从 1 秒放宽到 3 秒,减少闲时定时器开销。
    非首页/观看页路由清理:跳转到 /shorts、/channel/...、/results 等路由时主动清除布局 class,防止上一次留下的 CSS 影响这些页面。
    🧹 代码整理
    showThemeStatusMessage.hideTimer(挂在函数对象上的定时器句柄)改为模块级的 let themeStatusHideTimer,读起来更直白。
    提取常量:OBSERVER_APPLY_DEBOUNCE_MS、ROUTE_POLL_INTERVAL_MS、PREF_F6_*_BIT、LAYOUT_MODE_CLASSES。
    0.2.16 — 2026-04-23
    🐛 修复(重大)
    主题切换不稳定:彻底重写切换路径。此前的做法是"模拟点击头像菜单 → Appearance → 目标主题项 → Escape 关菜单",依赖 YouTube 的多页菜单懒加载时序、Escape 关闭行为、cookie 回写节奏,经常在以下场景失败:
    菜单还没渲染出选项就超时回滚;
    Escape 没关掉菜单,残留弹层遮挡页面;
    cookie 回写晚于校验轮询,误报"切换失败"红色提示;
    快速点两次时卡在 themeSwitchInFlight 状态。
    新版本改为直接向 ytd-app 派发 yt-action 事件(yt-signal-action-toggle-dark-theme-{on|off|device}),和官方 Appearance 菜单点击走的是同一个 reducer。全程不开菜单、不发 Escape、不依赖 DOM 懒加载。
    🧹 代码整理
    删除不再需要的辅助函数:findAccountMenuButton、findAppearanceMenuEntry、clickMenuEntry、closeOfficialThemeMenus、ensureOfficialThemeOptionsVisible、waitFor、getOfficialThemeOptions、detectThemeModeFromOptions 等。
    删除 THEME_BUSY_CLASS 及对应 CSS(不再需要遮挡临时打开的菜单)。
    verifyThemeMode 失败时改为静默重试一次再报错,容忍 cookie 异步写入延迟。

  • v0.2.15 2026-04-21

    v0.2.15

    Added a compact 4 / 5 home grid toggle next to the theme switcher for quickly changing the number of videos shown per row on the YouTube home page.
    Set the default home grid layout to 5 videos per row, with 4 available as an alternate compact layout option.
    Added persistent storage for the home grid preference so the selected layout is preserved after refresh or reopening YouTube.
    Updated the home grid rendering logic so the selected 4 or 5 column mode is applied dynamically instead of being hardcoded.
    Styled the new grid toggle to match the existing topbar controls, including filled active-state highlighting for the selected option.

  • v0.2.14 2026-04-21

    v0.2.14

    修复主题切换器在切换 Auto / Light / Dark 时会误触发右上角账号菜单的 bug,改进为更稳定地调用 YouTube 官方外观切换逻辑。
    优化主题切换稳定性,减少因菜单路径变化导致的切换失败或异常闪动。
    修复播放页在浏览器窗口缩小时,播放器尺寸不能及时跟随变化的问题。
    改善播放器缩放同步逻辑,减少缩放过程中的延迟感,并缓解缩小到较小尺寸时视频与播放窗口不匹配、出现裁切的情况。

    Fixed a bug where switching Auto / Light / Dark could unintentionally trigger the account menu in the top-right corner.
    Improved theme-switch stability by making the script follow YouTube’s official appearance switching flow more reliably.
    Fixed an issue where the player on watch pages did not resize correctly when the browser window was reduced.
    Improved player resize synchronization to reduce lag during window resizing and mitigate cases where the video no longer matched the player bounds and became cropped.

  • v0.2.7 2026-04-15

    v0.2.7

    改善视频加载后的布局同步效率,减少进入播放页后播放器放大延迟、画面尺寸跟随不及时的问题。
    优化 watch 页布局重试与状态同步机制,降低单页跳转后布局判定过早导致的显示异常。
    改善 Live 视频与 Live Chat Replay 页面的识别逻辑,避免直播页、直播回放页被误判成普通视频页。
    优化直播页面的聊天面板默认显示行为,进入页面时更稳定地保持默认折叠,并保留 Open panel 手动展开。
    修复部分直播页和搜索结果跳转进入直播页时,聊天面板未正确折叠或 Open panel 异常隐藏的问题。
    修复主题切换器稳定性问题,提升 Auto / Light / Dark 模式切换成功率。

    Improved post-load player layout sync to reduce delayed resizing after entering watch pages.
    Optimized watch-page retry and state-sync flow to avoid display glitches caused by early layout detection during SPA navigation.
    Improved detection for live streams and live chat replay pages to prevent them from being misclassified as regular videos.
    Refined default live-chat panel behavior so live pages collapse more reliably on load while preserving manual reopening through Open panel.
    Fixed cases where live pages or search-to-live navigations failed to collapse chat correctly or hid the Open panel unexpectedly.
    Fixed theme switcher reliability to improve Auto / Light / Dark switching behavior.

  • v0.2.6 2026-04-14
  • v0.2.4 2026-04-14
  • v0.2.3 2026-04-14
  • v0.2.2 2026-04-14
  • v0.2 2026-04-14
  • v0.1.16 2026-04-14

    v0.1.16

    修复直播页与普通视频页的右侧栏判定逻辑。普通视频继续隐藏推荐侧栏,直播页会正确识别并保留直播聊天能力。
    新增直播页聊天面板默认折叠。进入直播页面时,脚本会自动关闭一次已展开的聊天面板,让页面默认显示可点击的 Open panel,同时保留用户手动展开聊天的能力。
    优化单页路由切换下的状态重置,避免从直播页切换到普通视频后错误保留聊天相关状态。
    更新脚本元信息说明,明确直播/回放页面会保留并优化 live chat 行为。


    v0.1.16

    Fixed watch-page sidebar detection so regular videos still hide the recommendations sidebar, while live streams correctly preserve live chat support.
    Added default live-chat panel collapsing on live pages. When entering a live stream, the script closes the expanded chat panel once so the page starts with a clickable Open panel, while still allowing manual reopening by the user.
    Improved SPA route-change state resets to prevent live-chat state from leaking into normal watch pages after navigation.
    Updated the userscript metadata to explicitly describe preserved live chat behavior on live/stream pages.

  • v0.1.15 2026-04-13

    0.1.15
    • Fixed unwanted horizontal scrolling on watch pages when using Left/Right arrow keys.
    • Prevented the hidden secondary column from causing sideways page movement.
    • Left/Right arrow keys now reliably seek the video backward/forward on watch pages.
    • Excluded input boxes, textareas, and editable fields from key interception.
    • Improved overall watch page overflow handling and layout stability.

  • v0.1.14 2026-04-06
  • v0.1.9 2026-04-05
  • v0.1.8 2026-04-05
  • v0.1.8 2026-04-05
  • v0.1.8 2026-04-05

    更新日志

    中文

    本次更新主要集中在顶部分类栏和主题切换体验的打磨:

    • 优化主题切换稳定性,修复部分情况下切换失败、错位或状态不同步的问题
    • 首页顶部分类栏重做为更紧凑的连体标签栏样式
    • 为分类栏加入玻璃质感效果,包括半透明、模糊、高光和悬浮层次
    • 优化分类栏在亮色 / 暗色模式下的视觉适配
    • 修复分类栏与左右箭头的对齐问题
    • 修复分类栏悬浮后遮挡首页第一排内容的问题
    • 优化选中标签的位置、底部阴影和顶部轮廓等细节
    • 新增首页视频卡片 hover 轻微放大效果

    English

    This update mainly focuses on refining the top chip bar and theme-switching experience:

    • Improved theme-switching stability and fixed cases where switching could fail, desync, or land on the wrong state
    • Redesigned the homepage category chips into a more compact connected tab bar
    • Added a glass-style treatment to the chip bar, including translucency, blur, highlights, and floating depth
    • Improved chip bar styling in both light mode and dark mode
    • Fixed alignment issues between the chip bar and the left/right arrow buttons
    • Fixed cases where the floating chip bar could cover the first row of homepage content
    • Refined details such as selected-chip positioning, bottom shadow, and top outline
    • Added a subtle hover zoom effect for homepage video cards
  • v0.1.7 2026-04-05
  • v0.1.7 2026-04-05
  • v0.1.6 2026-04-05
  • v0.1.4 2026-04-03

    更新日志

    本次版本主要新增了两类更新:

    • 新增顶部快速主题切换开关,支持 Auto / Light / Dark
    • 主题切换直接调用 YouTube 官方 Appearance 功能,而不是自定义主题逻辑
    • 首页顶部分类标签样式重做,改为更紧凑的连体标签栏风格
    • 顶部标签栏补充了亮色与暗色模式适配
    • 优化了标签栏的对齐、间距和选中态视觉效果
    • 修复了主题切换状态不同步的问题
    • 修复了部分情况下 Auto / Light / Dark 切换不稳定的问题
    • 修复了首页视频卡片 hover 时背景被裁切的问题
    • 优化了首页视频区域与顶部标签栏之间的间距
    • 调整了首页视频卡片之间的间距,减少 hover 背景重叠

    整体上,这一版是在保留原有首页 5 列、隐藏 Shorts、播放页居中和隐藏推荐栏这些核心功能的基础上,进一步补强了顶部交互和视觉一致性,让桌面端 YouTube 更顺手、更稳定。


    This update mainly adds two groups of improvements:

    • Added a top quick theme switcher with Auto / Light / Dark
    • Theme switching now uses YouTube’s official Appearance behavior instead of a custom theme system
    • Redesigned the homepage category chips into a more compact connected tab bar
    • Added proper light-mode and dark-mode styling for the top chip bar
    • Improved chip bar alignment, spacing, and selected-state visuals
    • Fixed theme switcher state desync issues
    • Fixed unstable switching behavior in some Auto / Light / Dark transitions
    • Fixed homepage video hover backgrounds being clipped
    • Improved spacing between the top chip bar and the homepage video grid
    • Adjusted spacing between homepage video cards to reduce hover background overlap

    Overall, this version keeps the existing core features such as the 5-column homepage layout, hidden Shorts sections, and the centered watch page without the recommendation sidebar, while further improving top-bar usability, visual consistency, and stability on desktop YouTube.

  • v0.1.0 2026-03-30