Last active
October 10, 2016 19:25
-
-
Save ThenTech/740a2f591becb5907768bd1c90983da3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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