Restore slim tubnails on home and subs pages
当前为
// ==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);
})();