3BMeteo.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.

  1. // ==UserScript==
  2. // @name 3BMeteo.com: Hide Annoying popups (the anti-adblock popup and others)
  3. // @name:it 3BMeteo.com: Nasconde i popup fastidiosi (il popup anti-adblock ed altri)
  4. // @description This script hides the annoying popups (the anti-adblock popup and others) that are shown in the web page.
  5. // @description:it Questo script nasconde i popup fastidiosi (il popup anti-adblock e altri) che vengono visualizzati nella pagina web.
  6. // @match https://*.3bmeteo.com/*
  7. // @grant none
  8. //// @run-at document-start
  9. // @version 1.0.7
  10. // @author Cyrano68
  11. // @license MIT
  12. // @namespace https://greatest.deepsurf.us/users/788550
  13. // ==/UserScript==
  14.  
  15. (function()
  16. {
  17. "use strict";
  18.  
  19. function console_log(text)
  20. {
  21. const dateNow = new Date();
  22. //let now = dateNow.toISOString();
  23. let now = dateNow.toLocaleString() + "." + dateNow.getMilliseconds();
  24. console.log(`${now} ${text}`);
  25. }
  26.  
  27. var myVersion = GM_info.script.version;
  28. console_log(`==> 3BMeteo_com_HideAnnoyingPopups: HELLO! Loading script (version: ${myVersion})...`);
  29.  
  30. document.addEventListener("DOMContentLoaded", onDOMContentLoaded);
  31. window.addEventListener("load", onWindowLoaded);
  32.  
  33. createMutationObserver();
  34.  
  35. function onDOMContentLoaded()
  36. {
  37. console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onDOMContentLoaded - document.readyState=${document.readyState}`);
  38. // DO NOTHING!
  39. }
  40.  
  41. function onWindowLoaded()
  42. {
  43. console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onWindowLoaded - document.readyState=${document.readyState}`);
  44. // DO NOTHING!
  45. }
  46.  
  47. function onMutationList(mutationList, observer)
  48. {
  49. //console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - mutationList.length=${mutationList.length}`);
  50. mutationList.forEach((mutation, i) =>
  51. {
  52. //console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - mutation[${i}] - mutation.type=${mutation.type}`);
  53. if (mutation.type === "childList")
  54. {
  55. let addedNodes = mutation.addedNodes;
  56. if (addedNodes.length > 0)
  57. {
  58. //console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - mutation[${i}] - addedNodes.length=${addedNodes.length}`);
  59. addedNodes.forEach((addedNode, j) =>
  60. {
  61. let searchedDiv = searchVisibleNode(addedNode, "div#iubenda-cs-banner");
  62. if (searchedDiv !== null)
  63. {
  64. // Hide the anti-adblock popup and show again the vertical scrollbar.
  65. //
  66.  
  67. //console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - searchedDiv.outerHTML='${searchedDiv.outerHTML}'`);
  68.  
  69. let parentElement = searchedDiv.parentElement;
  70. console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - parentElement: tagName='${parentElement.tagName}' id='${parentElement.id}'`);
  71.  
  72. searchedDiv.style.display = "none"; // Hide node.
  73. document.body.style.overflowY = "scroll"; // Show vertical scrollbar.
  74. searchedDiv.remove(); // Remove node. IMPORTANT: Without this instruction the script does NOT work properly.
  75. console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - 'iubenda-cs-banner' - mutation[${i}], addedNode[${j}] - searchedDiv.tagName='${searchedDiv.tagName}', searchedDiv.classList='${searchedDiv.classList}' ---> HIDDEN/REMOVED`);
  76. }
  77.  
  78. searchedDiv = searchVisibleNode(addedNode, "div#sidebar-video-fixed");
  79. if (searchedDiv !== null)
  80. {
  81. // Even if the Firefox-Settings about autoplay is "Block Audio and Video" a popup containing a video-player appears
  82. // on the bottom-right of screen (it appears without audio and with stopped video, but appears). Here we hide that popup.
  83. //
  84.  
  85. //console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - searchedDiv.outerHTML='${searchedDiv.outerHTML}'`);
  86.  
  87. let parentElement = searchedDiv.parentElement;
  88. console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - parentElement: tagName='${parentElement.tagName}' id='${parentElement.id}'`);
  89.  
  90. searchedDiv.style.display = "none"; // Hide node.
  91. document.body.style.overflowY = "scroll"; // Show vertical scrollbar.
  92. searchedDiv.remove(); // Remove node. IMPORTANT: Without this instruction the script does NOT work properly.
  93. console_log(`==> 3BMeteo_com_HideAnnoyingPopups: onMutationList - 'sidebar-video-fixed' - mutation[${i}], addedNode[${j}] - searchedDiv.tagName='${searchedDiv.tagName}', searchedDiv.classList='${searchedDiv.classList}' ---> HIDDEN/REMOVED`);
  94. }
  95. });
  96. }
  97. }
  98. });
  99. }
  100.  
  101. function searchVisibleNode(node, selector)
  102. {
  103. let parentElement = node.parentElement;
  104. return (parentElement === null ? null : parentElement.querySelector(`${selector}:not([style*=\"display:none\"]):not([style*=\"display: none\"])`));
  105. }
  106.  
  107. function createMutationObserver()
  108. {
  109. console_log("==> 3BMeteo_com_HideAnnoyingPopups: createMutationObserver");
  110.  
  111. // SEE: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
  112. const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  113.  
  114. // Create an observer instance linked to the callback function.
  115. const observer = new MutationObserver(onMutationList);
  116.  
  117. // Options for the observer (which mutations to observe).
  118. const config = {subtree: true, childList: true};
  119.  
  120. // Start observing the target node for configured mutations.
  121. observer.observe(document, config);
  122. }
  123.  
  124. console_log("==> 3BMeteo_com_HideAnnoyingPopups: Script loaded");
  125. })();