HideNotch

QuitarNotch

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         HideNotch
// @match        *://*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @run-at       document-end
// @version      0.0.3
// @description  QuitarNotch
// @namespace http://tampermonkey.net/
// ==/UserScript==

(function () {
    const timeOuts = [100, 200, 300, 500];
    const videos = document.getElementsByTagName('video');
    const isRemoteDesktop = location.href.includes('remotedesktop.google.com');

    //***** VIEWPORT *****
    if (!document.querySelector('meta[name="viewport"]')) {
        const meta = document.createElement('meta');
        meta.name = 'viewport';
        meta.content = 'width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no';
        document.head.appendChild(meta);
    }

    const style = document.createElement('style');
    style.textContent = `
        .fillVideoCSS {
            top: 0 !important;
            left: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            object-fit: fill !important;
            position: fixed !important;
        }
    `;
    document.head.appendChild(style);

    //***** FULLSCREEN VIDEOS *****
    function applyFullscreenVideos() {
        for (let video of videos) {
            video.classList.remove('fillVideoCSS');
            video.classList.add('fillVideoCSS');
        }

        const firstVideo = videos[0];
        if (firstVideo && firstVideo.videoWidth > firstVideo.videoHeight && screen.orientation?.lock) {
            screen.orientation.lock('landscape').catch(() => {});
        }
    }

    function removeFullscreenVideos() {
        for (let video of videos) {
            video.classList.remove('fillVideoCSS');
        }
    }

    document.addEventListener('fullscreenchange', () => {
        if (document.fullscreenElement) {
            timeOuts.forEach(timeout => setTimeout(applyFullscreenVideos, timeout));
        } else {
            removeFullscreenVideos();
        }
        console.clear();
    });

    //***** REMOTE DESKTOP WAKE LOCK *****
    if (isRemoteDesktop) {
        let wakeLock = null;

        async function requestWakeLock() {
            try {
                if ('wakeLock' in navigator) {
                    wakeLock = await navigator.wakeLock.request('screen');
                    wakeLock.addEventListener('release', () => {
                        if (document.visibilityState === 'visible') requestWakeLock();
                    });
                }
            } catch (e) {
                console.warn('No se pudo activar wake lock:', e);
            }
        }

        requestWakeLock();

        document.addEventListener('visibilitychange', () => {
            if (document.visibilityState === 'visible') requestWakeLock();
        });
    }

    //***** DISEÑO *****
    let el;
    if ((el = document.getElementById('speedbump'))) el.remove();
    if ((el = document.getElementById('views'))) el.style.top = '0px';
})();