Youtube restore slim tubnails

Restore slim tubnails on home and subs pages

目前为 2020-07-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         Youtube restore slim tubnails
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Restore slim tubnails on home and subs pages
// @author       me
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    //should made portable my settings
    const getRelative = () => {
        var p = document.createElement("p");
        p.innerHTML = "test";
        p.style.fontSize = "16px";
        document.body.appendChild(p);
        var relative = 19/p.offsetHeight;
        p.innerHTML = "";
        return relative;
    }

    var relative = getRelative();
    var itemWidth = 240*relative;
    var postWidth = 350*relative;
    var subsWidth = 214;
    var padding = 48;
    var fontSize = 1.4*relative;
    var lineHeight = 1.8*relative;

    let parentSize = document.createElement("style");
    var parent = document.getElementById("page-manager");;

    const updateParentSize = () => {
        parentSize.innerHTML = ":root{--how-many-items:"+parseInt(parent.offsetWidth/itemWidth)+";"+
                               "--how-many-posts:"+parseInt(parent.offsetWidth/postWidth)+";"+
                               "--variable-columns-width:"+parseInt((parent.offsetWidth-padding)/subsWidth)*subsWidth+"px}";
    }

    updateParentSize();

    let style = document.createElement("style");
    style.innerHTML = "ytd-rich-grid-renderer.ytd-two-column-browse-results-renderer{"+
                      "--ytd-rich-grid-items-per-row:var(--how-many-items) !important;"+
                      "--ytd-rich-grid-posts-per-row:var(--how-many-posts) !important;"+
                      "--ytd-rich-grid-movies-per-row:11 !important;}"+

                      "#metadata-line.ytd-video-meta-block,ytd-channel-name{"+
                      "max-height: 7.1rem !important;"+
                      "font-size:"+fontSize+"rem !important;"+
                      "line-height:"+lineHeight+"rem !important}"+

                      "ytd-two-column-browse-results-renderer[page-subtype='subscriptions']{"+
                      "width:var(--variable-columns-width) !important;"+
                      "max-width:var(--variable-columns-width) !important}";
    document.body.appendChild(parentSize);
    document.body.appendChild(style);

    new ResizeObserver(updateParentSize).observe(parent);
})();

QingJ © 2025

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