I\'m writing a Chrome extension so I need to be able to listen for changes in the YouTube URL (i.e., see that you switched videos). YouTube makes this hard because with its
My solution was to simply check for the transitionend event on the #progress element (this is the red progress bar that shows up at the top).
document.addEventListener('transitionend', function(e) {
if (e.target.id === 'progress')
// do stuff
});
An even cleaner solution is to just listen for the spfdone event triggered by spfjs, the framework used by YouTube to manipulate push state. Credit to Rob for the answer.
document.addEventListener('spfdone', function() {
// do stuff
});