Skip to content

Instantly share code, notes, and snippets.

@ThenTech
Last active October 10, 2016 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThenTech/740a2f591becb5907768bd1c90983da3 to your computer and use it in GitHub Desktop.
Save ThenTech/740a2f591becb5907768bd1c90983da3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Youtube: Space to go to bottom of playlist
// @description Load playlist until everything is displayed and scrolls down if needed.
// @author Wosser1's Productions
// @namespace https://gist.github.com/Wosser1sProductions/
// @icon https://youtube.com/favicon.ico
// @version 0.3.1
// @include http*://*.youtube.com/playlist?list=*
// @include http*://*.youtube.com/*
// @include http*://youtube.com/*
// @include http*://*.youtu.be/*
// @include http*://youtu.be/*
// @exclude http*://*.youtube.com/watch?v=*
// ==/UserScript==
var loadID;
function getMoreBtn() {
return document.querySelector('button.load-more-button');
}
function scrollAndLoad() {
var moreButton = getMoreBtn();
if (moreButton !== null) {
moreButton.click();
} else {
//window.removeEventListener('keydown', setLoadInterval);
window.clearInterval(loadID);
}
window.scrollTo(0,document.body.scrollHeight);
}
function setLoadInterval(e) {
var validTarget = e.target === document.body;
if (validTarget && e.keyCode === 32) {
e.preventDefault();
window.scrollTo(0,document.body.scrollHeight);
if (!loadID)
if (getMoreBtn())
loadID = window.setInterval(scrollAndLoad, 100 );
}
}
window.addEventListener('keydown', e => setLoadInterval(e));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment