Greasy Fork

Greasy Fork is available in English.

Facebook Activity Auto Deleter (2025)

Automatically deletes Facebook activity log entries, confirms popups, scrolls, skips failed entries, and features a GUI toggle. Clean your profile easily.

当前为 2025-04-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Facebook Activity Auto Deleter (2025)
// @namespace    http://greasyfork.icu/en/users/1454546-shawnfrost13
// @version      3.9
// @description  Automatically deletes Facebook activity log entries, confirms popups, scrolls, skips failed entries, and features a GUI toggle. Clean your profile easily.
// @author       shawnfrost13
// @license      MIT
// @match        https://www.facebook.com/*/allactivity*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function () {
    'use strict';

    let isPaused = false;
    let deletionCount = 0;

    const statusBox = document.createElement('div');
    statusBox.id = 'fb-auto-delete-status';
    statusBox.style.position = 'fixed';
    statusBox.style.bottom = '10px';
    statusBox.style.right = '10px';
    statusBox.style.background = '#111';
    statusBox.style.color = 'lime';
    statusBox.style.padding = '10px';
    statusBox.style.borderRadius = '10px';
    statusBox.style.fontFamily = 'monospace';
    statusBox.style.zIndex = '9999';
    statusBox.textContent = '🧹 Script starting...';
    document.body.appendChild(statusBox);

    const toggleButton = document.createElement('button');
    toggleButton.textContent = '⏸ Pause Deleter';
    toggleButton.style.position = 'fixed';
    toggleButton.style.bottom = '65px';
    toggleButton.style.right = '10px';
    toggleButton.style.padding = '10px';
    toggleButton.style.borderRadius = '10px';
    toggleButton.style.border = 'none';
    toggleButton.style.background = '#222';
    toggleButton.style.color = 'white';
    toggleButton.style.fontFamily = 'monospace';
    toggleButton.style.cursor = 'pointer';
    toggleButton.style.zIndex = '9999';
    document.body.appendChild(toggleButton);

    toggleButton.addEventListener('click', () => {
        isPaused = !isPaused;
        toggleButton.textContent = isPaused ? '▶️ Resume Deleter' : '⏸ Pause Deleter';
        logStatus(isPaused ? '🧹 Script paused' : '🧹 Script resumed');
        if (!isPaused) deleteNext();
    });

    function logStatus(text) {
        if (statusBox) statusBox.textContent = text;
    }

    function getRandomDelay(min = 1100, max = 2100) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    function findMenuButtons() {
        return Array.from(document.querySelectorAll('[role="button"]')).filter(btn => {
            const label = btn.getAttribute('aria-label') || '';
            return (
                btn.offsetParent !== null &&
                (label.toLowerCase().includes("activity options") ||
                    label.toLowerCase().includes("action options"))
            );
        });
    }

    function autoConfirmPopups() {
        const dialogs = Array.from(document.querySelectorAll('[role="dialog"], [role="alertdialog"]'));
        dialogs.forEach(dialog => {
            const deleteBtn = Array.from(dialog.querySelectorAll('div[role="button"], button'))
                .find(btn =>
                    btn.offsetParent !== null &&
                    btn.innerText.trim().toLowerCase() === "delete"
                );
            if (deleteBtn) {
                console.log("✅ Auto-confirming DELETE dialog");
                deleteBtn.click();
                logStatus("Auto-confirmed delete popup");
            }
        });
    }

    function closeErrorDialogs() {
        const errorPopups = Array.from(document.querySelectorAll('[role="dialog"]'));
        errorPopups.forEach(dialog => {
            if (dialog.innerText.includes("Something went wrong")) {
                const closeBtn = Array.from(dialog.querySelectorAll('div[role="button"], button'))
                    .find(btn => btn.innerText.toLowerCase().includes("close") || btn.innerText.toLowerCase().includes("okay"));
                if (closeBtn) {
                    closeBtn.click();
                    console.log("⚠️ Closed 'Something went wrong' popup. Skipping this item.");
                    logStatus("⚠️ Skipped problematic item due to error");
                }
            }
        });
    }

    function autoScrollAndRetry() {
        console.log("🔄 Scrolling to load more activity...");
        logStatus("Scrolling to load more items...");

        window.scrollTo({
            top: document.body.scrollHeight,
            behavior: 'smooth'
        });

        setTimeout(() => {
            deleteNext();
        }, 2500);
    }

    function deleteNext() {
        if (isPaused) {
            logStatus("🧹 Script paused");
            return;
        }

        autoConfirmPopups();
        closeErrorDialogs();

        const buttons = findMenuButtons();

        if (buttons.length === 0) {
            logStatus('No deletable buttons found. Trying to scroll...');
            autoScrollAndRetry();
            return;
        }

        const btn = buttons[0];
        btn.scrollIntoView({ behavior: 'smooth', block: 'center' });
        btn.click();
        logStatus(`Opened menu for item #${deletionCount + 1}`);
        console.log(`📂 Opened menu for item #${deletionCount + 1}`);

        setTimeout(() => {
            const menuItems = Array.from(document.querySelectorAll('[role="menuitem"]'));
            const deleteOption = menuItems.find(el =>
                el.innerText.includes("Move to Recycle bin") ||
                el.innerText.includes("Delete") ||
                el.innerText.includes("Remove") ||
                el.innerText.includes("Unlike") ||
                el.innerText.includes("Remove reaction") ||
                el.innerText.includes("Remove tag")
            );

            if (deleteOption) {
                deleteOption.click();
                deletionCount++;
                logStatus(`🗑️ Deleted item #${deletionCount}`);
                console.log(`🗑️ Deleted item #${deletionCount}`);
                setTimeout(deleteNext, getRandomDelay());
            } else {
                logStatus(`⚠️ No delete option. Skipping...`);
                console.log("⚠️ No delete/remove option found. Skipping...");
                setTimeout(deleteNext, getRandomDelay());
            }
        }, 1500);
    }

    setTimeout(() => {
        deleteNext();
        setInterval(() => {
            if (!isPaused) {
                autoConfirmPopups();
                closeErrorDialogs();
            }
        }, 1000);
    }, 3000);
})();