Reddit Delete 🗑️

Automatically deletes every visible post/comment on your userpage

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Reddit Delete 🗑️
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically deletes every visible post/comment on your userpage
// @author       Agreasyforkuser
// @match        https://old.reddit.com/user/*
// @icon         https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @grant        none
// @license      MIT
// ==/UserScript==

function delete_content(){
    'use strict';
    function simulateClick(element) {
        const event = new MouseEvent('click', {
            view: window,
            bubbles: true,
            cancelable: true
        });
        element.dispatchEvent(event);
    }
    const linkObjects = document.querySelectorAll('.link, .comment');
    let currentIndex = 0;
    function deleteNextPost() {
        if (currentIndex < linkObjects.length) {
            const link = linkObjects[currentIndex];
            const deleteLink = link.querySelector('a[data-event-action="delete"]');
            if (deleteLink) {
                simulateClick(deleteLink);
                setTimeout(() => {
                    const yesLink = link.querySelector('a.yes');
                    if (yesLink) {
                        simulateClick(yesLink);
                        setTimeout(deleteNextPost, 300);
                    }
                }, 300);
            } else {
                currentIndex++;
                setTimeout(deleteNextPost, 300);
            }
        }
    }
    deleteNextPost();
}

    // Place a shortcut
    var link = document.createElement('a');
    link.href = 'javascript:void(0);';
    link.textContent = 'delete all content🗑️';
    link.style.color = 'white';
    link.style.backgroundColor = 'red';
    link.style.padding = '5px';
    link.style.fontWeight = 'bold';
    link.style.borderRadius = '20px';
    link.style.display = 'inline-table';
    link.addEventListener('click', function(event) {
        event.preventDefault();
        if (window.confirm('Are you sure you want to delete all visible submissions and comments?')) {
            delete_content();}
    });
    document.querySelector('.menuarea').appendChild(link);