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);
@khalidaxamd
Copy link

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);

@afzaledx
Copy link

afzaledx commented Jan 1, 2018

I had to modify the selectors (line 10):
var searches = ["#related", "#comments"];

@mikenuttall
Copy link

mikenuttall commented Sep 9, 2018

Added a clearInterval so it's not running continually

And added #contents - gets rid of all the "recommended for you" stuff

And got rid of the "Trending" button - another wasteland!

function findForDisabling(searchTerm){
    $(searchTerm).each(disableDisplay);
}

function disableDisplay(index, 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';
}    

@xstable
Copy link

xstable commented Jan 6, 2024

Here rewritten for anybody who want to use vanilla JS for it:

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

function disableDisplay(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';
}

Thanks for sharing

@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