Greasy Fork 还支持 简体中文。

Reddit Bypass Enhancer

Bypass "open in app" prompts, unblur NSFW content & thumbnails, remove spoiler overlays.

目前為 2025-03-19 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Reddit Bypass Enhancer
  3. // @version 2.5
  4. // @description Bypass "open in app" prompts, unblur NSFW content & thumbnails, remove spoiler overlays.
  5. // @author UniverseDev
  6. // @license GPL-3.0-or-later
  7. // @match https://www.reddit.com/*
  8. // @match https://sh.reddit.com/*
  9. // @grant none
  10. // @run-at document-start
  11. // @noframes
  12. // @namespace https://greasyfork.org/en/users/1030895-universedev
  13. // ==/UserScript==
  14.  
  15. 'use strict';
  16.  
  17. (function () {
  18. const SELECTORS = {
  19. nsfwModal: 'shreddit-async-loader[bundlename*="nsfw_blocking_modal"]',
  20. promptContainer: 'xpromo-nsfw-blocking-container',
  21. prompt: '.prompt',
  22. blurredContainer: 'shreddit-blurred-container',
  23. thumbnailBlur: '.thumbnail-blur',
  24. communityHighlightCard: 'community-highlight-card[blurred]',
  25. imageFilter: 'img.mb-0.h-full.w-full.object-cover[style*="filter"]',
  26. video: 'shreddit-player, video.blur',
  27. blurredSpan: 'span.inner.blurred',
  28. scrim: '.absolute.top-0.left-0.w-full.h-full.bg-scrim',
  29. spoilerOverlay: '.absolute.inset-0.overflow-visible.flex.items-center.justify-center'
  30. };
  31.  
  32. function queryElementsDeep(selector, root = document) {
  33. const elements = new Set();
  34. try {
  35. root.querySelectorAll(selector).forEach(el => elements.add(el));
  36. root.querySelectorAll('*').forEach(el => {
  37. if (el.shadowRoot) {
  38. el.shadowRoot.querySelectorAll(selector).forEach(shadowEl => elements.add(shadowEl));
  39. }
  40. });
  41. } catch (error) {
  42. console.error("Error in queryElementsDeep:", error);
  43. }
  44. return [...elements];
  45. }
  46.  
  47. function removeNSFWBlock() {
  48. try {
  49. document.querySelector(SELECTORS.nsfwModal)?.remove();
  50. document.getElementById("nsfw-qr-dialog")?.remove();
  51. document.querySelector("body > div:nth-child(7)")?.remove();
  52.  
  53. const promptContainer = document.querySelector(SELECTORS.promptContainer);
  54. promptContainer?.shadowRoot?.querySelector(SELECTORS.prompt)?.remove();
  55.  
  56. queryElementsDeep(SELECTORS.blurredContainer).forEach(container => {
  57. const firstChild = container.firstElementChild;
  58. if (firstChild) {
  59. firstChild.addEventListener('click', e => {
  60. e.preventDefault();
  61. if (e.target.closest('media-telemetry-observer')) {
  62. e.stopPropagation();
  63. }
  64. e.target.click();
  65. }, { once: true });
  66. firstChild.click();
  67. }
  68. });
  69.  
  70. queryElementsDeep(SELECTORS.thumbnailBlur).forEach(el => el.classList.remove('thumbnail-blur'));
  71. queryElementsDeep(SELECTORS.communityHighlightCard).forEach(card => card.removeAttribute('blurred'));
  72. queryElementsDeep(SELECTORS.imageFilter).forEach(img => img.style.removeProperty('filter'));
  73. queryElementsDeep(SELECTORS.video).forEach(video => video.classList.remove('blur'));
  74. queryElementsDeep(SELECTORS.blurredSpan).forEach(span => span.style.removeProperty('filter'));
  75. queryElementsDeep(SELECTORS.scrim).forEach(scrim => scrim.remove());
  76. queryElementsDeep(SELECTORS.spoilerOverlay).forEach(spoiler => spoiler.remove());
  77.  
  78. } catch (error) {
  79. console.error("Error in removeNSFWBlock:", error);
  80. }
  81. }
  82.  
  83. const observer = new MutationObserver(mutations => {
  84. let shouldRun = false;
  85. for (const mutation of mutations) {
  86. if (mutation.addedNodes.length) {
  87. shouldRun = true;
  88. break;
  89. }
  90. }
  91. if (shouldRun) removeNSFWBlock();
  92. });
  93.  
  94. observer.observe(document.documentElement, { childList: true, subtree: true });
  95.  
  96. const shredditCheckInterval = setInterval(() => {
  97. if (!document.querySelector('shreddit-app')) {
  98. observer.disconnect();
  99. clearInterval(shredditCheckInterval);
  100. }
  101. }, 5000);
  102. })();