YouTube Big Thumbnails Fix

Fixes YouTube’s oversized thumbnails with a customizable grid: More videos per row, full width, and no gaps — for a compact, efficient layout.

目前为 2025-04-23 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Big Thumbnails Fix
  3. // @namespace https://greasyfork.org/users/1461079
  4. // @version 1.4
  5. // @description Fixes YouTube’s oversized thumbnails with a customizable grid: More videos per row, full width, and no gaps — for a compact, efficient layout.
  6. // @author Michaelsoft
  7. // @match *://www.youtube.com/*
  8. // @grant GM_addStyle
  9. // @run-at document-start
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // === SETTINGS ===
  17. const settings = {
  18. videosPerRow: 6, // Change this to set videos per row (e.g. 4, 5, 6, etc.)
  19. disableShorts: false, // Set to true to completely hide the Shorts section
  20. enableShowMoreFix: true, // Set to false to show only 1 row of Shorts (disables "Show More" force-expand)
  21. };
  22.  
  23. // === Apply CSS customizations ===
  24. GM_addStyle(`
  25. ytd-rich-grid-renderer {
  26. --ytd-rich-grid-items-per-row: ${settings.videosPerRow} !important;
  27. --ytd-rich-grid-posts-per-row: ${settings.videosPerRow} !important;
  28. --ytd-rich-grid-gutter-margin: 0px !important;
  29. --ytd-rich-grid-slim-items-per-row: 7 !important; /* Number of shorts per row */
  30. --ytd-rich-grid-game-cards-per-row: 7 !important; /* Number of game cards per row (possibly redundant) */
  31. }
  32.  
  33. ytd-two-column-browse-results-renderer.grid-${settings.videosPerRow}-columns {
  34. width: 100% !important;
  35. }
  36.  
  37. ytd-two-column-browse-results-renderer.grid:not(.grid-disabled) {
  38. max-width: 100% !important;
  39. }
  40.  
  41. /* Hide Shorts completely if setting is enabled */
  42. ${settings.disableShorts ? `
  43. ytd-rich-section-renderer.style-scope.ytd-rich-grid-renderer {
  44. display: none !important;
  45. }
  46. ` : ''}
  47. `);
  48.  
  49. // === "Show More" / hidden content fix ===
  50. if (settings.enableShowMoreFix) {
  51. const observer = new MutationObserver(() => {
  52. document.querySelectorAll('ytd-rich-item-renderer[hidden]').forEach(el => {
  53. el.removeAttribute('hidden');
  54. });
  55.  
  56. document.querySelectorAll('ytd-rich-shelf-renderer').forEach(el => {
  57. el.setAttribute('is-show-more-hidden', '');
  58. });
  59. });
  60.  
  61. observer.observe(document.documentElement, {
  62. childList: true,
  63. subtree: true
  64. });
  65. }
  66. })();