// ==UserScript== // @name Repubblica.it: Hide the "ExitIntent" popup // @name:it Repubblica.it: Nasconde il popup "ExitIntent" // @description This script hides the "ExitIntent" popup that sometimes is shown when you want to exit from the current page of the site. // @description:it Questo script nasconde il popup "ExitIntent" che a volte viene visualizzato quando si vuole uscire dalla pagina corrente del sito. // @match https://*.repubblica.it/* // @grant none //// @run-at document-start // @version 1.1.0 // @author Cyrano68 // @license MIT // @namespace https://greasyfork.org/users/788550 // @downloadURL https://update.greasyfork.cloud/scripts/450050/Repubblicait%3A%20Hide%20the%20%22ExitIntent%22%20popup.user.js // @updateURL https://update.greasyfork.cloud/scripts/450050/Repubblicait%3A%20Hide%20the%20%22ExitIntent%22%20popup.meta.js // ==/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(`==> Repubblica_it_HideExitIntentPopup: HELLO! Loading script (version: ${myVersion})...`); document.addEventListener("DOMContentLoaded", onDOMContentLoaded); window.addEventListener("load", onWindowLoaded); createMutationObserver(); function onDOMContentLoaded() { console_log(`==> Repubblica_it_HideExitIntentPopup: onDOMContentLoaded - document.readyState=${document.readyState}`); // DO NOTHING! } function onWindowLoaded() { console_log(`==> Repubblica_it_HideExitIntentPopup: onWindowLoaded - document.readyState=${document.readyState}`); // DO NOTHING! } function onMutationList(mutationList, observer) { //console_log(`==> Repubblica_it_HideExitIntentPopup: onMutationList - mutationList.length=${mutationList.length}`); mutationList.forEach((mutation, i) => { //console_log(`==> Repubblica_it_HideExitIntentPopup: onMutationList - mutation[${i}] - mutation.type=${mutation.type}`); if (mutation.type === "childList") { let addedNodes = mutation.addedNodes; if (addedNodes.length > 0) { //console_log(`==> Repubblica_it_HideExitIntentPopup: onMutationList - mutation[${i}] - addedNodes.length=${addedNodes.length}`); addedNodes.forEach((addedNode, j) => { let searchedDiv = searchVisibleNode(addedNode, "div#adagio-overlay-try-buy"); if (searchedDiv !== null) { //console_log(`==> Repubblica_it_HideExitIntentPopup: onMutationList - searchedDiv.outerHTML='${searchedDiv.outerHTML}'`); let parentElement = searchedDiv.parentElement; console_log(`==> Repubblica_it_HideExitIntentPopup: onMutationList - parentElement='${parentElement}'`); searchedDiv.style.display = "none"; // Hide node. document.body.style.overflowY = "scroll"; // Show vertical scrollbar. console_log(`==> Repubblica_it_HideExitIntentPopup: onMutationList - 'adagio-overlay-try-buy' - mutation[${i}], addedNode[${j}] - searchedDiv.tagName='${searchedDiv.tagName}', searchedDiv.id='${searchedDiv.id}' ---> HIDDEN`); } }); } } }); } 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("==> Repubblica_it_HideExitIntentPopup: 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("==> Repubblica_it_HideExitIntentPopup: Script loaded"); })();