FinecoBank.com: Hide Annoying popups (the warning-disconnection popup)

This script hides the annoying popups (the warning-disconnection popu) that are shown in the web page.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           FinecoBank.com: Hide Annoying popups (the warning-disconnection popup)
// @name:it        FinecoBank.com: Nasconde i popup fastidiosi (il popup di avviso disconnessione)
// @description    This script hides the annoying popups (the warning-disconnection popu) that are shown in the web page.
// @description:it Questo script nasconde i popup fastidiosi (il popup di avviso disconnessione) che vengono visualizzati nella pagina web.
// @namespace      https://greasyfork.org/users/788550
// @version        1.0.8
// @author         Cyrano68
// @license        MIT
// @match          https://finecobank.com/*
// @require        https://update.greasyfork.org/scripts/547732/1651464/BasicLib.js
// @require        https://update.greasyfork.org/scripts/535551/1709323/HideAnnoyingPopupsLib.js
// @grant          none
// ==/UserScript==

// This is a IIFE (Immediately Invoked Function Expression).
(function()
{
    "use strict";

    const blib = window.BasicLib;
    blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: Using library 'BasicLib' (version: ${blib.getVersion()})`);

    const haplib = window.HideAnnoyingPopupsLib;
    blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: Using library 'HideAnnoyingPopupsLib' (version: ${haplib.getVersion()})`);

    //// When enabled, additional log will be shown.
    //haplib.setShowDebugLog(true);

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

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

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

    const buttonText = "RIMANI CONNESSO";
    //const minClickDelay_s = 0;
    const minClickDelay_s = 2;
    const maxRandomClickDelay_s = 3;

    const myID = blib.generateID();
    blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: myID='${myID}'`);

    function onMutatedNode(mutation, selector, foundNode)
    {
        // This function must return a boolean value: stopMutationProcessing. When it is TRUE the current mutation will not be further processed.
        // IMPORTANT: In this case we will always return TRUE (otherwise the "haplib" will hide every matching button).
        //

        if ((typeof(foundNode) === "undefined") && (typeof(selector) === "object"))
        {
            foundNode = selector;
            selector = undefined;
        }

        blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: onMutatedNode - BEGIN - myID='${myID}' - foundNode.textContent=${foundNode.textContent}`);
        let stopMutationProcessing = false;

        if (foundNode.textContent === buttonText)
        {
            // The popup will appear for "clickDelay_ms" milliseconds. Then the script will click "programmatically" on the button.
            if (minClickDelay_s > 0)
            {
                const maxRandomClickDelay_ms = maxRandomClickDelay_s * 1e3;
                const randomClickDelay_ms = blib.getMathRandomInteger(maxRandomClickDelay_ms);

                const minClickDelay_ms = minClickDelay_s * 1e3;
                const clickDelay_ms = minClickDelay_ms + randomClickDelay_ms;
                blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: onMutatedNode - myID='${myID}' - clickDelay_ms=${clickDelay_ms}`);
                setTimeout(() =>
                {
                    blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: onMutatedNode - delayed - myID='${myID}' - clicking on button programmatically`);
                    foundNode.click();
                }, clickDelay_ms);
            }
            else
            {
                blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: onMutatedNode - myID='${myID}' - clicking on button programmatically`);
                foundNode.click();
            }
        }
        else
        {
            blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: onMutatedNode - myID='${myID}' - Button IGNORED`);
        }

        stopMutationProcessing = true;
        blib.consoleLog(`==> FinecoBank_com_HideAnnoyingPopups: onMutatedNode - END - myID='${myID}' - stopMutationProcessing=${stopMutationProcessing}`);
        return stopMutationProcessing;
    }

    const mutationObserverConfig = {subtree: true, childList: true};
    const mutatedNodesConfig     = {selectors: ["button.btn.btn-primary"], onMutatedNode: onMutatedNode};
    haplib.configure(mutationObserverConfig, mutatedNodesConfig);

    blib.consoleLog("==> FinecoBank_com_HideAnnoyingPopups: Script loaded");
})();