Last active
January 22, 2026 14:12
-
-
Save ThinaticSystem/256a172d2fbd8a550a4f93c45f1a38d9 to your computer and use it in GitHub Desktop.
html-unload.js (Disable html-load.com)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @ts-check | |
| "use strict"; | |
| const EVIL_DOMAINS = /** @type {const} */ ([ | |
| "error-report.com", | |
| "html-load.com", | |
| "content-loader.com", | |
| ]); | |
| /** | |
| * @param {string} urlString | |
| * @returns {boolean} | |
| */ | |
| const isEvilUrl = (urlString) => { | |
| if (!urlString) return false; | |
| /** @type {URL} */ | |
| let url; try { | |
| url = new URL(urlString, document.baseURI); | |
| } catch { | |
| return false; | |
| } | |
| return EVIL_DOMAINS.some((domain) => url.hostname === domain || url.hostname.endsWith(`.${domain}`)); | |
| } | |
| const originalRemove = Element.prototype.remove; | |
| Element.prototype.remove = function () { | |
| if (!["STYLE", "LINK"].includes(this.tagName)) return originalRemove.call(this); | |
| // NOP | |
| } | |
| /** | |
| * @param {Node} node | |
| * @returns {node is Element} | |
| */ | |
| const isElementNode = (node) => node instanceof Element | |
| /** | |
| * @param {HTMLIFrameElement} element | |
| */ | |
| const removeIfEvilIframe = (element) => { | |
| if (element.src && isEvilUrl(element.src)) { | |
| originalRemove.call(element); | |
| } | |
| }; | |
| document.querySelectorAll("iframe").forEach(removeIfEvilIframe); | |
| const observer = new MutationObserver((mutations) => { | |
| mutations.forEach(({ addedNodes }) => { | |
| addedNodes.forEach((node) => { | |
| if (!isElementNode(node)) return; | |
| if (node instanceof HTMLIFrameElement) { | |
| removeIfEvilIframe(node); | |
| } | |
| if (node.hasChildNodes()) { | |
| const iframes = node.querySelectorAll("iframe"); | |
| iframes.forEach(removeIfEvilIframe); | |
| } | |
| }); | |
| }); | |
| }); | |
| observer.observe(document, { | |
| childList: true, | |
| subtree: true, | |
| }); | |
| window.confirm = () => { throw null }; | |
| navigation.addEventListener("navigate", (event) => { | |
| if (isEvilUrl(event.destination.url)) { | |
| event.preventDefault(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment