Last active
June 24, 2019 20:21
-
-
Save RafalJDev/273173ec3a7595d96d7178bcf5444db5 to your computer and use it in GitHub Desktop.
Scroll to index video on youtube playlist page
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
function scrollTillIndexNumber (indexToScroll) { | |
window.scrollTo(0,document.querySelector("div.style-scope ytd-section-list-renderer").scrollHeight); | |
var lastElementIndex = document.getElementsByTagName("yt-formatted-string").length; | |
var currentLastIndex = (lastElementIndex - 8)/2; | |
if (currentLastIndex < indexToScroll) { | |
setTimeout(function () { scrollTillIndexNumber(indexToScroll)} | |
,400); | |
return; | |
}; | |
}; | |
var videosElement = document.getElementsByClassName('ytd-playlist-sidebar-primary-info-renderer')[4].textContent.replace(' videos',''); | |
var amountOfVideos = parseInt(videosElement) | |
scrollTillIndexNumber(amountOfVideos); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment