FinecoBank.com: OBSOLETE - Refresh periodically the currrent page

This is script is obsolete and can be replaced by the new script https://gf.qytechs.cn/it/scripts/540426-finecobank-com-hide-annoying-popups-the-warning-disconnection-popup. 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: OBSOLETE - Refresh periodically the currrent page
// @name:it        FinecoBank.com: OBSOLETO - Aggiorna periodicamente la pagina corrente
// @description    This is script is obsolete and can be replaced by the new script https://gf.qytechs.cn/it/scripts/540426-finecobank-com-hide-annoying-popups-the-warning-disconnection-popup. 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 è obsoleto e può essere sostituito dal nuovo script https://gf.qytechs.cn/it/scripts/540426-finecobank-com-hide-annoying-popups-the-warning-disconnection-popup. 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.1.6
// @author         Cyrano68
// @license        MIT
// @namespace https://gf.qytechs.cn/users/788550
// ==/UserScript==

(function()
{
    "use strict";

    function getZeroFilledMillisecs(dateNow)
    {
        const millisecs = dateNow.getMilliseconds();
        return ("00" + millisecs).slice(-3);
    }

    function consoleLog(text)
    {
        const dateNow = new Date();
        //const now = dateNow.toISOString();
        const now = dateNow.toLocaleString() + "." + getZeroFilledMillisecs(dateNow);
        console.log(`${now} ${text}`);
    }

    const myVersion = GM_info.script.version;
    consoleLog(`==> FinecoBank_com_RefreshPage: HELLO! Loading script (version: ${myVersion})...`);

    const currUrl = window.location.href;
    consoleLog(`==> FinecoBank_com_RefreshPage: currUrl='${currUrl}'`);

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

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

    let timerId = 0;
    let startTime;

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

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

    function checkRefreshPage()
    {
        const currTime = new Date();
        const elapsedTime_ms = currTime - startTime;
        const elapsedTime_s = elapsedTime_ms / 1e3;

        consoleLog(`==> FinecoBank_com_RefreshPage: checkRefreshPage - elapsedTime_ms=${elapsedTime_ms} (${elapsedTime_s} secs)`);
        if (elapsedTime_ms >= refreshInterval_ms)
        {
            clearInterval(timerId);
            consoleLog(`==> FinecoBank_com_RefreshPage: checkRefreshPage - TIMER STOPPED - timerId=${timerId}`);
            timerId = 0;
            consoleLog(`==> 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);
            consoleLog(`==> FinecoBank_com_RefreshPage: checkRefreshPage - TIMER STOPPED - timerId=${timerId}`);
            timerId = 0;
            const shortInterval_ms = refreshInterval_ms - elapsedTime_ms;
            const shortInterval_s = shortInterval_ms / 1e3;
            consoleLog(`==> FinecoBank_com_RefreshPage: checkRefreshPage - STARTING TIMER 'checkRefreshPage' - shortInterval_ms=${shortInterval_ms} () (${shortInterval_s} secs)`);
            timerId = setInterval(checkRefreshPage, shortInterval_ms);
            consoleLog(`==> FinecoBank_com_RefreshPage: checkRefreshPage - TIMER STARTED - timerId=${timerId}`);
            consoleLog(`==> FinecoBank_com_RefreshPage: checkRefreshPage - shortInterval=${shortInterval_s} secs - wait...`);
        }
        else
        {
            consoleLog(`==> FinecoBank_com_RefreshPage: checkRefreshPage - wait ${interval_s} secs...`);
            // DO NOTHING!
        }
    }

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址