Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YouTube #544

Open
Akash2372 opened this issue Jul 1, 2024 · 0 comments
Open

YouTube #544

Akash2372 opened this issue Jul 1, 2024 · 0 comments

Comments

@Akash2372
Copy link

// ==UserScript==
// @name Hide YouTube Shorts
// @namespace http://tampermonkey.net/
// @Version 0.1
// @description Hide YouTube Shorts on YouTube
// @author Your Name
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Function to hide elements with specific selectors
function hideShorts() {
    const shortsSelectors = [
        'ytd-rich-section-renderer[header-style="SHORTS"]', // Shorts section on homepage
        'ytd-grid-video-renderer[is-shorts]', // Shorts in subscription feed
        'ytd-reel-shelf-renderer' // Shorts in explore
    ];

    shortsSelectors.forEach(selector => {
        const elements = document.querySelectorAll(selector);
        elements.forEach(element => {
            element.style.display = 'none';
        });
    });
}

// Run the function initially
hideShorts();

// Create a MutationObserver to watch for changes and hide Shorts dynamically
const observer = new MutationObserver(hideShorts);
observer.observe(document.body, { childList: true, subtree: true });

})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant