Comment by susam
16 days ago
Here is another one I found in my personal userscripts. I believe this script is more effective than my previous one because it prevents recommendations for Shorts or other videos from being shown.
// ==UserScript==
// @name No YT Sidebar and Shorts
// @match https://www.youtube.com/*
// ==/UserScript==
function noYTSidebar () {
const element = document.getElementById('secondary')
if (element === null) {
window.setTimeout(noYTSidebar, 1000)
return
}
element.getElementById('secondary').style.display = 'none'
}
function noYTShorts () {
const elements = document.querySelectorAll('ytd-rich-shelf-renderer')
if (elements.length === 0) {
window.setTimeout(noYTShorts, 1000)
return
}
for (e of document.querySelectorAll('ytd-rich-shelf-renderer')) {
e.style.display = 'none'
}
}
noYTSidebar()
noYTShorts()
This is what I used, they have field `is-short`, https://github.com/epicseven-cup/remove-youtube-short/blob/m...
https://addons.mozilla.org/en-US/firefox/addon/remove-youtub...
Thanks for sharing. I realised I have several userscripts I've written over time to tackle web browsing distractions. I found another one and this is probably the most effective for me because it hides Shorts at the CSS level. That means I don't need to rely on setTimeout(..., 1000) to catch elements that get inserted dynamically after the page loads.
I did a firefox addon 3 months ago. You can disable/enable things in addon menu. I'm using Study mode actively as I'm a student.
https://github.com/ErenayDev/YouTube-Focus