ReHike Fixes 4 SYTARB

Hides the .player-unavailable element on age-restricted videos

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         ReHike Fixes 4 SYTARB
// @namespace    http://tampermonkey.net/
// @author       wavypurples
// @version      1.0
// @description  Hides the .player-unavailable element on age-restricted videos
// @icon         https://www.youtube.com/favicon.ico
// @match        https://www.youtube.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to check and hide the player-unavailable element
    function hidePlayerUnavailable() {
        const messageElement = document.querySelector('.player-unavailable .content .message');
        if (messageElement && messageElement.textContent.trim() === "Sorry, this content is age-restricted") {
            const playerUnavailable = document.querySelector('.player-unavailable');
            if (playerUnavailable) {
                playerUnavailable.style.display = 'none';
            }
        }
    }

    // Run the function initially
    hidePlayerUnavailable();

    // Observe for changes to dynamically loaded content
    const observer = new MutationObserver(hidePlayerUnavailable);
    observer.observe(document.body, { childList: true, subtree: true });
})();