It's my first time using grease monkey, and I'm a novice at javascript, but I have some simple code to delete the suggested videos on the right-hand side of YouTube, which I find can distract me from work:
var elem = document.getElementById('watch-related');
elem.parentNode.removeChild(elem);
I've tried using addEventListener()
; as well as a while
loop with a setTimeOut()
; and I've tried setInterval()
. None worked. But they all, including the plain code, work if I refresh the page or arrive at the link from an external source, but if I arrive at the video from another YouTube page it doesn't.
I think it has something to do with the way YouTube loads pages, but I haven't been able to find any workarounds. Any ideas?
Edit: I also found this, which has some good info on this topic, but also doesn't work.