Old Red YouTube Progress Bar

Restores the old solid red YouTube progress bars (video player, thumbnail overlay, hover preview progress bar and top loading bar) and ensures the style is applied dynamically even on page loads or DOM changes.

目前為 2024-10-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Old Red YouTube Progress Bar
// @namespace    https://greasyfork.org/en/users/1384870
// @version      1.1
// @description  Restores the old solid red YouTube progress bars (video player, thumbnail overlay, hover preview progress bar and top loading bar) and ensures the style is applied dynamically even on page loads or DOM changes.
// @author       Rastrisr
// @match        *://*.youtube.com/*
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to restore the old red YouTube progress bars
    function applyOldRedProgressBar() {
        // Check if the style element already exists
        let styleElement = document.getElementById('oldRedProgressBarStyle');
        if (!styleElement) {
            styleElement = document.createElement('style');
            styleElement.id = 'oldRedProgressBarStyle';
            document.head.appendChild(styleElement);
        }
        // Update or set the styles in the style element
        styleElement.innerHTML = `
        .ytp-play-progress {
            background: #FF0000 !important; /* Old solid red color for the video player progress bar */
        }
        #progress.ytd-thumbnail-overlay-resume-playback-renderer {
            background: #FF0000 !important; /* Old solid red color for the thumbnail overlay progress bar */
        }
        #progress.yt-page-navigation-progress {
            background: #FF0000 !important; /* Old solid red color for the top loading bar */
        }
        .YtProgressBarLineProgressBarPlayed {
            background: #FF0000 !important; /* Old Solid red color for the hover preview progress bar */
        }
        `;
    }

    // MutationObserver to ensure the red progress bar style is reapplied dynamically
    function observeForChanges() {
        const observer = new MutationObserver(() => {
            applyOldRedProgressBar();
        });

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

    // Initial application of the old red progress bars and setting up the observer
    setTimeout(() => {
        applyOldRedProgressBar();
        observeForChanges();
    }, 2000);

})();