History Scroll, back to the start of your YouTube history
History Scroll is a tiny script I wrote that keeps scrolling YouTube's watch history down by itself, batch after batch, and stops when it reaches the very first video.
/*
@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);curl -O https://pablomurad.com/snippets/history-scroll.js
A tiny script I wrote to get to the beginning of the YouTube watch history without holding the End key for half an hour.
The history page has no "oldest first" button. It loads a batch of videos and adds the next one only when you get close to the bottom.1 This script jumps to the bottom of the page every two seconds, so each jump asks for one more batch, and the list keeps going back in time on its own. Two seconds gives each batch time to arrive before the next jump.
Open youtube.com/feed/history, press F12, paste it into the console and leave the tab alone. It stops by itself when the page hasn't grown for five rounds in a row, about ten seconds, and an alert says you're at the first video you ever watched while signed in.2 The wait is there because a batch sometimes takes longer to show up, and one quiet round doesn't mean the list is over.
To stop it before that, run this in the same console:3
clearInterval(window.historyScroll);Notes
-
That pattern is called infinite scroll. The page watches for the end of the list to come into view and then fetches the next batch, instead of splitting the history into numbered pages. ↩
-
The history only goes as far back as YouTube kept it. If watch history was paused or auto-delete is on in your Google account, older videos are simply not there to load. ↩
-
setIntervalreturns a number that identifies the timer. Keeping it onwindowmeans it survives after the paste, andclearIntervalwith that number cancels it. ↩