Fix YouTube Renderer

Fixes empty YT grid slots in renderer caused by adblockers

目前為 2024-02-05 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Fix YouTube Renderer
// @namespace    youtube.com
// @version      1.0
// @description  Fixes empty YT grid slots in renderer caused by adblockers
// @author       Zach Kosove
// @include      https://www.youtube.com/*
// @grant        GM_addStyle
// ==/UserScript==

GM_addStyle(`
/* Variables */
:root {
    --columns: 4;
    --horizontal-margin: 35px;
    --vertical-margin: 30px;
    --font-size-title: 1.8rem;
    --font-size-metadata: 1.2rem;
    --font-weight-title: 400;
    --font-weight-metadata: 400;
    --thumb-size-search: 360px;
    --thumb-grid-width: 210px;
    --viewed-gray: 80%;
    --width-container-home: 100%;
}

/* Containers */
ytd-rich-grid-row.style-scope.ytd-rich-grid-renderer,
ytd-rich-grid-row.style-scope.ytd-rich-grid-renderer > #contents {
    display: contents !important;
}

/* Video Width */
ytd-rich-item-renderer.style-scope.ytd-rich-grid-row {
    --ytd-rich-grid-items-per-row: var(--columns) !important;
    width: calc(100% / var(--ytd-rich-grid-items-per-row) - var(--horizontal-margin) / 2 - 0.01px) !important;
}

/* Thumbnails */
yt-horizontal-list-renderer[should-use-mixed-list-height] {
    --ytd-grid-video-width: var(--thumb-grid-width);
    --ytd-grid-video-thumbnail-height: calc(var(--thumb-grid-width) * 9 / 16);
}

/* Content */
#contents ytd-rich-grid-row ytd-rich-item-renderer {
    max-width: unset !important;
    margin-bottom: var(--vertical-margin) !important;
}

/* Title */
#video-title.ytd-rich-grid-media,
/* add other selectors here */
#video-title.ytd-playlist-panel-video-renderer,
ytd-grid-video-renderer #video-title.yt-simple-endpoint.ytd-grid-video-renderer {
    font-size: var(--font-size-title) !important;
    font-weight: var(--font-weight-title) !important;
}

/* Details */
ytd-video-meta-block[rich-meta] #byline-container.ytd-video-meta-block,
/* add other selectors here */
#byline.ytd-playlist-panel-video-renderer {
    font-size: var(--font-size-metadata) !important;
    font-weight: var(--font-weight-metadata) !important;
}

/* Thumbnail Size */
ytd-video-renderer[use-search-ui] ytd-thumbnail.ytd-video-renderer,
/* add other selectors here */
ytd-playlist-thumbnail.ytd-radio-renderer {
    max-width: var(--thumb-size-search) !important;
    min-width: var(--thumb-size-search) !important;
}

/* Bloat Removal (Includes Empty Sections) */
ytd-rich-grid-renderer > #contents.ytd-rich-grid-renderer > *:not(ytd-rich-item-renderer.style-scope.ytd-rich-grid-row, ytd-rich-grid-row, ytd-continuation-item-renderer)
`);