Greasy Fork is available in English.
Automatically deletes Facebook activity log entries, confirms popups, skips failed entries, and auto-scrolls. Starts paused with toggle GUI.
当前为
// ==UserScript==
// @name Facebook Activity Auto Deleter (2025)
// @namespace http://greasyfork.icu/en/users/1454546-shawnfrost13
// @version 4.03
// @description Automatically deletes Facebook activity log entries, confirms popups, skips failed entries, and auto-scrolls. Starts paused with toggle GUI.
// @author shawnfrost13
// @license MIT
// @match https://www.facebook.com/*/allactivity*
// @grant none
// @run-at document-end
// @note Keep the tab active and non-discarded. Will skip stuck entries after 2 failed attempts and won't retry them again.
// ==/UserScript==
(function () {
'use strict';
let deletionCount = 0;
let failedEntries = new WeakMap();
let skipNext = false;
let isPaused = true;
function getRandomDelay(min = 1100, max = 2100) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
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 = '10px';
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 createToggleButton() {
let btn = document.createElement('button');
btn.id = 'fb-auto-toggle';
btn.textContent = '▶️ Start Auto Delete';
btn.style.position = 'fixed';
btn.style.bottom = '60px';
btn.style.right = '10px';
btn.style.zIndex = '10000';
btn.style.padding = '8px 12px';
btn.style.background = '#333';
btn.style.color = 'white';
btn.style.border = '1px solid lime';
btn.style.borderRadius = '8px';
btn.style.cursor = 'pointer';
btn.style.fontFamily = 'monospace';
btn.onclick = () => {
isPaused = !isPaused;
btn.textContent = isPaused ? '▶️ Start Auto Delete' : '⏸️ Pause Auto Delete';
if (!isPaused) {
deleteNext();
}
};
document.body.appendChild(btn);
}
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");
}
const errorPopup = Array.from(dialog.querySelectorAll('*')).find(el =>
el.textContent.includes("Something went wrong")
);
if (errorPopup) {
console.log("⚠️ Detected failure popup");
const closeBtn = dialog.querySelector('[aria-label="Close"], [aria-label="Dismiss"]');
if (closeBtn) closeBtn.click();
}
});
}
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("⏸️ Paused");
return;
}
autoConfirmPopups();
const buttons = findMenuButtons().filter(btn => !failedEntries.has(btn));
if (buttons.length === 0) {
logStatus('No deletable actions found. Scrolling...');
autoScrollAndRetry();
return;
}
let btn = buttons[0];
if (skipNext) {
console.log("⏭️ Skipping next item after failure.");
failedEntries.set(btn, true);
skipNext = false;
setTimeout(deleteNext, getRandomDelay());
return;
}
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 {
console.log("❌ No delete option found. Retrying...");
let failCount = failedEntries.get(btn) || 0;
failCount++;
failedEntries.set(btn, failCount);
if (failCount >= 2) {
console.warn("⚠️ Skipping next entry after 2 failures.");
skipNext = true;
}
logStatus(`⚠️ Failed to delete item. Attempt ${failCount}`);
setTimeout(deleteNext, getRandomDelay());
}
}, 1500);
}
// Init
setTimeout(() => {
createToggleButton();
logStatus("⏸️ Script loaded and paused");
setInterval(autoConfirmPopups, 1000);
}, 3000);
})();