Skip to content

Instantly share code, notes, and snippets.

@Rochdy
Created February 18, 2023 03:04
Show Gist options
  • Save Rochdy/aeadab548fb657cb1e90c3b5b1b30038 to your computer and use it in GitHub Desktop.
Save Rochdy/aeadab548fb657cb1e90c3b5b1b30038 to your computer and use it in GitHub Desktop.
Auto scroll youtube shorts
const observer = new MutationObserver(
(mutationList, observer) => {
for (const mutation of mutationList) {
if (mutation.type === 'attributes' && mutation.target.localName === 'video') {
//Change the video playback speed if you think people are boring
//mutation.target.playbackRate = 1.25;
mutation.target.loop = false;
mutation.target.onended = (e) => document.getElementById('shorts-container').scrollTop += mutation.target.scrollHeight;
}
}
}
);
observer.observe(document.getElementById('shorts-container'), { attributes: true, childList: true, subtree: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment