Reddit saved autoscroller

Script to scroll automatically to the bottom of Reddit's saved page

Fra 03.09.2021. Se den seneste versjonen.

// ==UserScript==
// @name        Reddit saved autoscroller
// @match       https://www.reddit.com/user/*/saved/
// @grant       none
// @version     1.0
// @author      AdrianSkar
// @description Script to scroll automatically to the bottom of Reddit's saved page
// @namespace https://greasyfork.org/users/564765
// ==/UserScript==
/*jshint esversion: 6 */

// Scroll fn
function autoScroll(time) {
	let intervalA = window.setInterval(() => {
		if ((window.scrollY + window.screen.height) >= document.body.scrollHeight) {
			alert('done scrolling');
			clearInterval(intervalA);
			return;
		}
		else window.scrollTo(0, document.body.scrollHeight);
	}, time);
}

// Create and display new button
let lastButton = document.querySelector('#profile-nav-menu-tooltip');
let scrollButton = lastButton.cloneNode();
scrollButton.textContent = 'SCROLL TO BOTTOM';
lastButton.parentElement.appendChild(scrollButton);

// Listen for click and perform autoScroll
scrollButton.addEventListener('click', () => {
	let time = prompt("Speed in ms (you'l get an alert when done):");
	autoScroll(time);
});