Skip to content

Instantly share code, notes, and snippets.

@maifeeulasad
Created August 7, 2025 07:36
Show Gist options
  • Select an option

  • Save maifeeulasad/76c442aba634c43e301989506d0767f3 to your computer and use it in GitHub Desktop.

Select an option

Save maifeeulasad/76c442aba634c43e301989506d0767f3 to your computer and use it in GitHub Desktop.
facebook unsave all or remove all item from saved for later
  • go to your saved page: https://www.facebook.com/saved/
  • or you can go inside some specific collection
  • scroll down, keep scrolling down till you reach the end
  • and then paste the script in console and hit enter

we can automate the scrolling part as well, but I had 14k something in saved for later page, so had to do it in a span of a month anyways. and facebook will make my 128gb pc slow if i tried to render the whole list, as it is not virtualized at all.

(async () => {
// Helper to wait a given number of milliseconds
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
// Find all target elements with the specific outer div class
const elements = Array.from(document.querySelectorAll(
'.html-div.xdj266r.xat24cr.xexx8yu.xyri2b.x18d9i69.x1c1uobl.x6s0dn4.x78zum5.xl56j7k.x14ayic.xwyz465.x1e0frkt'
));
console.log(`Found ${elements.length} elements. Starting from the last.`);
for (let i = elements.length - 1; i >= 0; i--) {
const el = elements[i];
// Scroll into view and click
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
el.click();
console.log(`Clicked element ${i}`);
await wait(500);
// Look for the "Unsave" span with exact class string
const unsaveBtn = Array.from(document.querySelectorAll(
'span.x193iq5w.xeuugli.x13faqbe.x1vvkbs.x10flsy6.x1lliihq.x1s928wv.xhkezso.x1gmr53x.x1cpjm7i.x1fgarty.x1943h6x.x4zkp8e.x41vudc.x1f6kntn.xvq8zen.xk50ysn.xzsf02u.x1yc453h'
)).find(span => span.textContent.trim() === 'Unsave');
if (unsaveBtn) {
unsaveBtn.scrollIntoView({ behavior: 'smooth', block: 'center' });
unsaveBtn.click();
console.log(`Clicked 'Unsave' for element ${i}`);
} else {
console.warn(`Unsave button not found for element ${i}`);
}
await wait(500);
}
console.log('Done unsaving all.');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment