Reddit Cleaner

Auto version of working bookmarklet (no reload needed)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Reddit Cleaner
// @namespace    https://greasyfork.org/users/aakash-yadav
// @version      2.0
// @description  Auto version of working bookmarklet (no reload needed)
// @author       graphite
// @match        https://www.reddit.com/*
// @run-at       document-end
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    function unblock() {
        try {
            // Reset body lock
            document.body.style = "";

            // Remove blur layer
            document.querySelector("div[style*='blur(4px)']")?.remove();

            // Remove main modal
            document.getElementById("blocking-modal")?.remove();

            // Remove shadow popup
            try {
                const x = document.getElementsByTagName("xpromo-nsfw-blocking-container")[0];
                if (x && x.shadowRoot && x.shadowRoot.children[1]) {
                    x.shadowRoot.children[1].remove();
                }
            } catch(e) {}

            // Remove other popups
            document.getElementsByTagName("xpromo-untagged-content-blocking-modal")[0]?.remove();
            document.querySelector("shreddit-exit-app-modal")?.remove();

        } catch(e) {}
    }

    // Run immediately on load
    unblock();

    // Keep running for dynamic content
    setInterval(unblock, 800);

    // Re-run on Reddit SPA navigation (page changes without reload)
    if (window.navigation) {
        window.navigation.addEventListener("navigate", () => {
            unblock();
            setTimeout(unblock, 500);
            setTimeout(unblock, 1500);
            setTimeout(unblock, 3000);
        });
    }

})();