[Twitter] Fix scroll

My very crude attempt at fixing twitter scrolling to top of page on moving back from sub-tweets.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         [Twitter] Fix scroll
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  My very crude attempt at fixing twitter scrolling to top of page on moving back from sub-tweets.
// @author       SL1900
// @match        *://*.twitter.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    let session_store = {};

    setInterval(()=>{
        if(window.scrollY < 50 && session_store[window.location.href] && session_store[window.location.href] > 300)
        {
            console.log(session_store[window.location.href]);
            window.scroll(window.scrollX, session_store[window.location.href]);
        }

        if(window.scrollY > 150) session_store[window.location.href] = window.scrollY;
    }, 100);
})();