YouTube - FIXED remove download, clip, thanks buttons

Hides YouTube "Download", "Clip", "Thanks", and "Promote" buttons from the interface. Fixed.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         YouTube - FIXED remove download, clip, thanks buttons
// @namespace    Violentmonkey Scripts
// @version      1.0
// @description  Hides YouTube "Download", "Clip", "Thanks", and "Promote" buttons from the interface. Fixed.
// @author       Magma_Craft (update by jawsawn)
// @match        *://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    "use strict";

    const style = document.createElement("style");
    style.textContent = `
        ytd-download-button-renderer,
        #flexible-item-buttons [aria-label="Promote"],
        #flexible-item-buttons [aria-label="Clip"],
        #flexible-item-buttons [aria-label="Thanks"],
        #flexible-item-buttons [title="Show support with Super Thanks"],
        ytd-button-renderer[button-renderer*="MONEY_HEART"],
        ytd-button-renderer[button-renderer*="CONTENT_CUT"] {
            display: none !important;
        }
    `;
    document.head.appendChild(style);
    //uncomment the rest if it breaks again

    /*function removeButtonsByIconType(container) {
        const buttons = container.querySelectorAll("ytd-button-renderer");

        buttons.forEach((btn) => {
            try {
                const iconType = btn.data?.icon?.iconType;
                if (["MONEY_HEART", "CONTENT_CUT", "DOWNLOAD"].includes(iconType)) {
                    btn.remove();
                }
            } catch (e) {
                // fail silently
            }
        });
    }

    async function waitForElm(selector) {
        while (!document.querySelector(selector)) {
            await new Promise((resolve) => requestAnimationFrame(resolve));
        }
        return document.querySelector(selector);
    }

    function initObserver() {
        const observer = new MutationObserver(() => {
            document.querySelectorAll("#top-level-buttons-computed.ytd-menu-renderer")
                .forEach(removeButtonsByIconType);
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true,
        });
    }

    document.addEventListener("yt-page-data-updated", async () => {
        const btns = await waitForElm("#top-level-buttons-computed.ytd-menu-renderer");
        removeButtonsByIconType(btns);
    });

    initObserver();*/
})();