// ==UserScript== // @name Repubblica: Hide the "UsingAdBlock" alert // @name:it Repubblica: Nasconde l'avviso "UsingAdBlock" // @description This script hides the alert "UsingAdBlock" that is shown when you use an ad-block. // @description:it Questo script nasconde l'alert "UsingAdBlock" che viene visualizzato quando si usa un ad-block. // @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.4 // @author Cyrano68 // @license MIT // @namespace https://greasyfork.org/users/788550 // @downloadURL none // ==/UserScript== (function() { "use strict"; function console_log(text) { //let now = new Date().toISOString(); let now = new Date().toLocaleString(); console.log(`${now} ${text}`); } console_log("==> Repubblica_HideUsingAdBlockAlert: HELLO! Loading script..."); document.addEventListener("DOMContentLoaded", onDOMContentLoaded); window.addEventListener("load", onWindowLoaded); createMutationObserver(); function onDOMContentLoaded() { console_log(`==> Repubblica_HideUsingAdBlockAlert: onDOMContentLoaded - document.readyState=${document.readyState}`); // DO NOTHING! } function onWindowLoaded() { console_log(`==> Repubblica_HideUsingAdBlockAlert: onWindowLoaded - document.readyState=${document.readyState}`); // DO NOTHING! } function onMutationList(mutationList, observer) { // We can simply check the presence of the popup in the DOM tree. var divContainer = $("div.fc-dialog-container:visible"); //console_log(`==> Repubblica_HideUsingAdBlockAlert: onMutationList - divContainer.length=${divContainer.length}`); if (divContainer.length > 0) { divContainer.hide(); divContainer.remove(); $("body").css("overflow-y", "scroll"); // Show vertical scrollbar console_log(`==> Repubblica_HideUsingAdBlockAlert: onMutationList - divContainer.length=${divContainer.length} ---> HIDDEN/REMOVED`); } /* // Even if the Firefox-Settings about autoplay is "Block Audio and Video" a popup containing a video-player appears on the bottom-right of screen // (it appears without audio and video, but appears). Here we hide that popup. var divWrapper = $("div.video-frame__wrapper:visible"); //console_log(`==> Repubblica_HideUsingAdBlockAlert: onMutationList - divWrapper.length=${divWrapper.length}`); if (divWrapper.length > 0) { divWrapper.hide(); divWrapper.remove(); $("body").css("overflow-y", "scroll"); // Show vertical scrollbar console_log(`==> Repubblica_HideUsingAdBlockAlert: onMutationList - divWrapper.length=${divWrapper.length} ---> HIDDEN/REMOVED`); } */ } function createMutationObserver() { console_log("==> Repubblica_HideUsingAdBlockAlert: 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_HideUsingAdBlockAlert: Script loaded"); })();