Return YouTube's Red Color

Revert YouTube's new pink color to the classic red

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Return YouTube's Red Color
// @icon         https://www.youtube.com/favicon.ico
// @version      1.0.4
// @description  Revert YouTube's new pink color to the classic red
// @author       dark110
// @match        *://*.youtube.com/*
// @grant        none
// @license MIT
// @namespace https://greasyfork.org/users/1404735
// ==/UserScript==

(function() {
    'use strict';

    const COLOR = '#FF0000';
    const HUE_ROTATION = '20deg';
    const ICON_URL = 'https://www.gstatic.com/youtube/img/creator/favicon/favicon.ico';

    const ToColor = [
        '.html5-play-progress',
        '.ytp-play-progress',
        'div.ytp-scrubber-button.ytp-swatch-background-color',
        'div.YtProgressBarLineProgressBarPlayed.YtProgressBarLineProgressBarPlayedRefresh',
        'div.style-scope.ytd-thumbnail-overlay-resume-playback-renderer'
    ];

    const ToFilter = [
        '.ytp-large-play-button',
        '.ytp-button',
        '.ytcp-home-button',
        '.yt-icon-shape',
        'ytd-badge-supported-renderer',
        '.badge-shape'
    ];

    const Apply = () => {
        ToColor.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => el.style.background = COLOR);
        });

        ToFilter.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => el.style.filter = `hue-rotate(${HUE_ROTATION})`);
        });

        const icon = document.querySelector("link[rel*='icon']");
        if (icon) {
            const newicon = document.createElement('link');
            newicon.rel = 'shortcut icon';
            newicon.href = ICON_URL;
            document.head.replaceChild(newicon, icon);
        }
    };

    const ApplyObserver = new MutationObserver(Apply);
    ApplyObserver.observe(document.body, {childList: true, subtree: true});

    Apply();
})();