Greasy Fork

Greasy Fork is available in English.

Facebook Activity Auto Deleter

Auto delete Facebook activity logs with confirmation and auto scroll support. Skips problematic entries. Stable and smooth.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Facebook Activity Auto Deleter
// @namespace    http://greasyfork.icu/en/users/1454546-shawnfrost13
// @version      3.3
// @description  Auto delete Facebook activity logs with confirmation and auto scroll support. Skips problematic entries. Stable and smooth.
// @author       shawnfrost13
// @license      MIT
// @match        https://www.facebook.com/*/allactivity*
// @grant        none
// @run-at       document-end
// @tags         facebook, delete, activity, privacy, automation, cleanup
// ==/UserScript==

(function () {
  'use strict';

  const log = (msg) => {
    console.log(`[FB AutoDeleter] ${msg}`);
    const toastId = 'fb-auto-deleter-toast';
    let toast = document.getElementById(toastId);
    if (!toast) {
      toast = document.createElement('div');
      toast.id = toastId;
      toast.style.cssText = `
        position: fixed;
        bottom: 10px;
        right: 10px;
        background: #222;
        color: #0f0;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 13px;
        z-index: 99999;
        font-family: sans-serif;
      `;
      document.body.appendChild(toast);
    }
    toast.textContent = msg;
  };

  const wait = (ms) => new Promise((r) => setTimeout(r, ms));
  const randomWait = () => wait(1100 + Math.random() * 1000);

  async function deleteOneActivity(entry) {
    try {
      // Click the 3-dot action button
      entry.setAttribute('data-fb-processed', 'true');
      entry.click();
      log('Clicked action menu...');
      await wait(600);

      // Find and click the "Delete" option
      const deleteSpan = Array.from(document.querySelectorAll('span')).find(
        (el) => /delete/i.test(el.textContent)
      );

      if (!deleteSpan) {
        log('⚠️ No delete option found, skipping.');
        return;
      }

      deleteSpan.click();
      log('🗑️ Clicked delete...');
      await wait(800);

      // Look for the confirmation dialog
      const confirmBtn = Array.from(document.querySelectorAll('div[role="dialog"] div[role="button"]')).find(
        (btn) => /delete|confirm|yes/i.test(btn.textContent)
      );

      if (confirmBtn) {
        confirmBtn.click();
        log('✅ Confirmed deletion');
      } else {
        log('⚠️ No confirm button, skipping.');
      }

      await randomWait();
    } catch (err) {
      console.error("❌ Error during deletion", err);
      log('❌ Error - skipped');
    }
  }

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

  async function processLoop() {
    log('🚀 Started Facebook Activity Auto Deleter...');
    while (true) {
      const actions = Array.from(document.querySelectorAll('div[aria-label="Action options"]')).filter(
        (el) => !el.getAttribute('data-fb-processed')
      );

      if (actions.length === 0) {
        log('🔁 No new items, scrolling...');
        scrollPage();
        await wait(3000);
        continue;
      }

      for (let i = 0; i < actions.length; i++) {
        await deleteOneActivity(actions[i]);
      }

      await wait(1500);
    }
  }

  setTimeout(processLoop, 2500);
})();