kongregate_hide_anti-adblock_banner.js
| 1 | // ==UserScript== |
| 2 | // @name Kongregate Hide Anti-Adblock Notice |
| 3 | // @version 1.0 |
| 4 | // @description Hides the "ad or script blocking software is interfering" banner on Kongregate. |
| 5 | // @match *://*.kongregate.com/* |
| 6 | // @run-at document-start |
| 7 | // @grant none |
| 8 | // ==/UserScript== |
| 9 | |
| 10 | (function () { |
| 11 | 'use strict'; |
| 12 | |
| 13 | // The only stable marker is the text. Class names and the z-index are randomized. |
| 14 | const TEXT_NEEDLE = 'ad or script blocking software is interfering'; |
| 15 | |
| 16 | // Find the notice by its text, climb to the fixed-position bar, and remove it. |
| 17 | function sweep(root) { |
| 18 | const scope = (root && root.querySelectorAll) ? root : document; |
| 19 | scope.querySelectorAll('div').forEach(function (el) { |
| 20 | if (el.textContent && el.textContent.indexOf(TEXT_NEEDLE) !== -1) { |
| 21 | const bar = el.closest('div[style*="position: fixed"]') || el; |
| 22 | bar.remove(); |
| 23 | } |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | // Catch insertions and re-insertions. |
| 28 | const observer = new MutationObserver(function (mutations) { |
| 29 | for (const m of mutations) { |
| 30 | for (const node of m.addedNodes) { |
| 31 | if (node.nodeType === 1 && (node.textContent || '').indexOf(TEXT_NEEDLE) !== -1) { |
| 32 | sweep(node.parentNode || document); |
| 33 | return; |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | }); |
| 38 | observer.observe(document.documentElement, { childList: true, subtree: true }); |
| 39 | |
| 40 | // Initial pass + safety net on full load. |
| 41 | sweep(document); |
| 42 | window.addEventListener('load', function () { sweep(document); }, { once: true }); |
| 43 | console.log("Anti-Adblock loaded") |
| 44 | })(); |
| 45 |