Facebook Activity Cleaner
A Chrome console script that automatically deletes your Facebook activity logs. Works with Group activity, Comments, Posts, and any activity that has the three-dot menu with a "Delete Your Activity" option. This script runs directly in your browser's developer console and automates the cleanup process.
Critical Warning
This script performs irreversible actions. Once you delete an activity item, it cannot be recovered. The script will automatically delete ALL items from your activity history that match the three-dot menu pattern. Use with extreme caution and only on accounts you own.
(async function() {
const CONFIG = {
INTERVAL_BETWEEN_DELETES: 100,
MENU_WAIT_TIME: 100,
CONFIRM_WAIT_TIME: 100,
SCROLL_AMOUNT: 500,
SCROLL_WAIT_TIME: 200,
MAX_EMPTY_SCROLLS: 5,
PROCESS_BATCH_SIZE: 1
};
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
console.log('š Starting Facebook Activity Log Cleaner...');
console.log('ā ļø Warning: This will permanently delete your activity. No undo!');
let deletedCount = 0;
let emptyScrollCount = 0;
let shouldStop = false;
window.stopScript = function() {
shouldStop = true;
console.log('ā¹ļø Script stop requested...');
};
function findThreeDotButtons() {
const selectors = [
'div[aria-label="Actions for this activity"]',
'div[aria-label="More options"]',
'div[role="button"][tabindex="0"][aria-haspopup="menu"]',
'div[aria-haspopup="menu"]',
'i[data-visualcompletion="css-img"]',
'div[role="button"]:has(svg)',
'div[role="button"][tabindex="0"]:has(> i[data-visualcompletion="css-img"])'
];
let buttons = [];
for (const selector of selectors) {
try {
const elements = document.querySelectorAll(selector);
elements.forEach(el => {
if (el.offsetParent !== null &&
el.getBoundingClientRect().width > 0 &&
el.getBoundingClientRect().height > 0) {
buttons.push(el);
}
});
} catch (e) {}
}
const uniqueButtons = [];
const seen = new Set();
for (const btn of buttons) {
if (!seen.has(btn) && btn.isConnected) {
seen.add(btn);
uniqueButtons.push(btn);
}
}
return uniqueButtons;
}
async function clickDeleteOption() {
const menuItems = document.querySelectorAll('div[role="menuitem"]');
for (const item of menuItems) {
const spans = item.querySelectorAll('span');
for (const span of spans) {
const text = span.textContent.trim();
if ((text === 'Delete Your Activity' || text === 'Delete') &&
item.offsetParent !== null) {
item.scrollIntoView({ behavior: 'smooth', block: 'center' });
await sleep(200);
item.click();
return true;
}
}
}
const allElements = document.querySelectorAll('*');
for (const el of allElements) {
const text = el.textContent.trim();
if ((text === 'Delete Your Activity' || text === 'Delete') &&
el.offsetParent !== null &&
el.getBoundingClientRect().width > 0) {
let clickableEl = el;
while (clickableEl && !clickableEl.getAttribute('role')) {
clickableEl = clickableEl.parentElement;
}
if (clickableEl && clickableEl.getAttribute('role') === 'menuitem') {
clickableEl.click();
return true;
}
}
}
return false;
}
async function clickConfirmButton() {
await sleep(800);
const allButtons = document.querySelectorAll('button, div[role="button"]');
for (const btn of allButtons) {
if (!btn.offsetParent) continue;
const btnText = btn.textContent.trim().toLowerCase();
if ((btnText === 'delete' || btnText === 'confirm') && btn.offsetParent !== null) {
const rect = btn.getBoundingClientRect();
if (rect.width > 50 && rect.height > 30) {
btn.click();
return true;
}
}
}
const primaryButtons = document.querySelectorAll('[data-testid="confirmationSheetConfirmButton"]');
for (const btn of primaryButtons) {
if (btn.offsetParent) {
btn.click();
return true;
}
}
document.activeElement?.blur();
await sleep(100);
const enterEvent = new KeyboardEvent('keydown', {
key: 'Enter',
code: 'Enter',
keyCode: 13,
which: 13,
bubbles: true,
cancelable: true
});
document.dispatchEvent(enterEvent);
if (document.activeElement && document.activeElement.getAttribute('role') === 'button') {
document.activeElement.click();
return true;
}
return false;
}
async function processActivityItem(button) {
try {
if (!button.isConnected) {
return false;
}
button.scrollIntoView({ behavior: 'smooth', block: 'center' });
await sleep(500);
button.click();
await sleep(CONFIG.MENU_WAIT_TIME);
const deleteClicked = await clickDeleteOption();
if (!deleteClicked) {
document.body.click();
await sleep(500);
return false;
}
await clickConfirmButton();
deletedCount++;
console.log(`ā
Deleted ${deletedCount} item(s)`);
await sleep(CONFIG.INTERVAL_BETWEEN_DELETES);
document.body.click();
await sleep(300);
return true;
} catch (error) {
console.error('ā Error processing item');
document.body.click();
await sleep(500);
return false;
}
}
console.log('š Starting deletion process...');
await sleep(1000);
while (!shouldStop && emptyScrollCount < CONFIG.MAX_EMPTY_SCROLLS) {
const buttons = findThreeDotButtons();
if (buttons.length === 0) {
const oldScroll = window.scrollY;
window.scrollBy({
top: CONFIG.SCROLL_AMOUNT,
behavior: 'smooth'
});
await sleep(CONFIG.SCROLL_WAIT_TIME);
if (Math.abs(window.scrollY - oldScroll) < 100) {
emptyScrollCount++;
console.log(`š Scrolled ${emptyScrollCount} times without finding items`);
if (emptyScrollCount >= CONFIG.MAX_EMPTY_SCROLLS) {
console.log('š Reached end of activity log');
break;
}
} else {
emptyScrollCount = 0;
}
continue;
}
console.log(`š Found ${buttons.length} activity items`);
const batchSize = Math.min(CONFIG.PROCESS_BATCH_SIZE, buttons.length);
let processedCount = 0;
for (let i = 0; i < batchSize && !shouldStop; i++) {
const button = buttons[i];
if (await processActivityItem(button)) {
processedCount++;
}
if (i < batchSize - 1) {
await sleep(500);
}
}
if (processedCount === 0) {
emptyScrollCount++;
} else {
emptyScrollCount = 0;
}
window.scrollBy({ top: 200, behavior: 'smooth' });
await sleep(1000);
}
console.log(`\nš Script finished!`);
console.log(`š Total deleted: ${deletedCount} items`);
if (shouldStop) {
console.log('ā¹ļø Script stopped by user');
} else if (emptyScrollCount >= CONFIG.MAX_EMPTY_SCROLLS) {
console.log('š No more items found');
}
})();
How to Use This Script
- Navigate to Facebook Activity Log: Go to your Facebook Activity Log (you must be signed in).
- Select Activity Type: Navigate to any activity section that has three-dot menus (e.g., Groups, Comments, Posts).
- Open Developer Console: Press
F12orCtrl+Shift+I(Windows/Linux) /Cmd+Option+I(Mac) to open Developer Tools. - Switch to Console Tab: Click on the "Console" tab in the Developer Tools panel.
- Paste and Run: Copy the script above, paste it into the console, and press
Enterto execute. - Monitor Progress: Watch the console for deletion counts and watch the browser as it automatically removes items.
- Stop the Script: To stop execution, type
stopScript()in the console and press Enter.
Usage Notes
- Keep the Facebook tab active and visible while the script runs
- Works on any Facebook activity log with three-dot menus and "Delete Your Activity" option
- The script automatically scrolls and loads more items as needed
- It stops when it reaches the bottom of the page or after 5 empty scrolls
- If Facebook changes their HTML, you might need to update the selectors
- For thousands of items, this will take time (e.g., 1000 items at 100ms each = ~1.7 minutes)
Configuration Tips
You can modify these variables in the script:
INTERVAL_BETWEEN_DELETES- Time between each deletion (milliseconds). Default is 100ms.- Too fast may trigger Facebook's rate limiting
- May cause temporary blocks or CAPTCHA verification
- 100ms is faster but may risk detection
SCROLL_AMOUNT- How much to scroll when no items are found (pixels)PROCESS_BATCH_SIZE- Number of items to process at once (1 recommended)MAX_EMPTY_SCROLLS- Stop after this many scrolls without finding items
Note: Facebook may temporarily block actions if the script runs too fast. If this happens, increase the interval time.
Important
This script is designed for educational purposes and personal use only. Only use it on your own Facebook account. Facebook may detect automated activity and temporarily restrict your account. Use responsibly and at your own risk.