Facebook Activity Auto Deleter (2025)

Automatically deletes Facebook activity log entries, confirms popups, and scrolls. Now with error handling and a GUI toggle. Clean your timeline fast!

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

// ==UserScript==
// @name         Facebook Activity Auto Deleter (2025)
// @namespace    https://gf.qytechs.cn/en/users/1454546-shawnfrost13
// @version      3.91
// @description  Automatically deletes Facebook activity log entries, confirms popups, and scrolls. Now with error handling and a GUI toggle. Clean your timeline fast!
// @author       shawnfrost13
// @license      MIT
// @match        https://www.facebook.com/*/allactivity*
// @grant        none
// @run-at       document-end
// @note         Keep the tab active and non-discarded. Reload if it glitches. Toggle on/off via GUI.
// ==/UserScript==

(function () {
    'use strict';

    console.log("🔥 FB Auto Deleter 2025 v3.9 started");

    let deletionCount = 0;
    let isRunning = true;
    const attemptedSet = new WeakSet();

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

    // GUI Toggle
    function addToggleGUI() {
        const toggle = document.createElement('button');
        toggle.textContent = '⏸ Pause Deleter';
        toggle.id = 'fb-auto-delete-toggle';
        toggle.style.position = 'fixed';
        toggle.style.bottom = '85px';
        toggle.style.right = '10px';
        toggle.style.zIndex = '9999';
        toggle.style.padding = '8px 12px';
        toggle.style.borderRadius = '10px';
        toggle.style.background = '#444';
        toggle.style.color = '#fff';
        toggle.style.border = '1px solid lime';
        toggle.style.cursor = 'pointer';
        toggle.style.fontFamily = 'monospace';

        toggle.addEventListener('click', () => {
            isRunning = !isRunning;
            toggle.textContent = isRunning ? '⏸ Pause Deleter' : '▶️ Resume Deleter';
            logStatus(isRunning ? 'Resumed' : 'Paused');
            if (isRunning) deleteNext();
        });

        document.body.appendChild(toggle);
    }

    function logStatus(text) {
        let el = document.getElementById('fb-auto-delete-status');
        if (!el) {
            el = document.createElement('div');
            el.id = 'fb-auto-delete-status';
            el.style.position = 'fixed';
            el.style.bottom = '50px';
            el.style.right = '10px';
            el.style.background = '#111';
            el.style.color = 'lime';
            el.style.padding = '10px';
            el.style.borderRadius = '10px';
            el.style.fontFamily = 'monospace';
            el.style.zIndex = '9999';
            document.body.appendChild(el);
        }
        el.textContent = `🧹 ${text}`;
    }

    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")) &&
                !attemptedSet.has(btn)
            );
        });
    }

    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 &&
                ["delete", "remove", "confirm"].includes(btn.innerText.trim().toLowerCase())
            );
            if (deleteBtn) {
                console.log("✅ Auto-confirming DELETE dialog");
                deleteBtn.click();
                logStatus("Auto-confirmed delete popup");
            }
        });

        // Handle "Something went wrong" popup
        const errorPopup = Array.from(document.querySelectorAll('[role="dialog"]')).find(d => d.textContent.includes("Something went wrong"));
        if (errorPopup) {
            const closeBtn = errorPopup.querySelector('[aria-label="Close"]');
            if (closeBtn) {
                closeBtn.click();
                logStatus("⚠️ Closed error popup");
            }
        }
    }

    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 (!isRunning) return;

        autoConfirmPopups();

        const buttons = findMenuButtons();

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

        const btn = buttons[0];
        attemptedSet.add(btn);

        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(() => {
        addToggleGUI();
        deleteNext();
        setInterval(autoConfirmPopups, 1000);
    }, 3000);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址