Reddit Mobile App Nag Remover

5/25/2023, 5:35 PK

目前为 2023-05-25 提交的版本。查看 最新版本

// ==UserScript==
// @name        Reddit Mobile App Nag Remover
// @namespace   Violentmonkey Scripts
// @match       https://*reddit.com/*
// @grant       none
// @version     1.1
// @author      Jupiter Liar
// @description 5/25/2023, 5:35 PK
// @license     Attribution CC BY
// ==/UserScript==

// Function to remove the nag popup element or XPromoPopupRpl element
function removeNagPopup() {
  const nagPopup = document.querySelector('shreddit-experience-tree, .XPromoPopupRpl');

  if (nagPopup) {
    nagPopup.style.display = 'none';
    document.body.style.overflow = 'unset';
    document.body.style.position = 'unset';
  }
}

// Create a MutationObserver instance for nagPopup
const popupObserver = new MutationObserver(function(mutationsList) {
  for (let mutation of mutationsList) {
    if (mutation.type === 'childList') {
      removeNagPopup();
      break;
    }
  }
});

// Start observing the body for changes related to nagPopup
popupObserver.observe(document.body, { childList: true, subtree: true });

// Function to remove the nag bottom element or XPromoBottomBar element
function removeNagBottom() {
  const navFrame = document.querySelector('.NavFrame');
  
  if (navFrame) {
    const nagBottoms = navFrame.querySelectorAll('shreddit-async-loader, .XPromoBottomBar');

    nagBottoms.forEach(nagBottom => {
      nagBottom.style.display = 'none';
    });

    document.body.style.overflow = 'unset';
    document.body.style.position = 'unset';
  }
}

// Create a MutationObserver instance for nagBottom
const bottomObserver = new MutationObserver(function(mutationsList) {
  for (let mutation of mutationsList) {
    if (mutation.type === 'childList') {
      removeNagBottom();
      break;
    }
  }
});

// Start observing the body for changes related to nagBottom
bottomObserver.observe(document.body, { childList: true, subtree: true });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址