// ==UserScript== // @name Repubblica: Hide the "ExitIntent" overlay // @name:it Repubblica: Nasconde l'overlay "ExitIntent" // @description This script hides the "ExitIntent" overlay that sometimes is shown when you want to exit from the current page of the site. // @description:it Questo script nasconde l'overlay "ExitIntent" che a volte viene visualizzato quando si vuole uscire dalla pagina corrente del sito. // @match https://*.repubblica.it/* // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js // @grant none //// @run-at document-start // @version 1.0.1 // @author Cyrano68 // @license MIT // @namespace https://greasyfork.org/users/788550 // @downloadURL none // ==/UserScript== (function() { "use strict"; console.log("==> Repubblica_HideExitIntentOverlay: HELLO! Loading script..."); document.addEventListener("DOMContentLoaded", onDOMContentLoaded); window.addEventListener("load", onWindowLoaded); createMutationObserver(); function onDOMContentLoaded() { console.log("==> Repubblica_HideExitIntentOverlay: onDOMContentLoaded - document.readyState=" + document.readyState); // DO NOTHING! } function onWindowLoaded() { console.log("==> Repubblica_HideExitIntentOverlay: onWindowLoaded - document.readyState=" + document.readyState); } function onMutationList(mutationList, observer) { //console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - mutationList.length=" + mutationList.length); mutationList.forEach((mutation, i) => { //console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - i=" + i + ": mutation.type=" + mutation.type); switch(mutation.type) { case "childList": { var addedNodes = mutation.addedNodes; if (addedNodes.length > 0) { //console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - i=" + i + ": addedNodes.length=" + addedNodes.length); addedNodes.forEach((addedNode, j) => { //console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - i=" + i + ": onAddedNode - j=" + j + ": addedNode.tagName='" + addedNode.tagName + "'"); if (addedNode.tagName == "DIV") { //console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - i=" + i + ": onAddedNode - j=" + j + ": addedNode.tagName='" + addedNode.tagName + "', addedNode.id='" + addedNode.id + "'"); if (addedNode.id == "adagio-overlay-try-buy") { $(addedNode).hide(); console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - i=" + i + ": onAddedNode - j=" + j + ": addedNode.tagName='" + addedNode.tagName + "', addedNode.id='" + addedNode.id + "' ---> HIDDEN"); } } }); } var removedNodes = mutation.removedNodes; if (removedNodes.length > 0) { //console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - i=" + i + ": removedNodes.length=" + removedNodes.length); } break; } case "attributes": /* An attribute value changed on the element in mutation.target. The attribute name is in mutation.attributeName, and its previous value is in mutation.oldValue. */ break; } }); var divOverlay = $("div#adagio-overlay-try-buy:visible"); if (divOverlay.length > 0) { divOverlay.hide(); console.log("==> Repubblica_HideExitIntentOverlay: onMutationList - divOverlay.length=" + divOverlay.length + " ---> HIDDEN"); } } function createMutationObserver() { console.log("==> Repubblica_HideExitIntentOverlay: createMutationObserver"); // Options for the observer (which mutations to observe) const config = {attributes: true, childList: true, subtree: true, characterData: true}; var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; // Create an observer instance linked to the callback function const observer = new MutationObserver(onMutationList); // Start observing the target node for configured mutations observer.observe(document, config); } console.log("==> Repubblica_HideExitIntentOverlay: Script loaded"); })();