让youtube网站一行显示5个视频的Tampermonkey 代码

// ==UserScript==
// @name         YouTube 5 Videos Per Row
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Force YouTube to display 5 videos per row on the homepage
// @author       bgegao.com
// @match        https://www.youtube.com/*
// @match        https://youtube.com/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // 注入自定义CSS
    GM_addStyle(`
        ytd-rich-grid-renderer {
            --ytd-rich-grid-items-per-row: 5 !important;
            --ytd-rich-grid-posts-per-row: 5 !important;
            --ytd-rich-grid-row-margin: 10px !important;
        }

        /* 确保视频卡片宽度适配 */
        ytd-rich-item-renderer {
            width: calc(20% - 12px) !important;
            margin: 6px !important;
        }

        /* 调整网格容器 */
        #contents.ytd-rich-grid-renderer {
            display: flex !important;
            flex-wrap: wrap !important;
            justify-content: space-between !important;
        }
    `);
})();

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

96 − 95 =