YouTube Cards▶️🃏 & Shorts Text🩳📰 Hider

Hides metadata from YouTube Shorts and Videos End Cards Unless Hover

当前为 2024-11-25 提交的版本,查看 最新版本

// ==UserScript==
// @name         YouTube Cards▶️🃏 & Shorts Text🩳📰 Hider
// @namespace    http://tampermonkey.net/
// @version      1.0002
// @description  Hides metadata from YouTube Shorts and Videos End Cards Unless Hover
// @author       Your name
// @match        https://www.youtube.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function hideMetadata() {
        let metadataContainers = document.querySelectorAll('.metadata-container');
        metadataContainers.forEach(container => {
            container.style.opacity = '0';
        });
    }
    function showMetadata() {
        let metadataContainers = document.querySelectorAll('.metadata-container');
        metadataContainers.forEach(container => {
            container.style.opacity = '1';
        });
    }

    const videoArea = document.querySelector('#shorts-inner-container'); 

    if (videoArea) {
        videoArea.addEventListener('mouseover', function() {
            showMetadata();
        });
        videoArea.addEventListener('mouseleave', function() {
            hideMetadata();
        });
    } else {
        console.error('Video container (shorts-inner-container) not found.');
    }

    hideMetadata();

    let css = `
        #shorts-inner-container .metadata-container {
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        #shorts-inner-container:hover .metadata-container {
            opacity: 1;
        }

        div[class*="video-player"]:not(:hover) div[class^="ytp-ce"],
        div[class*="ytp-autohide"] div[class^="ytp-ce"] {
            display: none !important;
        }

        .YtProgressBarLinePlayed {
            visibility: visible !important;
            opacity: 1 !important;
        }

        yt-progress-bar {
            opacity: 1 !important;
            display: block !important;
        }
    `;

    if (typeof GM_addStyle !== "undefined") {
        GM_addStyle(css);
    } else {
        let styleNode = document.createElement("style");
        styleNode.appendChild(document.createTextNode(css));
        (document.querySelector("head") || document.documentElement).appendChild(styleNode);
    }

    const observer = new MutationObserver(() => {
        const redBar = document.querySelector('.YtProgressBarLinePlayed');
        if (redBar) {
            redBar.style.visibility = 'visible';
            redBar.style.opacity = '1';
        }
    });

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址