FinecoBank.com: Refresh periodically the currrent page

This script refreshes periodically the current page of FinecoBank.com in order to avoid (after 4 min.) the warning modal popup and (after 5 min.) the disconnection.

// ==UserScript==
// @name           FinecoBank.com: Refresh periodically the currrent page
// @name:it        FinecoBank.com: Aggiorna periodicamente la pagina corrente
// @description    This script refreshes periodically the current page of FinecoBank.com in order to avoid (after 4 min.) the warning modal popup and (after 5 min.) the disconnection.
// @description:it Questo script aggiorna periodicamente la pagina corrente di FinecoBank.com per evitare che (dopo 4 min.) venga visualizzato il popup modale di avviso e che (dopo 5 min.) venga eseguita la disconnessione.
// @match          https://finecobank.com/*
// @exclude        https://finecobank.com/app/powerbook/*
// @grant          none
//// @run-at         document-start
// @version        1.0.7
// @author         Cyrano68
// @license        MIT
// @namespace https://greasyfork.org/users/788550
// ==/UserScript==

(function()
{
    "use strict";

    function console_log(text)
    {
        //let now = new Date().toISOString();
        let now = new Date().toLocaleString();
        console.log(`${now} ${text}`);
    }

    console_log("==> FinecoBank_com_RefreshPage: HELLO! Loading script...");

    document.addEventListener("DOMContentLoaded", onDOMContentLoaded);
    window.addEventListener("load", onWindowLoaded);

    let timerId = 0;
    let interval_ms = 10000; // 10s
    let refreshInterval_ms = (3*60 + 45)*1000; // 3m45s ---> less than 4m, in order to avoid the modal popup.
    let startTime;

    function onDOMContentLoaded()
    {
        console_log(`==> FinecoBank_com_RefreshPage: onDOMContentLoaded - document.readyState=${document.readyState}`);
        // DO NOTHING!
    }

    function onWindowLoaded()
    {
        let currUrl = window.location.href;
        console_log(`==> FinecoBank_com_RefreshPage: onWindowLoaded - document.readyState=${document.readyState}`);
        // Start a timer that periodically checks if it's time to refresh the current page.
        console_log(`==> FinecoBank_com_RefreshPage: onWindowLoaded - STARTING TIMER 'checkRefreshPage' - interval_ms=${interval_ms}`);
        timerId = setInterval(checkRefreshPage, interval_ms);
        console_log(`==> FinecoBank_com_RefreshPage: onWindowLoaded - TIMER STARTED - timerId=${timerId} - currUrl='${currUrl}'`);
        console_log(`==> FinecoBank_com_RefreshPage: onWindowLoaded - wait ${interval_ms/1e3} secs...`);
        startTime = new Date();
    }

    function checkRefreshPage()
    {
        let currUrl = window.location.href;
        let currTime = new Date();
        let elapsedTime_ms = currTime - startTime;
        console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - elapsedTime_ms=${elapsedTime_ms} (${elapsedTime_ms/1e3} secs)`);
        if (elapsedTime_ms >= refreshInterval_ms)
        {
            clearInterval(timerId);
            console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - TIMER STOPPED - timerId=${timerId}`);
            timerId = 0;
            console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - REFRESH PAGE - currUrl='${currUrl}'`);
            window.location.reload();  // Refresh the current page
        }
        else if (elapsedTime_ms > (refreshInterval_ms - interval_ms))
        {
            clearInterval(timerId);
            console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - TIMER STOPPED - timerId=${timerId}`);
            timerId = 0;
            let shortInterval_ms = refreshInterval_ms - elapsedTime_ms;
            console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - STARTING TIMER 'checkRefreshPage' - shortInterval_ms=${shortInterval_ms}`);
            timerId = setInterval(checkRefreshPage, shortInterval_ms);
            console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - TIMER STARTED - timerId=${timerId}`);
            console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - wait ${shortInterval_ms/1e3} secs...`);
        }
        else
        {
            console_log(`==> FinecoBank_com_RefreshPage: checkRefreshPage - wait ${interval_ms/1e3} secs...`);
            // DO NOTHING!
        }
    }

    console_log("==> FinecoBank_com_RefreshPage: Script loaded");
})();