Skip to content

Instantly share code, notes, and snippets.

@timfreund
Created August 6, 2016 14:12
Show Gist options
  • Save timfreund/93dde982a5d12fd639c78c2df1bcbe2f to your computer and use it in GitHub Desktop.
Save timfreund/93dde982a5d12fd639c78c2df1bcbe2f to your computer and use it in GitHub Desktop.
function findForDisabling(searchTerm){
$(searchTerm).each(disableDisplay);
}
function disableDisplay(index, element){
element.style.display = 'none';
}
window.setInterval(function(){
var searches = ["#feed", ".watch-sidebar", "#watch-discussion", ".feed-item-container"];
searches.forEach(findForDisabling);
}, 3000);
@xstable
Copy link

xstable commented Jan 6, 2024

BTW: Found an bug with this script.
If you have more then one youtube-account, there is a popup, that is shown to choose which account should be used.
The content of this Popup is hidden by the above script (I've disabled the display:none in following screenshot to show:

image

Here is an adjustment that should work:

function checkParentClass(element) {
    return element.closest('.ytd-channel-switcher-renderer') !== null;
}

function findForDisabling(searchTerm) {
    document.querySelectorAll(searchTerm).forEach(disableDisplay);
}

function disableDisplay(element) {
  if(element.id == "contents" && !checkParentClass(element)){
     element.style.display = 'none'; 
  }
}

var destroyRabbitHoles = window.setInterval(getRabbitHoles, 3000);

var count = 0;
function getRabbitHoles() {
    var searches = [
                     "#feed", 
                     ".watch-sidebar", 
                     "#watch-discussion", 
                     ".feed-item-container",
                     "#related", 
                     "#comments",
                     "#contents"
              ];
    searches.forEach(findForDisabling);  
    if(count++ > 2){
        clearInterval(destroyRabbitHoles);
    }
}

var trendingButton = document.querySelector("a[title=Trending]");

if( trendingButton !== null){
    trendingButton.style.display = 'none';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment