Reddit Bypass Enhancer

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

2025-03-18 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

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 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         Reddit Bypass Enhancer
// @version      2.3
// @description  Bypass "open in app" prompts, unblur NSFW content & thumbnails, remove spoiler overlays.
// @author       UniverseDev
// @license      GPL-3.0-or-later
// @match        https://www.reddit.com/*
// @match        https://sh.reddit.com/*
// @grant        none
// @run-at       document-start
// @noframes
// @namespace    https://greasyfork.org/en/users/1030895-universedev
// ==/UserScript==

'use strict';

(function () {
    function queryElementsDeep(selector) {
        const elements = new Set();
        try {
            document.querySelectorAll(selector).forEach(el => elements.add(el));
            document.querySelectorAll('*').forEach(el => {
                if (el.shadowRoot) {
                    el.shadowRoot.querySelectorAll(selector).forEach(shadowEl => elements.add(shadowEl));
                }
            });
        } catch (error) {
            console.error("Error in queryElementsDeep:", error);
        }
        return [...elements];
    }

    const SELECTORS = {
        nsfwModal: 'shreddit-async-loader[bundlename*="nsfw_blocking_modal"]',
        promptContainer: 'xpromo-nsfw-blocking-container > *',
        prompt: '.prompt',
        blurredContainer: 'shreddit-blurred-container',
        thumbnailBlur: '.thumbnail-blur',
        communityHighlightCard: 'community-highlight-card',
        thumbnailImage: 'img.mb-0.h-full.w-full.object-cover',
        thumbnailShadow: '.thumbnail-shadow',
        mediaBackground: '.bg-media-background',
        blurredSpan: 'span.inner.blurred',
        scrim: '.absolute.top-0.left-0.w-full.h-full.bg-scrim',
        imageFilter: 'img.mb-0.h-full.w-full.object-cover',
        video: 'shreddit-player, video',
        mediaTelemetryObserver: 'media-telemetry-observer',
        spoilerOverlay: '.absolute.inset-0.overflow-visible.flex.items-center.justify-center'
    };

    function removeNSFWBlock() {
        try {
            document.querySelector(SELECTORS.nsfwModal)?.remove();
            document.querySelector(SELECTORS.promptContainer)?.shadowRoot?.querySelector(SELECTORS.prompt)?.remove();

            document.getElementById("nsfw-qr-dialog")?.remove();
            document.querySelector("body > div:nth-child(7)")?.remove();

            document.querySelectorAll('body > *').forEach(el => {
                if (el.style.backdropFilter) el.style.backdropFilter = 'none';
            });

            document.querySelectorAll(SELECTORS.blurredContainer).forEach(container => {
                try {
                    if (container.shadowRoot?.innerHTML && container.firstElementChild) {
                        container.firstElementChild.addEventListener('click', e => {
                            e.preventDefault();
                            if (e.target.closest(SELECTORS.mediaTelemetryObserver)) {
                                e.stopPropagation();
                            }
                            container.classList.add('clicked-container');
                            e.target.click();
                        }, { once: true });

                        container.firstElementChild.click();
                    }
                } catch (error) {
                    console.error("Error processing blurred container:", error, container);
                }
            });

            document.querySelectorAll(SELECTORS.thumbnailBlur).forEach(el => el.classList.remove('thumbnail-blur'));
            document.querySelectorAll(SELECTORS.communityHighlightCard).forEach(card => card.removeAttribute('blurred'));
            document.querySelectorAll(SELECTORS.imageFilter).forEach(img => img.style.removeProperty('filter'));
            document.querySelectorAll(SELECTORS.video).forEach(video => video.classList.remove('blur'));
            document.querySelector(SELECTORS.thumbnailShadow)?.remove();
            document.querySelector(SELECTORS.mediaBackground)?.style.setProperty('background-color', 'transparent');

            queryElementsDeep(SELECTORS.blurredSpan).forEach(span => span.style.removeProperty('filter'));
            queryElementsDeep(SELECTORS.scrim).forEach(scrim => scrim.remove());
            queryElementsDeep(SELECTORS.spoilerOverlay).forEach(spoiler => spoiler.remove());
        } catch (error) {
            console.error("Error in removeNSFWBlock:", error);
        }
    }

    const observer = new MutationObserver(mutations => {
        for (const mutation of mutations) {
            if (mutation.addedNodes.length) {
                removeNSFWBlock();
                break;
            }
        }
    });

    observer.observe(document.documentElement, { childList: true, subtree: true });

    const shredditCheckInterval = setInterval(() => {
        if (!document.querySelector('shreddit-app')) {
            observer.disconnect();
            clearInterval(shredditCheckInterval);
        }
    }, 5000);
})();