YouTube Default Logo (Remove Premium Text, Always)

Always shows the default YouTube logo, removes "Premium" text and yoodle, and keeps it that way

// ==UserScript==
// @name         YouTube Default Logo (Remove Premium Text, Always)
// @version      1.5.0
// @description  Always shows the default YouTube logo, removes "Premium" text and yoodle, and keeps it that way
// @author       T3 Chat
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// @namespace https://greasyfork.dpdns.org/users/1412746
// ==/UserScript==

(function () {
    'use strict';

    // Hide yoodle with CSS
    const style = document.createElement('style');
    style.textContent = `
        ytd-yoodle-renderer {
            display: none !important;
        }
    `;
    document.head.appendChild(style);

    // Remove "Premium" text node or element from logo area
    function removePremiumText() {
        const logoRenderer = document.querySelector('ytd-topbar-logo-renderer');
        if (!logoRenderer) return;

        // Remove is-red-logo attribute to avoid premium logo
        logoRenderer.removeAttribute('is-red-logo');
        logoRenderer.querySelectorAll('ytd-logo[is-red-logo]').forEach(el => {
            el.removeAttribute('is-red-logo');
        });

        // Find the <a id="logo"> link
        const logoLink = logoRenderer.querySelector('a#logo');
        if (!logoLink) return;

        // Remove any element or text node that contains "Premium"
        Array.from(logoLink.childNodes).forEach(node => {
            // Remove text nodes with "Premium"
            if (
                node.nodeType === Node.TEXT_NODE &&
                node.textContent.trim().toLowerCase().startsWith('premium')
            ) {
                node.textContent = '';
            }
            // Remove elements with "Premium" text
            if (
                node.nodeType === Node.ELEMENT_NODE &&
                node.textContent.trim().toLowerCase().startsWith('premium')
            ) {
                node.style.display = 'none';
            }
        });
    }

    // Observe the logo area for any changes
    function observeLogo() {
        const logoRenderer = document.querySelector('ytd-topbar-logo-renderer');
        if (!logoRenderer) return;
        const logoObserver = new MutationObserver(removePremiumText);
        logoObserver.observe(logoRenderer, { childList: true, subtree: true });
        // Initial fix
        removePremiumText();
    }

    // Observe the body for the logo renderer to appear
    const bodyObserver = new MutationObserver(() => {
        if (document.querySelector('ytd-topbar-logo-renderer')) {
            observeLogo();
        }
    });
    bodyObserver.observe(document.body, { childList: true, subtree: true });

    // Initial run (in case logo is already present)
    observeLogo();
})();
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

一年攒够 12 元

云驰互联

云驰互联