Tellows.it: 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 Tellows.it: Hide Annoying popups (the anti-adblock popup and others)
  3. // @name:it Tellows.it: 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://*.tellows.it/*
  7. // @grant none
  8. //// @run-at document-start
  9. // @version 1.0.3
  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 getZeroFilledMillisecs(dateNow)
  20. {
  21. let millisecs = dateNow.getMilliseconds();
  22. return ("00" + millisecs).slice(-3);
  23. }
  24.  
  25. function console_log(text)
  26. {
  27. const dateNow = new Date();
  28. //let now = dateNow.toISOString();
  29. let now = dateNow.toLocaleString() + "." + getZeroFilledMillisecs(dateNow);
  30. console.log(`${now} ${text}`);
  31. }
  32.  
  33. var myVersion = GM_info.script.version;
  34. console_log(`==> Tellows_it_HideAnnoyingPopup: HELLO! Loading script (version: ${myVersion})...`);
  35.  
  36. document.addEventListener("DOMContentLoaded", onDOMContentLoaded);
  37. window.addEventListener("load", onWindowLoaded);
  38.  
  39. createMutationObserver();
  40.  
  41. function onDOMContentLoaded()
  42. {
  43. console_log(`==> Tellows_it_HideAnnoyingPopup: onDOMContentLoaded - document.readyState=${document.readyState}`);
  44. // DO NOTHING!
  45. }
  46.  
  47. function onWindowLoaded()
  48. {
  49. console_log(`==> Tellows_it_HideAnnoyingPopup: onWindowLoaded - document.readyState=${document.readyState}`);
  50. // DO NOTHING!
  51. }
  52.  
  53. function onMutationList(mutationList, observer)
  54. {
  55. //console_log(`==> Tellows_it_HideAnnoyingPopup: onMutationList - mutationList.length=${mutationList.length}`);
  56. mutationList.forEach((mutation, i) =>
  57. {
  58. //console_log(`==> Tellows_it_HideAnnoyingPopup: onMutationList - mutation[${i}] - mutation.type=${mutation.type}`);
  59. if (mutation.type === "childList")
  60. {
  61. let addedNodes = mutation.addedNodes;
  62. if (addedNodes.length > 0)
  63. {
  64. //console_log(`==> Tellows_it_HideAnnoyingPopup: onMutationList - mutation[${i}] - addedNodes.length=${addedNodes.length}`);
  65. addedNodes.forEach((addedNode, j) =>
  66. {
  67. let searchedDiv = searchVisibleNode(addedNode, "div.fc-dialog-container");
  68. if (searchedDiv !== null)
  69. {
  70. // Hide the anti-adblock popup and show again the vertical scrollbar.
  71. //
  72.  
  73. //console_log(`==> Tellows_it_HideAnnoyingPopup: onMutationList - searchedDiv.outerHTML='${searchedDiv.outerHTML}'`);
  74.  
  75. let parentElement = searchedDiv.parentElement;
  76. console_log(`==> Tellows_it_HideAnnoyingPopup: onMutationList - parentElement: tagName='${parentElement.tagName}' id='${parentElement.id}'`);
  77.  
  78. searchedDiv.style.display = "none"; // Hide node.
  79. document.body.style.overflowY = "scroll"; // Show vertical scrollbar.
  80. searchedDiv.remove(); // Remove node. IMPORTANT: Without this instruction the script does NOT work properly.
  81. console_log(`==> Tellows_it_HideAnnoyingPopup: onMutationList - 'fc-dialog-container' - mutation[${i}], addedNode[${j}] - searchedDiv.tagName='${searchedDiv.tagName}', searchedDiv.classList='${searchedDiv.classList}' ---> HIDDEN/REMOVED`);
  82. }
  83. });
  84. }
  85. }
  86. });
  87. }
  88.  
  89. function searchVisibleNode(node, selector)
  90. {
  91. let parentElement = node.parentElement;
  92. return (parentElement === null ? null : parentElement.querySelector(`${selector}:not([style*=\"display:none\"]):not([style*=\"display: none\"])`));
  93. }
  94.  
  95. function createMutationObserver()
  96. {
  97. console_log("==> Tellows_it_HideAnnoyingPopup: createMutationObserver");
  98.  
  99. // SEE: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
  100. const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  101.  
  102. // Create an observer instance linked to the callback function.
  103. const observer = new MutationObserver(onMutationList);
  104.  
  105. // Options for the observer (which mutations to observe).
  106. const config = {subtree: true, childList: true};
  107.  
  108. // Start observing the target node for configured mutations.
  109. observer.observe(document, config);
  110. }
  111.  
  112. console_log("==> Tellows_it_HideAnnoyingPopup: Script loaded");
  113. })();