YouTube 3 Video Grid Fix

Youtube 3 Grid Fix

// ==UserScript==
// @name         YouTube 3 Video Grid Fix
// @namespace    http://tampermonkey.net/
// @version      1.1.2
// @description  Youtube 3 Grid Fix
// @author       Horizon
// @match        https://www.youtube.com/*
// @exclude      https://www.youtube.com/watch*
// @exclude      https://accounts.youtube.com/*
// @grant        GM_addStyle
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    /* simple but works */
    const p = location.pathname;
    if (p.startsWith('/watch') || p.startsWith('/embed') || p.startsWith('/@') || p.startsWith('/shorts')) {
        return;
    }

    GM_addStyle(`
        ytd-rich-grid-renderer {
            --ytd-rich-grid-items-per-row: 5 !important;
        }

        ytd-rich-grid-renderer > #contents > ytd-rich-grid-row,
        ytd-item-section-renderer ytd-rich-grid-row {
            display: grid !important;
            grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
            gap: var(--ytd-rich-grid-gutter-margin, 16px) !important;
            width: 100% !important;
        }

        ytd-thumbnail {
            max-height: none !important;
            height: auto !important;
            width: 100% !important;
        }

        ytd-thumbnail img {
            width: 100% !important;
            height: 100% !important;
            object-fit: cover !important;
        }
    `);
})();