Reddit Bypass Enhancer

Bypass the "open in app prompt" and unblur NSFW content on Reddit automatically.

当前为 2024-12-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Reddit Bypass Enhancer
  3. // @namespace https://greasyfork.org/en/users/1030895-universedev
  4. // @version 1.2
  5. // @description Bypass the "open in app prompt" and unblur NSFW content on Reddit automatically.
  6. // @author UniverseDev
  7. // @license GPL-3.0-or-later
  8. // @match https://www.reddit.com/*
  9. // @match https://sh.reddit.com/*
  10. // @grant none
  11. // @run-at document-end
  12. // @noframes
  13. // ==/UserScript==
  14. 'use strict';
  15.  
  16. (function () {
  17. const NSFW_MODAL_TAG = 'shreddit-async-loader';
  18. const NSFW_MODAL_ATTR = 'bundlename';
  19. const BLURRED_TAG = 'shreddit-blurred-container';
  20. const PROMPT_SELECTOR = 'xpromo-nsfw-blocking-container';
  21.  
  22. function removeNSFWBlock() {
  23. const nsfwModal = document.querySelector(`${NSFW_MODAL_TAG}[${NSFW_MODAL_ATTR}*="nsfw_blocking_modal"]`);
  24. if (nsfwModal) nsfwModal.remove();
  25.  
  26. const prompt = document.querySelector(`${PROMPT_SELECTOR} > *`)?.shadowRoot?.querySelector('.prompt');
  27. if (prompt) prompt.remove();
  28.  
  29. const blurredContainers = document.querySelectorAll(BLURRED_TAG);
  30. blurredContainers.forEach(container => {
  31. if (container.shadowRoot?.innerHTML) {
  32. container.firstElementChild.click();
  33. }
  34. });
  35. }
  36.  
  37. const observer = new MutationObserver(() => {
  38. removeNSFWBlock();
  39. });
  40.  
  41. observer.observe(document, {
  42. childList: true,
  43. subtree: true,
  44. attributes: false,
  45. });
  46.  
  47. removeNSFWBlock();
  48.  
  49. const shredditCheckInterval = setInterval(() => {
  50. if (!document.querySelector('shreddit-app')) {
  51. observer.disconnect();
  52. clearInterval(shredditCheckInterval);
  53. }
  54. }, 5000);
  55. })();