YouTube Row Fix

5 videos/row

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Advertisement:

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

Advertisement:

// ==UserScript==
// @name         YouTube Row Fix
// @namespace    https://youtube.com/
// @version      1.4
// @description  5 videos/row
// @match        https://www.youtube.com/*
// @match        https://youtube.com/*
// @grant        none
// @run-at       document-start
// @license MIT
// ==/UserScript==

(() => {
    "use strict";

    const prfx = "row fix ignore";
    const VideoPerRow = 5;
    const ShortPerRow = 8;

    function addStyle() {
        const old = document.getElementById(prfx);

        if (old) {
            old.remove();
        }

        const style = document.createElement("style");
        style.id = prfx;
        style.textContent = `
            html,
            ytd-rich-grid-renderer {
                --ytd-rich-grid-items-per-row: ${VideoPerRow} !important;
                --ytd-rich-grid-posts-per-row: ${VideoPerRow} !important;
                --ytd-rich-grid-slim-items-per-row: ${VideoPerRow} !important;
            }

            ytd-rich-grid-renderer {
                margin-left: 8px !important;
                margin-right: 8px !important;
            }

            ytd-rich-grid-row,
            #contents.ytd-rich-grid-row,
            ytd-rich-grid-row > #contents {
                display: contents !important;
            }

            ytd-rich-item-renderer {
                max-width: none !important;
            }

            ytd-rich-shelf-renderer[is-shorts],
            ytd-rich-section-renderer {
                --ytd-rich-grid-items-per-row: ${ShortPerRow} !important;
                --ytd-rich-grid-posts-per-row: ${ShortPerRow} !important;
            }

            @media (max-width: 1200px) {
                html,
                ytd-rich-grid-renderer {
                    --ytd-rich-grid-items-per-row: 4 !important;
                    --ytd-rich-grid-posts-per-row: 4 !important;
                    --ytd-rich-grid-slim-items-per-row: 4 !important;
                }
            }

            @media (max-width: 900px) {
                html,
                ytd-rich-grid-renderer {
                    --ytd-rich-grid-items-per-row: 3 !important;
                    --ytd-rich-grid-posts-per-row: 3 !important;
                    --ytd-rich-grid-slim-items-per-row: 3 !important;
                }
            }
        `;

        document.documentElement.appendChild(style);
    }

    function patchGrid() {
        document.querySelectorAll("ytd-rich-grid-renderer").forEach((grid) => {
            grid.style.setProperty("--ytd-rich-grid-items-per-row", String(VideoPerRow), "important");
            grid.style.setProperty("--ytd-rich-grid-posts-per-row", String(VideoPerRow), "important");
            grid.style.setProperty("--ytd-rich-grid-slim-items-per-row", String(VideoPerRow), "important");
        });
    }

    function run() {
        addStyle();
        patchGrid();
    }

    run();

    window.addEventListener("yt-navigate-finish", run);
    window.addEventListener("resize", patchGrid);

    new MutationObserver(patchGrid).observe(document.documentElement, {
        childList: true,
        subtree: true
    });
})();