Reddit NSFW Bypass

Watches for reddit NSFW login prompt, then deletes it and reveals contents.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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 NSFW Bypass
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Watches for reddit NSFW login prompt, then deletes it and reveals contents.
// @author       You
// @match        https://www.reddit.com/r/*
// @icon         https://www.reddit.com/favicon.ico
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

	function doRemove(){

        const element = document.getElementById("blocking-modal-contents");
        if (element !== null) {
            element.remove();
            console.log(`[ElementRemover] 'blocking-modal-contents' removed.`);
        }

		document.querySelectorAll("svg[icon-name='nsfw-fill']").forEach(svgImage => {
			let targetParent = svgImage.parentNode.parentNode.parentNode;
			if (targetParent) {
				let imageElement = targetParent.querySelector("img");
				if (imageElement && imageElement.style && imageElement.style.filter.includes("blur")) {
					imageElement.style.filter = imageElement.style.filter.replace(/blur\(\d+px\)/g, '');
					svgImage.parentNode.parentNode.remove();
					console.log(`[ElementRemover] NSFW image revealed.`);
				}
			}
		});

		function revealNsfwContent(container) {
			revealTextContent(container);
			revealThumbnailContent(container);
		}

		function revealThumbnailContent(container) {
			const blurredBody = container.querySelector("div[slot='post-media-container']");
			if (!blurredBody) return;

			const revealedDiv = container.querySelector("div[slot='revealed']");
			if (!revealedDiv) return;
			if (revealedDiv.parentNode == blurredBody) return;

			blurredBody.insertBefore(revealedDiv, blurredBody.firstChild);

			for (let i = blurredBody.children.length - 1; i >= 1; i--) {
				blurredBody.removeChild(blurredBody.children[i]);
			}

			console.log(`[ElementRemover] NSFW thumbnail revealed. ${blurredBody.children.length} children remain.`);
		}

		function revealTextContent(container) {
			const textBody = container.querySelector("shreddit-post-text-body");
			if (!textBody) return;

			const contentZone = textBody.querySelector("div");
			if (!contentZone) return;

			textBody.querySelectorAll("div[slot='revealed']").forEach(div => {
				const contentElement = div.querySelector("div[property='schema:articleBody']");
				if (!contentElement) return;

				contentZone.insertBefore(contentElement, contentZone.firstChild);
				console.log(`[ElementRemover] NSFW content revealed.`);

				while (contentZone.children.length > 1) {
					contentZone.removeChild(contentZone.lastChild);
				}
			});
		}

		document.querySelectorAll("shreddit-post").forEach(article => revealNsfwContent(article));
    }


    const observer = new MutationObserver((_,__) => { doRemove(); });

    doRemove(null);

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

})();