Spacebar scroll marker

Fading marker line when you hit space to scroll.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Spacebar scroll marker
// @namespace    None
// @version      0.1
// @description  Fading marker line when you hit space to scroll.
// @match        *://*/*
// @exclude      *://*.reddit.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let i, elements=document.querySelectorAll('body *');
    for (i=0;i < elements.length;i++) {
        if (getComputedStyle(elements[i]).position === 'fixed' || getComputedStyle(elements[i]).position === 'sticky') {
            elements[i].parentNode.removeChild(elements[i]);
        }
    }
    let elem=Array.from(document.getElementsByTagName("body"))[0].appendChild(document.createElement('div'));
    elem.style.width="100%";
    elem.style.borderTop="1px solid red";
    elem.style.position="absolute";
    elem.style.top="0px";
    elem.style.opacity="0";
    elem.style.transition="opacity 1500ms";
    window.addEventListener('keydown', e => {
        if(e.code === "Space"){
            elem.style.transition="";
            elem.style.top=(window.innerHeight + window.scrollY) + "px";
            elem.style.opacity="1";
            setTimeout(function(){
                elem.style.transition="opacity 1500ms";
                elem.style.opacity="0";
            }, 200);
        }
    }
);
}())();