Install Tampermonkey or similar web script extension and add this script and you'll never* have to worry about videos with Peterson or Shapiro popping up again
(Updated code below)
I had been running a similar script and it seemed to work at first, but after it stopped working I did some debugging and found that it was executing before the page elements finished loading. So I added code to wait an extra 5 seconds before executing and now it seems to be working fine. You can increase the amount of time it waits by updating the 5000 in the code to however many milliseconds you think you'll need.
One thing it does not block the associated thumbnail links to the videos as these belong to a different class. If somebody who actually knows what they're doing in javascript wants to update it to remove the thumbnails, or can figure out how to make it wait until all elements are loaded before running (I tried adding a listener but it didn't work), that would be great!
UPDATE:
I think I managed to get it to hide the entire recommendation element including the thumbnail link -- I ran this on a page that was showing Shapiro/Peterson recs and they all disappeared entirely. Now I just need to figure out how to implement an event listener to ensure that the code runs as soon as the page loads the elements.
(Updated code below)
I had been running a similar script and it seemed to work at first, but after it stopped working I did some debugging and found that it was executing before the page elements finished loading. So I added code to wait an extra 5 seconds before executing and now it seems to be working fine. You can increase the amount of time it waits by updating the 5000 in the code to however many milliseconds you think you'll need.
One thing it does not block the associated thumbnail links to the videos as these belong to a different class. If somebody who actually knows what they're doing in javascript wants to update it to remove the thumbnails, or can figure out how to make it wait until all elements are loaded before running (I tried adding a listener but it didn't work), that would be great!
UPDATE:
I think I managed to get it to hide the entire recommendation element including the thumbnail link -- I ran this on a page that was showing Shapiro/Peterson recs and they all disappeared entirely. Now I just need to figure out how to implement an event listener to ensure that the code runs as soon as the page loads the elements.
Code:
// ==UserScript==
// @name youtube hide recommended crap
// @namespace hindbrain
// @description hide youtube recommended for you in side bar
// @include *youtube*
// @version 1
// @grant none
// ==/UserScript==
setTimeout(function() {
//Code to run After timeout elapses
'use strict';
//var spans = document.getElementsByClassName("yt-simple-endpoint style-scope ytd-compact-video-renderer");
var spans = document.getElementsByClassName("style-scope ytd-watch-next-secondary-results-renderer");
var spanschildren;
var flag;
console.log('spans length:' + spans.length);
for (var i = 0; i < spans.length; i++) {
flag = 0;
console.log("Tag: " + spans[i].tagName);
if (spans[i].tagName == "YTD-COMPACT-VIDEO-RENDERER"){
console.log(spans[i].textContent);
console.log('Text contains Shapiro: ' + spans[i].textContent.includes('Shapiro'));
console.log('Text contains Peterson: ' + spans[i].textContent.includes('Peterson'));
spanschildren = spans[i].children;
console.log('spanschildren length:' + spanschildren.length);
for (var j = 0; j < spanschildren.length; j++){
console.log(spanschildren[j].textContent);
if (spanschildren[j].textContent.includes('Shapiro') || spanschildren[j].textContent.includes('Peterson') || spanschildren[j].textContent.includes('JonTron')){
flag = 1;
}
}
}
if (flag == 1){
spans[i].hidden = "true";
}
}
}, 5000); //Five seconds will elapse and Code will execute.
;
Last edited: