Remove Youtube Shorts

Remove youtube shorts junk

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Remove Youtube Shorts
// @namespace    https://www.youtube.com/
// @version      0.2
// @description  Remove youtube shorts junk
// @author       Scamcast
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function RemoveShorts() {
        document.querySelectorAll('ytd-grid-video-renderer').forEach(video => {
            try {
                if (video.__data.data.navigationEndpoint.commandMetadata.webCommandMetadata.webPageType.match(/shorts/i)) video.remove();
            } catch (e) {}
        });

        document.querySelectorAll('ytd-guide-entry-renderer.ytd-guide-section-renderer').forEach(guideItem => {
            try {
                if (guideItem.__data.data.formattedTitle.simpleText.match(/shorts/i)) guideItem.remove();
            } catch (e) {}
        });

        document.querySelectorAll('tp-yt-paper-tab').forEach(tab => {
            try {
                if (tab.textContent.match(/shorts/i)) tab.remove();
            } catch (e) {}
        });
        document.querySelectorAll('ytd-reel-shelf-renderer, ytd-rich-shelf-renderer').forEach(reelshelf => reelshelf.remove());
    }

    RemoveShorts();
    let JunkCheckInterval = setInterval(RemoveShorts, 1000);

    window.addEventListener('focus', (e)=>{
        if (document.hasFocus() && document.visibilityState == 'visible'){
            clearInterval(JunkCheckInterval);
            JunkCheckInterval = setInterval(RemoveShorts, 1000);
        } else if (!document.hasFocus() || document.visibilityState == 'hidden') {
            clearInterval(JunkCheckInterval);
        };
    });
    window.addEventListener('visibilitychange', (e)=>{
        if (!document.hasFocus() || document.visibilityState == 'hidden') {
            clearInterval(JunkCheckInterval);
        };
    })
})();