Skip to content

Instantly share code, notes, and snippets.

@moeinalmasi
Last active October 3, 2022 08:22
Show Gist options
  • Save moeinalmasi/88c3014a8e8429f472eddb2706bfcf7a to your computer and use it in GitHub Desktop.
Save moeinalmasi/88c3014a8e8429f472eddb2706bfcf7a to your computer and use it in GitHub Desktop.
Unlike All Facebook Pages
// Run it at your own risk!!
// If you have been on Facebook since 2004 and happened to like ton of pages and wanna get rid of them all at once...
// Navigate to https://www.facebook.com/pages/?category=liked and run the the following snippet in the developer console...
var fb_unlike_all = () => {
[].slice
.call(document.querySelectorAll("button"))
.filter((x) => x.innerText.indexOf("Liked") != -1)
.map((x) => {
x.click();
});
window.scrollTo(0, document.body.scrollHeight);
window.setTimeout(fb_unlike_all, 3 * 1000);
};
fb_unlike_all();
@nathanbirrell
Copy link

Nice one. In case this doesn't work for others, I had to add 2 things:

  1. Selectors for FB's classnames (which will change every release so you will need to update the querySelectorAll unfortunately)
  2. "Unlike" AND "Unfollow" pages, depending on which verb the button uses

Updated version:

// If you have been on Facebook since 2004 and happened to like ton of pages and wanna get rid of them all at once...
// Navigate to https://www.facebook.com/pages/?category=liked and run the the following snippet in the developer console...
var fb_unlike_all = () => {
  [].slice
    .call(
      document.querySelectorAll(
        // You'll probably have to dig into inspector to update this for yourself unfortunately, it will change on every FB release
        ".om3e55n1.g4tp4svg.alzwoclg.jez8cy9q.jcxyg2ei.i85zmo3j.sr926ui1.jl2a5g8c.k7n6ui8p.b41d885q.hmqrhxox.got7tec9.frfouenu.bonavkto.djs4p424.r7bn319e.bdao358l.aesu6q9g.e4ay1f3w.dqxcxcok.ed17d2qt"
      )
    )
    .filter((x) => x.innerText === "Liked" || x.innerText === "Following")
    .map((x) => {
      x.click();
    });
  window.scrollTo(0, document.body.scrollHeight);
  window.setTimeout(fb_unlike_all, 3 * 1000);
};
fb_unlike_all();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment