/* @name History Scroll @description Keep scrolling the YouTube watch history until it reaches the beginning, then stop @author Pablo Murad ยท https://pablomurad.com To stop early: clearInterval(window.historyScroll); */ let lastHeight = 0, still = 0; window.historyScroll = setInterval(() => { const h = document.documentElement.scrollHeight; /* Count how many rounds in a row the page did not grow */ still = (h === lastHeight) ? still + 1 : 0; lastHeight = h; if (still >= 5) { clearInterval(window.historyScroll); alert('Reached the start of your history.'); return; } window.scrollTo(0, h); }, 2000);