Last active
June 22, 2023 14:24
-
-
Save MrDrache333/4e9121cea06395b6342e99232cd980f8 to your computer and use it in GitHub Desktop.
Remove YouTube Shorts Links and Videos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Hide youtube Shorts | |
// @version 1.0 | |
// @namespace https://gist.github.com/MrDrache333/4e9121cea06395b6342e99232cd980f8 | |
// @description Remove youtube shorts Links, Videos and Feeds | |
// @author MrDrache333 | |
// @match https://*.youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function removeLinks(selector){ | |
var count = 0 | |
//Remove Links | |
document.querySelectorAll(selector).forEach(t => { | |
const elem = t.closest('ytd-guide-entry-renderer'); | |
if (elem){ | |
elem.remove(); | |
count++ | |
} | |
}) | |
if(count)console.log('Removed ' + count + ' shorts-Links'); | |
} | |
function removeShortsVideos(){ | |
//Remove Shorts in search | |
var count = 0 | |
document.querySelectorAll('a[href^="/shorts/"]').forEach(t => { | |
const elem = t.closest('ytd-video-renderer'); | |
if (elem){ | |
elem.remove(); | |
} | |
}) | |
if(count)console.log('Removed ' + count + ' shorts-Videos'); | |
} | |
//@author danieloliveira117 | |
function removeShortsFeed() { | |
let count = 0; | |
document.querySelectorAll('ytd-thumbnail-overlay-time-status-renderer[overlay-style="SHORTS"]').forEach(t => { | |
if (t) { | |
count++; | |
const elem = t.closest('ytd-grid-video-renderer'); | |
if (elem) { | |
elem.remove(); | |
} | |
} | |
}); | |
if (count) { | |
console.log('Removed ' + count + ' shorts'); | |
} | |
} | |
function removeShorts(){ | |
removeLinks('a[title="Shorts"]'); | |
removeLinks('a[title="Entdecken"]'); | |
removeLinks('a[title="YouTube Music"]'); | |
removeLinks('a[title="Originals"]'); | |
removeShortsVideos(); | |
removeShortsFeed(); | |
} | |
const observer = new MutationObserver(removeShorts); | |
observer.observe(document.querySelector('#page-manager'), { childList:true, subtree:true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment