Greasy Fork镜像 支持简体中文。

Videos scroller

Scrollbar + more videos on main page.

目前為 2019-11-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Videos scroller
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @description  Scrollbar + more videos on main page.
// @author       Bum
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @grant        GM_addStyle
// @match        https://www.youtube.com/*
// ==/UserScript==
var itemsPerRow = 6;

jQuery(document).ready(_main);

function _main() {
    var isReady = jQuery("div.ytd-watch-next-secondary-results-renderer").length > 0;
    if (!isReady) {
        setTimeout(_main, 500);
        return;
    }
    jQuery("div.ytd-watch-next-secondary-results-renderer").wrap("<div id='style-3' class='scrollbar'></div>");
    $('div.scrollbar').bind('mousewheel DOMMouseScroll', function(e) {
        var scrollTo = null;
        if (e.type == 'mousewheel') {
            scrollTo = (e.originalEvent.wheelDelta * -1);
        } else if (e.type == 'DOMMouseScroll') {
            scrollTo = 40 * e.originalEvent.detail;
        }

        if (scrollTo) {
            e.preventDefault();
            $(this).scrollTop(scrollTo + $(this).scrollTop());
        }

    });
}

(function() {
    function GM_addStyle(css) {
        const style = document.getElementById("GM_addStyle") || (function() {
            const style = document.createElement('style');
            style.type = 'text/css';
            style.id = "GM_addStyle";
            document.head.appendChild(style);
            return style;
        })();
        const sheet = style.sheet;
        sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
    }
    GM_addStyle(`
ytd-rich-grid-renderer{
    --ytd-rich-grid-items-per-row: ` + itemsPerRow + ` !important;
}
`);
    GM_addStyle(`
.scrollbar
{
	margin-left: 30px;
    max-height: 800px;
	float: left;
	overflow-y: scroll;
	margin-bottom: 25px;
}
`);
    GM_addStyle(`
   #style-3::-webkit-scrollbar-track
{
	-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
	background-color: #F5F5F5;
}
`);
    GM_addStyle(`
#style-3::-webkit-scrollbar
{
	width: 6px;
	background-color: #F5F5F5;
}
`);
    GM_addStyle(`
#style-3::-webkit-scrollbar-thumb
{
	background-color: #000000;
}
`);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址