YouTube Layout Fix

Forces 6 videos per row, adjusts text/spacing, hides checkmarks, & search chapters. Optionally hides all Shorts content **(shelves, search items, sidebar button)**. Fixes scrollbars & player buttons. Hides unrelated search shelves and ensures consistent **playlist & channel** layouts.

  1. // ==UserScript==
  2. // @name YouTube Layout Fix
  3. // @namespace http://tampermonkey.net/
  4. // @version 4.82
  5. // @description Forces 6 videos per row, adjusts text/spacing, hides checkmarks, & search chapters. Optionally hides all Shorts content **(shelves, search items, sidebar button)**. Fixes scrollbars & player buttons. Hides unrelated search shelves and ensures consistent **playlist & channel** layouts.
  6. // @author Kalakaua
  7. // @match https://www.youtube.com/*
  8. // @grant GM_addStyle
  9. // @run-at document-idle
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // --- ADJUSTABLE VALUES (User Prefs) ---
  17.  
  18. // === General Grid Layout (Home, Subs, Channel Pages, etc.) ===
  19. const desiredColumnCount = 6; // Number of columns for main content grids
  20. const gridEdgePadding = "24px"; // Padding on the left/right edges of the main grids
  21. const gridItemHorizontalMargin= "6px"; // Space between grid items horizontally
  22. const gridItemBottomMargin = "24px"; // Space below each grid item
  23.  
  24. // === Grid Items - Text & Spacing ===
  25. const gridTitleScale = 1.12; // Title text size multiplier
  26. const gridChannelScale = 0.85; // Channel name text size multiplier
  27. const gridMetadataScale = 0.85; // Views/Date text size multiplier
  28. const gridChannelMarginTop = "-1px"; // Space above channel name
  29. const gridMetaMarginTop = "-4px"; // Space above views/date line
  30.  
  31. // === Search Results Page (/results) - Layout ===
  32. const searchThumbnailWidth = "350px"; // Width of video/playlist thumbnails
  33. const searchResultsInitialMarginTop = "16px"; // Space above the very first search result section
  34. const searchResultsSectionMarginBottom = "16px"; // Space below each section of results (videos, playlists, etc.)
  35. const searchDescFixedWidth = "800px"; // Fixed width for description snippets to help align 3-dot menus
  36.  
  37. // === Search Results Page - Text Sizes ===
  38. const searchTitleScale = 1.4; // Scale factor for video, playlist, and channel titles
  39. const searchChannelScale = 1.20; // Scale factor for channel names listed under video results
  40. const searchVideoViewsDateScale = 1.4; // Scale factor for video views/date and the first metadata line of playlists
  41. const searchMetaSnippetScale = 1.35; // Scale factor for subsequent playlist metadata rows (video list)
  42. const searchChannelSubMetaScale = 1.0; // Scale factor for a channel item's subscriber count and @handle
  43.  
  44. // === Search Results Page - Channel Item Layout ===
  45. const searchChannelAvatarMaxWidth = "362px"; // Max width for the channel avatar container
  46. const searchChannelTextMaxWidth = "630px"; // Max width for the channel text container (title, subs, desc)
  47.  
  48. // === Watch Page - Below Video Player ===
  49. const watchOwnerChannelScale = 1.5; // Scale factor for the channel name under the video
  50. const watchTopRowMarginTop = "-4px"; // Space above the views/date line under the video title
  51. const watchSubCountMarginTop = "-3.5px";// Space above the subscriber count
  52.  
  53. // === Sidebar (Watch Page Right Sidebar) ===
  54. const sidebarTitleScale = 1.05; // Scale factor for video titles in the sidebar
  55. const sidebarChannelNameScale = 1.0; // Scale factor for channel names in the sidebar
  56. const sidebarViewsDateScale = 1.0; // Scale factor for views/date in the sidebar
  57. const sidebarTitleMarginBottom= "6px"; // Space below sidebar video titles
  58. const sidebarBadgeScale = 0.85; // Scale factor for badges (e.g., "New")
  59. const sidebarBadgeMarginTop = "2px"; // Space above badges
  60. const sidebarBadgeMarginBottom= "0px"; // Space below badges
  61.  
  62. // === Comment Section (Watch Page) ===
  63. const commentTextScale = 1.15; // Scale factor for main comment and reply text
  64. const commentMetaScale = 1.1; // Scale factor for author/timestamp metadata
  65.  
  66. // --- Technical Values ---
  67. const minimalPxReduction = "0.01px"; // Minimal reduction for calc() robustness in grid width calculation
  68.  
  69. // --- END OF ADJUSTABLE VALUES ---
  70.  
  71.  
  72. let css = `
  73. :root {
  74. --gm-grid-title-size: ${gridTitleScale}em;
  75. --gm-grid-channel-size: ${gridChannelScale}em;
  76. --gm-grid-metadata-size: ${gridMetadataScale}em;
  77. --gm-watch-owner-channel-size: ${watchOwnerChannelScale}em;
  78. --gm-watch-title-size: 1.5rem;
  79. --gm-sidebar-title-size: ${sidebarTitleScale}em;
  80. --gm-sidebar-channel-size: ${sidebarChannelNameScale}em;
  81. --gm-sidebar-viewsdate-size: ${sidebarViewsDateScale}em;
  82. --gm-sidebar-badge-size: ${sidebarBadgeScale}em;
  83. --gm-search-title-scale: ${searchTitleScale};
  84. --gm-search-channel-scale: ${searchChannelScale};
  85. --gm-search-title-size: calc(1.0rem * var(--gm-search-title-scale));
  86. --gm-search-channel-size: calc(0.8em * var(--gm-search-channel-scale));
  87. --gm-search-metasnippet-size: calc(0.8em * ${searchMetaSnippetScale});
  88. --gm-search-video-views-date-size: calc(0.78rem * ${searchVideoViewsDateScale});
  89. --gm-search-channel-submeta-size: calc(0.8em * ${searchChannelSubMetaScale});
  90. --gm-comment-text-final-size: calc(1rem * ${commentTextScale});
  91. --gm-comment-meta-final-size: calc(0.8rem * ${commentMetaScale});
  92. }
  93. #contents.ytd-rich-grid-renderer { padding-left: ${gridEdgePadding} !important; padding-right: ${gridEdgePadding} !important; box-sizing: border-box !important; width: 100% !important; }
  94. ytd-browse[page-subtype="channels"] #contents.ytd-rich-grid-renderer, ytd-browse[page-subtype="channels"] ytd-item-section-renderer #contents > ytd-rich-grid-renderer { padding-left: ${gridEdgePadding} !important; padding-right: ${gridEdgePadding} !important; box-sizing: border-box !important; width: 100% !important; }
  95. #contents.ytd-rich-grid-renderer > ytd-rich-item-renderer:not( ytd-browse[page-subtype="home"] #contents.ytd-rich-grid-renderer > ytd-rich-item-renderer, ytd-browse[page-subtype="subscriptions"] #contents.ytd-rich-grid-renderer > ytd-rich-item-renderer, ytd-browse[page-subtype="channels"] #contents.ytd-rich-grid-renderer > ytd-rich-item-renderer ) { margin-left: ${gridItemHorizontalMargin} !important; margin-right: ${gridItemHorizontalMargin} !important; margin-bottom: ${gridItemBottomMargin} !important; max-width: calc(100% / ${desiredColumnCount} - ${gridItemHorizontalMargin} * 2 - ${minimalPxReduction}) !important; }
  96. #contents.ytd-rich-grid-renderer ytd-rich-item-renderer:not(...) .yt-lockup-metadata-view-model-wiz__title { font-size: var(--gm-grid-title-size) !important; line-height: 1.2em !important; max-height: 2.4em !important; overflow: hidden !important; text-overflow: ellipsis !important; display: -webkit-box !important; -webkit-line-clamp: 2 !important; -webkit-box-orient: vertical !important; margin-bottom: 1px !important; }
  97. #contents.ytd-rich-grid-renderer ytd-rich-item-renderer:not(...) .yt-content-metadata-view-model-wiz__metadata-text { font-size: var(--gm-grid-metadata-size) !important; line-height: 1.3em !important; display: inline !important; }
  98. #contents.ytd-rich-grid-renderer ytd-rich-item-renderer:not(...) .yt-lockup-metadata-view-model-wiz__metadata { margin-top: ${gridMetaMarginTop} !important; line-height: 1.3em; }
  99. #contents.ytd-rich-grid-renderer ytd-rich-item-renderer:not(...) a.yt-core-attributed-string__link--call-to-action-color { font-size: 0.9em !important; margin-top: 2px !important; }
  100. ytd-browse[page-subtype="home"] #contents.ytd-rich-grid-renderer > ytd-rich-item-renderer, ytd-browse[page-subtype="subscriptions"] #contents.ytd-rich-grid-renderer > ytd-rich-item-renderer, ytd-browse[page-subtype="channels"] #contents.ytd-rich-grid-renderer > ytd-rich-item-renderer { margin-left: ${gridItemHorizontalMargin} !important; margin-right: ${gridItemHorizontalMargin} !important; margin-bottom: ${gridItemBottomMargin} !important; max-width: calc(100% / ${desiredColumnCount} - ${gridItemHorizontalMargin} * 2 - ${minimalPxReduction}) !important; border: none !important; }
  101. ytd-browse[page-subtype="home"] ytd-rich-item-renderer #video-title.ytd-rich-grid-media, ytd-browse[page-subtype="subscriptions"] ytd-rich-item-renderer #video-title.ytd-rich-grid-media, ytd-browse[page-subtype="channels"] ytd-rich-item-renderer #video-title.ytd-rich-grid-media { font-size: var(--gm-grid-title-size) !important; line-height: 1.2em !important; max-height: 2.4em !important; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-bottom: 1px !important; }
  102. ytd-browse[page-subtype="home"] ytd-rich-item-renderer #byline-container, ytd-browse[page-subtype="subscriptions"] ytd-rich-item-renderer #byline-container, ytd-browse[page-subtype="channels"] ytd-rich-item-renderer #byline-container { white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; display: flex !important; align-items: center !important; margin-top: ${gridChannelMarginTop} !important; line-height: 1.2em !important; gap: 0 !important; }
  103. ytd-browse[page-subtype="home"] ytd-rich-item-renderer ytd-channel-name, ytd-browse[page-subtype="subscriptions"] ytd-rich-item-renderer ytd-channel-name, ytd-browse[page-subtype="channels"] ytd-rich-item-renderer ytd-channel-name { font-size: var(--gm-grid-channel-size) !important; line-height: 1.25em !important; display: inline-block !important; overflow: hidden !important; text-overflow: ellipsis !important; flex-grow: 1 !important; min-width: 0 !important; margin: 0 !important; padding: 0 !important; vertical-align: baseline !important; }
  104. ytd-browse[page-subtype="home"] ytd-rich-item-renderer #metadata-line, ytd-browse[page-subtype="subscriptions"] ytd-rich-item-renderer #metadata-line, ytd-browse[page-subtype="channels"] ytd-rich-item-renderer #metadata-line { line-height: 1.3em !important; margin-top: ${gridMetaMarginTop} !important; display: block !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
  105. ytd-browse[page-subtype="home"] ytd-rich-item-renderer #metadata-line > span, ytd-browse[page-subtype="subscriptions"] ytd-rich-item-renderer #metadata-line > span, ytd-browse[page-subtype="channels"] ytd-rich-item-renderer #metadata-line > span { font-size: var(--gm-grid-metadata-size) !important; line-height: 1.2em !important; display: inline !important; vertical-align: baseline !important; }
  106. ytd-browse[page-subtype="home"] ytd-rich-item-renderer #metadata-line > span:first-of-type, ytd-browse[page-subtype="subscriptions"] ytd-rich-item-renderer #metadata-line > span:first-of-type, ytd-browse[page-subtype="channels"] ytd-rich-item-renderer #metadata-line > span:first-of-type { margin-right: 0.5em !important; }
  107. ytd-browse[page-subtype="home"] ytd-rich-item-renderer #metadata-line > span:first-of-type::after, ytd-browse[page-subtype="subscriptions"] ytd-rich-item-renderer #metadata-line > span:first-of-type::after, ytd-browse[page-subtype="channels"] ytd-rich-item-renderer #metadata-line > span:first-of-type::after { content: none !important; }
  108. ytd-browse[page-subtype="channels"] #contents.ytd-rich-grid-renderer ytd-grid-video-renderer, ytd-browse[page-subtype="channels"] ytd-item-section-renderer #contents > ytd-rich-grid-renderer ytd-grid-video-renderer { margin-left: ${gridItemHorizontalMargin} !important; margin-right: ${gridItemHorizontalMargin} !important; margin-bottom: ${gridItemBottomMargin} !important; max-width: calc(100% / ${desiredColumnCount} - ${gridItemHorizontalMargin} * 2 - ${minimalPxReduction}) !important; }
  109. ytd-browse[page-subtype="channels"] ytd-grid-video-renderer #video-title { font-size: var(--gm-grid-title-size) !important; line-height: 1.2em !important; max-height: 2.4em !important; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-bottom: 1px !important; }
  110. ytd-browse[page-subtype="channels"] ytd-grid-video-renderer #metadata-line { line-height: 1.3em !important; margin-top: ${gridMetaMarginTop} !important; display: block !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
  111. ytd-browse[page-subtype="channels"] ytd-grid-video-renderer #metadata-line > span { font-size: var(--gm-grid-metadata-size) !important; line-height: 1.2em !important; display: inline !important; vertical-align: baseline !important; }
  112. ytd-browse[page-subtype="channels"] ytd-grid-video-renderer #metadata-line > span:first-of-type { margin-right: 0.5em !important; }
  113. ytd-browse[page-subtype="channels"] ytd-grid-video-renderer #metadata-line > span:first-of-type::after { content: none !important; }
  114. ytd-rich-shelf-renderer #contents > ytd-rich-item-renderer { margin-left: ${gridItemHorizontalMargin} !important; margin-right: ${gridItemHorizontalMargin} !important; margin-bottom: ${gridItemBottomMargin} !important; max-width: calc(100% / ${desiredColumnCount} - ${gridItemHorizontalMargin} * 2 - ${minimalPxReduction}) !important; }
  115. ytd-badge-supported-renderer:has(.badge.badge-style-type-verified) { display: none !important; }
  116. ytd-app { overflow-x: hidden !important; }
  117. html.fullscreen, html.fullscreen body { overflow-x: hidden !important; }
  118. .ytp-fullscreen-button::after, #contentContainer::after, .ytp-play-button::before { content: none !important; }
  119.  
  120. /* ========================================================== */
  121. /* === SEARCH RESULTS PAGE (/results) === */
  122. /* ========================================================== */
  123. ytd-search ytd-item-section-renderer {
  124. margin-bottom: ${searchResultsSectionMarginBottom} !important;
  125. margin-top: 0 !important;
  126. }
  127. ytd-search ytd-item-section-renderer:first-of-type {
  128. margin-top: ${searchResultsInitialMarginTop} !important;
  129. }
  130.  
  131. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] {
  132. display: flex !important;
  133. margin-bottom: 0 !important;
  134. align-items: flex-start !important;
  135. }
  136. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] #dismissible ytd-thumbnail.ytd-video-renderer { width: ${searchThumbnailWidth} !important; min-width: ${searchThumbnailWidth} !important; max-width: ${searchThumbnailWidth} !important; flex-basis: ${searchThumbnailWidth} !important; flex-shrink: 0 !important; }
  137. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] #dismissible div.text-wrapper.ytd-video-renderer { margin-left: 12px !important; flex: 1 !important; min-width: 0; }
  138. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] a#video-title.ytd-video-renderer yt-formatted-string { font-size: var(--gm-search-title-size) !important; line-height: 1.25em !important; max-height: 2.5em !important; -webkit-line-clamp: 2 !important; display: -webkit-box !important; -webkit-box-orient: vertical !important; overflow: hidden !important; text-overflow: ellipsis !important; margin-bottom: 3px !important; }
  139.  
  140. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] #metadata-line.ytd-video-meta-block span.inline-metadata-item {
  141. font-size: var(--gm-search-video-views-date-size) !important;
  142. line-height: 1.3em !important;
  143. }
  144.  
  145. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] #channel-name.ytd-video-renderer yt-formatted-string > a, ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] #channel-name.ytd-video-renderer yt-formatted-string { font-size: var(--gm-search-channel-size) !important; line-height:1.3em !important; }
  146. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] #channel-thumbnail.ytd-video-renderer { width: 20px !important; height: 20px !important; }
  147.  
  148. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] .metadata-snippet-container.ytd-video-renderer yt-formatted-string.metadata-snippet-text,
  149. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] .metadata-snippet-container-one-line.ytd-video-renderer yt-formatted-string.metadata-snippet-text {
  150. font-size: 1.2rem !important;
  151. line-height: 1.3em !important;
  152. max-height: 2.6em !important;
  153. overflow: hidden !important;
  154. display: -webkit-box !important;
  155. -webkit-line-clamp: 2 !important;
  156. -webkit-box-orient: vertical !important;
  157. }
  158. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] .metadata-snippet-container.ytd-video-renderer,
  159. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] .metadata-snippet-container-one-line.ytd-video-renderer {
  160. width: ${searchDescFixedWidth} !important;
  161. min-width: ${searchDescFixedWidth} !important;
  162. max-width: ${searchDescFixedWidth} !important;
  163. display: block !important;
  164. margin-top: 4px !important;
  165. }
  166. ytd-search ytd-item-section-renderer ytd-video-renderer[is-search] #expandable-metadata.ytd-video-renderer { display: none !important; }
  167.  
  168. /* --- Playlist Item Styling in Search Results --- */
  169. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-view-model-wiz--horizontal {
  170. display: flex !important;
  171. align-items: flex-start !important;
  172. margin-bottom: 0 !important;
  173. }
  174. ytd-search ytd-item-section-renderer yt-lockup-view-model a.yt-lockup-view-model-wiz__content-image {
  175. width: ${searchThumbnailWidth} !important;
  176. min-width: ${searchThumbnailWidth} !important;
  177. max-width: ${searchThumbnailWidth} !important;
  178. flex-basis: ${searchThumbnailWidth} !important;
  179. flex-shrink: 0 !important;
  180. margin-right: 12px !important;
  181. }
  182. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-view-model-wiz__metadata {
  183. position: relative !important;
  184. width: ${searchDescFixedWidth} !important;
  185. min-width: ${searchDescFixedWidth} !important;
  186. max-width: ${searchDescFixedWidth} !important;
  187. flex-shrink: 0;
  188. }
  189. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-metadata-view-model-wiz {
  190. width: 100%;
  191. }
  192. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-metadata-view-model-wiz__text-container {
  193. width: 100% !important;
  194. padding-right: 44px !important;
  195. box-sizing: border-box !important;
  196. }
  197. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-metadata-view-model-wiz__menu-button {
  198. position: absolute !important;
  199. top: -11px !important;
  200. right: 0px !important;
  201. width: 40px !important;
  202. height: 40px !important;
  203. z-index: 5 !important;
  204. display: flex !important;
  205. align-items: center !important;
  206. justify-content: center !important;
  207. }
  208. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-metadata-view-model-wiz__menu-button button-view-model > button.yt-spec-button-shape-next {
  209. width: 40px !important;
  210. height: 40px !important;
  211. padding: 8px !important;
  212. box-sizing: border-box !important;
  213. display: flex !important;
  214. align-items: center !important;
  215. justify-content: center !important;
  216. }
  217. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-metadata-view-model-wiz__menu-button button-view-model > button.yt-spec-button-shape-next .yt-spec-button-shape-next__icon {
  218. margin: 0 !important;
  219. }
  220. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-lockup-metadata-view-model-wiz__title { font-size: var(--gm-search-title-size) !important; line-height: 1.25em !important; max-height: 2.5em !important; -webkit-line-clamp: 2 !important; display: -webkit-box !important; -webkit-box-orient: vertical !important; overflow: hidden !important; text-overflow: ellipsis !important; margin-bottom: 4px !important; }
  221.  
  222. ytd-search ytd-item-section-renderer yt-lockup-view-model yt-lockup-metadata-view-model .yt-content-metadata-view-model-wiz > .yt-content-metadata-view-model-wiz__metadata-row:not(:first-of-type) .yt-content-metadata-view-model-wiz__metadata-text {
  223. font-size: var(--gm-search-metasnippet-size) !important;
  224. line-height: 1.3em !important;
  225. }
  226. ytd-search ytd-item-section-renderer yt-lockup-view-model yt-lockup-metadata-view-model .yt-content-metadata-view-model-wiz > .yt-content-metadata-view-model-wiz__metadata-row:first-of-type .yt-content-metadata-view-model-wiz__metadata-text {
  227. font-size: var(--gm-search-video-views-date-size) !important;
  228. line-height: 1.3em !important;
  229. }
  230.  
  231. ytd-search ytd-item-section-renderer yt-lockup-view-model .yt-content-metadata-view-model-wiz__metadata-row { margin-bottom: 2px; }
  232.  
  233. /* === CHANNEL RENDERER STYLING IN SEARCH === */
  234. ytd-search ytd-item-section-renderer ytd-channel-renderer {
  235. display: block;
  236. margin-bottom: 0 !important;
  237. width: 100%;
  238. }
  239. ytd-search ytd-item-section-renderer ytd-channel-renderer #content-section {
  240. display: flex !important;
  241. flex-direction: row !important;
  242. align-items: flex-start !important;
  243. }
  244. ytd-search ytd-item-section-renderer ytd-channel-renderer #avatar-section {
  245. max-width: ${searchChannelAvatarMaxWidth} !important;
  246. min-width: 240px !important;
  247. margin-right: 16px !important;
  248. flex-shrink: 0 !important;
  249. }
  250. ytd-search ytd-item-section-renderer ytd-channel-renderer[use-bigger-thumbs][bigger-thumb-style=BIG] #avatar-section,
  251. ytd-search ytd-item-section-renderer ytd-channel-renderer[use-bigger-thumbs] #avatar-section {
  252. max-width: ${searchChannelAvatarMaxWidth} !important;
  253. }
  254. ytd-search ytd-item-section-renderer ytd-channel-renderer #info-section {
  255. flex-grow: 1 !important;
  256. min-width: 0;
  257. display: flex !important;
  258. flex-direction: row !important;
  259. align-items: flex-start !important;
  260. }
  261. ytd-search ytd-item-section-renderer ytd-channel-renderer #info-section a#main-link {
  262. max-width: ${searchChannelTextMaxWidth} !important;
  263. flex-grow: 1;
  264. min-width: 0;
  265. display: block;
  266. }
  267. ytd-search ytd-item-section-renderer ytd-channel-renderer #buttons {
  268. display: flex !important;
  269. align-items: center !important;
  270. flex-shrink: 0 !important;
  271. margin-left: 16px !important;
  272. padding-right: 72px !important;
  273. box-sizing: border-box !important;
  274. }
  275. ytd-search ytd-item-section-renderer ytd-channel-renderer #channel-title yt-formatted-string {
  276. font-size: var(--gm-search-title-size) !important;
  277. line-height: 1.3em !important;
  278. display: -webkit-box !important;
  279. -webkit-line-clamp: 2;
  280. -webkit-box-orient: vertical !important;
  281. overflow: hidden !important;
  282. text-overflow: ellipsis !important;
  283. }
  284. ytd-search ytd-item-section-renderer ytd-channel-renderer #metadata yt-formatted-string,
  285. ytd-search ytd-item-section-renderer ytd-channel-renderer #metadata span {
  286. font-size: var(--gm-search-channel-submeta-size) !important;
  287. line-height: 1.4em !important;
  288. }
  289. ytd-search ytd-item-section-renderer ytd-channel-renderer #description {
  290. font-size: 1.2rem !important;
  291. line-height: 1.3em !important;
  292. -webkit-line-clamp: 2 !important;
  293. display: -webkit-box !important;
  294. -webkit-box-orient: vertical !important;
  295. overflow: hidden !important;
  296. text-overflow: ellipsis !important;
  297. margin-top: 4px !important;
  298. }
  299.  
  300.  
  301. /* ========================================================== */
  302. /* === WATCH PAGE (/watch) === */
  303. /* ========================================================== */
  304. .title.ytd-video-primary-info-renderer h1.ytd-video-primary-info-renderer { font-size: var(--gm-watch-title-size) !important; line-height: 1.2em !important; }
  305. #top-row.ytd-watch-metadata { margin-top: ${watchTopRowMarginTop} !important; }
  306. ytd-video-owner-renderer ytd-channel-name { font-size: var(--gm-watch-owner-channel-size) !important; line-height: 1.05em !important; margin: 0 !important; padding: 0 !important; display: block !important; }
  307. #owner-sub-count.ytd-video-owner-renderer { margin-top: ${watchSubCountMarginTop} !important; margin-bottom: 0 !important; }
  308. #description-inner #description .content.ytd-video-secondary-info-renderer, .ytd-expander.ytd-video-secondary-info-renderer { font-size: 0.8em !important; line-height: 1.35em !important; }
  309. #info-text.ytd-video-primary-info-renderer { font-size: 0.8em !important; }
  310. ytd-compact-video-renderer h3.ytd-compact-video-renderer { margin-bottom: ${sidebarTitleMarginBottom} !important; margin-top: 0 !important; }
  311. #video-title.ytd-compact-video-renderer { font-size: var(--gm-sidebar-title-size) !important; line-height: 1.3em !important; max-height: 2.6em !important; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  312. ytd-compact-video-renderer ytd-channel-name { font-size: var(--gm-sidebar-channel-size) !important; line-height: 1.35em !important; margin-bottom: 1px !important; }
  313. ytd-compact-video-renderer #metadata-line span.inline-metadata-item { font-size: var(--gm-sidebar-viewsdate-size) !important; line-height: 1.45em !important; }
  314. ytd-compact-video-renderer ytd-badge-supported-renderer.badges { margin-top: ${sidebarBadgeMarginTop} !important; margin-bottom: ${sidebarBadgeMarginBottom} !important; font-size: var(--gm-sidebar-badge-size) !important; line-height: 1.2 !important; }
  315. ytd-comment-replies-renderer ytd-comment-view-model[is-reply] > #main > #expander { font-size: 1rem !important; }
  316. ytd-comment-view-model #expander > #content > yt-attributed-string#content-text { font-size: var(--gm-comment-text-final-size) !important; line-height: 1.5em !important; }
  317. ytd-comments ytd-comment-thread-renderer > ytd-comment-view-model:not([is-reply]) #header-author #author-text,
  318. ytd-comments ytd-comment-thread-renderer > ytd-comment-view-model:not([is-reply]) #header-author .published-time-text.ytd-comment-view-model a { font-size: var(--gm-comment-meta-final-size) !important; line-height: 1.4em !important; }
  319. ytd-comments ytd-comment-replies-renderer ytd-comment-view-model[is-reply] #header-author #author-text,
  320. ytd-comments ytd-comment-replies-renderer ytd-comment-view-model[is-reply] #header-author .published-time-text.ytd-comment-view-model a { font-size: var(--gm-comment-meta-final-size) !important; line-height: 1.4em !important; }
  321. #toolbar.ytd-comment-action-buttons-renderer { font-size: var(--gm-comment-meta-final-size) !important; }
  322. #header-author #author-text.ytd-comment-renderer { color: #aaa !important; }
  323. `;
  324.  
  325. // ===================================================================
  326. // === OPTIONAL FEATURE: HIDE UNWANTED SHELVES & SHORTS CONTENT
  327. // To disable, change 'true' to 'false'. To remove, delete the block.
  328. // ===================================================================
  329. const hideUnwantedContent = true;
  330.  
  331. if (hideUnwantedContent) {
  332. css += `
  333. /* Hide the main Shorts shelf on Home/Channel pages */
  334. ytd-rich-section-renderer:has(ytd-rich-shelf-renderer[is-shorts]) {
  335. display: none !important;
  336. }
  337.  
  338. /* Hide various unrelated shelves in Search Results */
  339. ytd-search ytd-shelf-renderer,
  340. ytd-search ytd-horizontal-list-renderer,
  341. ytd-search ytd-reel-shelf-renderer,
  342. ytd-search grid-shelf-view-model,
  343. ytd-search ytd-horizontal-card-list-renderer {
  344. display: none !important;
  345. }
  346.  
  347. /* Hide individual video items in search that are actually Shorts */
  348. ytd-search ytd-video-renderer[is-search]:has(a#thumbnail[href^="/shorts/"]) {
  349. display: none !important;
  350. }
  351.  
  352. /* Hide the "Shorts" link in the main sidebar guide */
  353. ytd-guide-entry-renderer:has(a#endpoint[title="Shorts"]) {
  354. display: none !important;
  355. }
  356. `;
  357. }
  358. // ===================================================================
  359.  
  360.  
  361. // ===================================================================
  362. // === OPTIONAL FEATURE: HIDE "Shorts" FILTER CHIP IN SEARCH
  363. // To disable, change 'true' to 'false'. To remove, delete the block.
  364. // ===================================================================
  365. const hideSearchShortsChip = true;
  366.  
  367. if (hideSearchShortsChip) {
  368. css += `
  369. /* Find the chip renderer that contains a "Shorts" title */
  370. yt-chip-cloud-chip-renderer:has(yt-formatted-string#text[title="Shorts"]) {
  371. display: none !important;
  372. }
  373. `;
  374. }
  375. // ===================================================================
  376.  
  377.  
  378. if (typeof GM_addStyle === 'function') {
  379. const scriptVersion = (typeof GM_info !== 'undefined' && GM_info.script) ? GM_info.script.version : 'N/A';
  380. GM_addStyle(css);
  381. console.log(`YouTube Layout Script: v${scriptVersion} Active (${desiredColumnCount} Cols)`);
  382. } else {
  383. console.error("YouTube Layout Script: GM_addStyle is not defined.");
  384. const style = document.createElement('style');
  385. style.textContent = css;
  386. document.head.appendChild(style);
  387. }
  388.  
  389. })();