evildog1 / Auto scrolldown/up and refresh

// ==UserScript==
// @name         Auto scrolldown/up and refresh
// @namespace    https://openuserjs.org/users/evildog1
// @version      1.0.1
// @description  Useful for kiosk
// @license MIT
// @author       evildog1
// @match        https://*/*
// @grant        none
// ==/UserScript==
var lastScrollHeight = 0;
var bottom;

function pageScroll() {
    var sh = document.documentElement.scrollHeight;
    if (sh != lastScrollHeight) {
        lastScrollHeight = sh;
        document.documentElement.scrollTop = 0;
    }
    document.documentElement.scrollHeight = 0;
    if (!bottom) {
        window.scrollBy(0, 1);
        scrolldelay = setTimeout(pageScroll, 15);
    } else {
        window.scrollBy(0, -1);
        scrolldelay = setTimeout(pageScroll, 15);
    }
    setTimeout(refresh, 600000);
}

pageScroll();

window.onscroll = function(ev) {
    if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
        // setTimeout(refresh, 6000);
        bottom = true;
    }

    if (window.scrollY == 0) {
        bottom = false;
    }
};

function refresh() {
    window.location.reload(true);
}