☰

Hide Reddit app banner

aaaaaaa

Hindi dapat direktang i-install ang script na ito. Ito ay isang library para sa iba pang mga script na isasama sa meta directive. // @require https://update.sleazyfork.org/scripts/606603/2005932/Hide%20Reddit%20app%20banner.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Hide Reddit app banner
// @match        https://*.reddit.com/*
// @run-at       document-idle
// @grant        none
// ==/UserScript==
(function () {
  const TEXT = 'Get the Reddit app';
  function fixedAncestor(el) {
    let n = el, found = null;
    while (n && n !== document.documentElement) {
      const p = getComputedStyle(n).position;
      if (p === 'fixed' || p === 'sticky') found = n;
      const root = n.getRootNode();
      n = n.parentElement || (root instanceof ShadowRoot ? root.host : null);
    }
    return found;
  }
  function sweep(root) {
    root.querySelectorAll('*').forEach(el => {
      if (el.shadowRoot) sweep(el.shadowRoot);
      const t = el.textContent || '';
      if (t.includes(TEXT) && t.length < 200) {
        const a = fixedAncestor(el);
        if (a && a.getBoundingClientRect().height < 200)
          a.style.setProperty('display', 'none', 'important');
      }
    });
  }
  let timer;
  const run = () => { clearTimeout(timer); timer = setTimeout(() => sweep(document), 300); };
  new MutationObserver(run).observe(document.documentElement, { childList: true, subtree: true });
  sweep(document);
})();