Skip to content

Instantly share code, notes, and snippets.

@joseederangojr
Last active July 24, 2025 20:21
Show Gist options
  • Select an option

  • Save joseederangojr/e4117f0ec2ccac17a8142c19cb13b735 to your computer and use it in GitHub Desktop.

Select an option

Save joseederangojr/e4117f0ec2ccac17a8142c19cb13b735 to your computer and use it in GitHub Desktop.
Facebook friend remover
// Go to facebook > settings > activity logs > connections > friends
(async () => {
function waitForElement(selector, timeout = 10000) {
return new Promise((resolve, reject) => {
const intervalTime = 100;
let elapsed = 0;
const interval = setInterval(() => {
const el = document.querySelector(selector);
if (el) {
clearInterval(interval);
resolve(el);
}
elapsed += intervalTime;
if (elapsed >= timeout) {
clearInterval(interval);
reject(`Timeout: Element not found - ${selector}`);
}
}, intervalTime);
});
}
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
while (true) {
const btn = document.querySelector('[aria-label="More options"]');
if (!btn) {
console.log('✅ No more "More options" buttons found. Finished.');
break;
}
try {
btn.click();
console.log('✅ Clicked: More options');
const menuItem = await waitForElement('[role="menuitem"][tabindex="0"]');
menuItem.click();
console.log('✅ Clicked: Menu item');
const removeBtn = await waitForElement('[aria-label="Remove"]');
removeBtn.click();
console.log('✅ Clicked: Remove');
// Wait 2 seconds before next iteration
await delay(2000);
} catch (err) {
console.warn('⚠️ Error processing button:', err);
// Optional: delay before retry or next iteration
await delay(2000);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment