From: PHO Date: Mon, 8 Feb 2021 10:32:32 +0000 (+0900) Subject: Remove the ad at the footer; also observe DOM changes X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=a6e95f2071e2c2e880655b32e4c3c85141d1329a;p=imenu-relinker.git Remove the ad at the footer; also observe DOM changes --- diff --git a/imenu-relinker.user.js b/imenu-relinker.user.js index 79c8fe0..3711d16 100644 --- a/imenu-relinker.user.js +++ b/imenu-relinker.user.js @@ -3,7 +3,7 @@ // @namespace http://cielonegro.org/ // @description Fix links on 5ch.net BBS. // @author PHO -// @version 1.0 +// @version 1.0.1 // @license CC0 // @run-at document-idle // @include https://*.5ch.net/* @@ -21,5 +21,26 @@ } } + function remove_ad_footer() { + // Starting from 2021-02-08, 5ch.net shows an iframe ad + // contained in several nested div elements. Dunno which + // script is doing it. + var iframes = document.querySelectorAll("iframe"); + for (var iframe of iframes.values()) { + if ((iframe.getAttribute("src") || "").startsWith("//stab.thench.net/")) { + // Found an iframe to be removed. + if (iframe.parentNode && iframe.parentNode.parentNode) { + iframe.parentNode.parentNode.remove(); + } + } + } + } + + // Pop-up windows shown when hovered on >>n links are dynamically + // inserted to the DOM. Relink anchors in them as well. + let observer = new MutationObserver(relink_all); + observer.observe(document.querySelector("body"), {subtree: true, childList: true}); + relink_all(); + remove_ad_footer(); })();