Greasy Fork

Greasy Fork is available in English.

Facebook Activity Auto Deleter + Auto Confirm + Auto Scroll

Automatically deletes Facebook activity log entries, confirms popups, and scrolls to load more. Perfect for cleanup or blanking your profile.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Facebook Activity Auto Deleter + Auto Confirm + Auto Scroll
// @namespace    http://greasyfork.icu/en/users/1454546-shawnfrost13
// @version      3.2
// @description  Automatically deletes Facebook activity log entries, confirms popups, and scrolls to load more. Perfect for cleanup or blanking your profile.
// @author       shawnfrost13
// @license      MIT
// @match        https://www.facebook.com/*/allactivity*
// @grant        none
// @run-at       document-end
// @tags         facebook, delete, cleanup, automation, privacy, scroll
// ==/UserScript==

(function () {
  'use strict';

  const randomDelay = () => 1000 + Math.random() * 1000;

  const clickDeleteButtons = async () => {
    const items = Array.from(document.querySelectorAll('div[aria-label="Action options"]'))
      .filter(el => !el.getAttribute('data-fb-auto-deleted'));

    if (items.length === 0) {
      console.log("✅ No more deletable items found.");
      return false;
    }

    for (const item of items) {
      try {
        // Click 3-dot action menu
        item.click();
        await new Promise(r => setTimeout(r, 500 + Math.random() * 500));

        // Look for the delete option in the dropdown
        const deleteOption = Array.from(document.querySelectorAll('span'))
          .find(span => /delete/i.test(span.textContent));

        if (deleteOption) {
          deleteOption.click();
          console.log("🗑️ Clicked delete option.");
        } else {
          console.log("⚠️ Delete option not found. Skipping.");
          item.setAttribute("data-fb-auto-deleted", "no-delete");
          continue;
        }

        await new Promise(r => setTimeout(r, 700));

        // Handle confirmation dialog (if any)
        const confirmButton = Array.from(document.querySelectorAll('div[role="dialog"] div[role="button"]'))
          .find(btn => /delete|confirm|yes/i.test(btn.textContent));

        if (confirmButton) {
          confirmButton.click();
          console.log("✅ Confirmed deletion.");
        }

        // Check for error toast
        await new Promise(r => setTimeout(r, 500));
        const errorToast = document.querySelector('[role="alert"]:not([data-fb-auto-deleted])');
        if (errorToast && errorToast.textContent.includes("Something went wrong")) {
          console.warn("❌ Facebook error detected. Skipping item.");
          item.setAttribute("data-fb-auto-deleted", "failed");
          const closeBtn = errorToast.querySelector('div[aria-label="Close"]');
          if (closeBtn) closeBtn.click();
          continue;
        }

        // Mark as deleted
        item.setAttribute("data-fb-auto-deleted", "true");
        console.log("✅ Marked item as deleted.");

        // Random wait
        await new Promise(r => setTimeout(r, randomDelay()));
      } catch (err) {
        console.error("⚠️ Error while deleting:", err);
      }
    }

    return true;
  };

  const autoScroll = () => {
    window.scrollTo(0, document.body.scrollHeight);
  };

  const startLoop = async () => {
    console.log("🚀 Facebook Auto Deleter running...");
    while (true) {
      const didDelete = await clickDeleteButtons();
      autoScroll();
      await new Promise(r => setTimeout(r, 2000 + Math.random() * 2000));
      if (!didDelete) break;
    }
    console.log("🏁 Script completed.");
  };

  // Start script after slight delay
  setTimeout(startLoop, 3000);
})();