AdnKronos.com: Hide Annoying popups (the anti-adblock popup and others)

This script hides the annoying popups (the anti-adblock popup and others) that are shown in the web page.

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name           AdnKronos.com: Hide Annoying popups (the anti-adblock popup and others)
// @name:it        AdnKronos.com: Nasconde i popup fastidiosi (il popup anti-adblock ed altri)
// @description    This script hides the annoying popups (the anti-adblock popup and others) that are shown in the web page.
// @description:it Questo script nasconde i popup fastidiosi (il popup anti-adblock e altri) che vengono visualizzati nella pagina web.
// @match          https://*.adnkronos.com/*
// @grant          none
//// @run-at         document-start
// @version        1.0.3
// @author         Cyrano68
// @license        MIT
// @namespace https://gf.zukizuki.org/users/788550
// ==/UserScript==

(function()
{
    "use strict";

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

    var myVersion = GM_info.script.version;
    console_log(`==> AdnKronos_com_HideAnnoyingPopups: HELLO! Loading script (version: ${myVersion})...`);

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

    createMutationObserver();

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

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

    function onMutationList(mutationList, observer)
    {
        //console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - mutationList.length=${mutationList.length}`);
        mutationList.forEach((mutation, i) =>
        {
            //console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - mutation[${i}] - mutation.type=${mutation.type}`);
            if (mutation.type === "childList")
            {
                let addedNodes = mutation.addedNodes;
                if (addedNodes.length > 0)
                {
                    //console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - mutation[${i}] - addedNodes.length=${addedNodes.length}`);
                    addedNodes.forEach((addedNode, j) =>
                    {
                        let searchedDiv = searchVisibleNode(addedNode, "div#qc-cmp2-container");
                        if (searchedDiv !== null)
                        {
                            // Hide a popup that asks to accept cookies and show again the vertical scrollbar.
                            //

                            //console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - searchedDiv.outerHTML='${searchedDiv.outerHTML}'`);

                            let parentElement = searchedDiv.parentElement;
                            console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - parentElement: tagName='${parentElement.tagName}' id='${parentElement.id}'`);

                            searchedDiv.style.display = "none";  // Hide node.
                            document.body.style.overflowY = "scroll";  // Show vertical scrollbar.
                            searchedDiv.remove();  // Remove node. IMPORTANT: Without this instruction the script does NOT work properly.
                            console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - 'qc-cmp2-container' - mutation[${i}], addedNode[${j}] - searchedDiv.tagName='${searchedDiv.tagName}', searchedDiv.classList='${searchedDiv.classList}' ---> HIDDEN/REMOVED`);
                        }

                        searchedDiv = searchVisibleNode(addedNode, "div.gdpr_container");
                        if (searchedDiv !== null)
                        {
                            // Hide another popup that asks to accept cookies and show again the vertical scrollbar.
                            //

                            //console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - searchedDiv.outerHTML='${searchedDiv.outerHTML}'`);

                            let parentElement = searchedDiv.parentElement;
                            console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - parentElement: tagName='${parentElement.tagName}' id='${parentElement.id}'`);

                            searchedDiv.style.display = "none";  // Hide node.
                            document.body.style.overflowY = "scroll";  // Show vertical scrollbar.
                            searchedDiv.remove();  // Remove node. IMPORTANT: Without this instruction the script does NOT work properly.
                            console_log(`==> AdnKronos_com_HideAnnoyingPopups: onMutationList - 'gdpr_container' - mutation[${i}], addedNode[${j}] - searchedDiv.tagName='${searchedDiv.tagName}', searchedDiv.classList='${searchedDiv.classList}' ---> HIDDEN/REMOVED`);
                        }
                    });
                }
            }
        });
    }

    function searchVisibleNode(node, selector)
    {
        let parentElement = node.parentElement;
        return (parentElement === null ? null : parentElement.querySelector(`${selector}:not([style*=\"display:none\"]):not([style*=\"display: none\"])`));
    }

    function createMutationObserver()
    {
        console_log("==> AdnKronos_com_HideAnnoyingPopups: createMutationObserver");

        // SEE: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
        const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;

        // Create an observer instance linked to the callback function.
        const observer = new MutationObserver(onMutationList);

        // Options for the observer (which mutations to observe).
        const config = {subtree: true, childList: true};

        // Start observing the target node for configured mutations.
        observer.observe(document, config);
    }

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