Skip to content

Instantly share code, notes, and snippets.

@dvx
Last active February 16, 2024 13:09
Show Gist options
  • Save dvx/67db6e6ac085d960ea43b9510eb16fec to your computer and use it in GitHub Desktop.
Save dvx/67db6e6ac085d960ea43b9510eb16fec to your computer and use it in GitHub Desktop.
How to Remove all Facebook Interest Categories

Facebook is Evil

If you're like me, you've amassed hundreds, if not thousands, of "interests" on Facebook over the past decade. These interests can be used to track, target, and advertise to you. These public "likes" can also be used for more nefarious purposes, like blackmail or coersion (https://www.forbes.com/sites/kashmirhill/2013/01/23/facebook-graph-search-embarrassing).

This is a short guide on how to easily remove them.

Guide

  1. First, make sure you're logged into Facebook and navigate to https://www.facebook.com/adpreferences/?section=interests

  2. Click "See All Interests"

  3. Open your browser's Javascript console and type in: setInterval(function(){ document.querySelectorAll('div[aria-label="Remove"]')[0].click() }, 2000); where 2000 is the number of miliseconds to wait between clicking the "Remove" button. My default is a sensible two seconds. This function clicks "Remove" over and over again. Facebook makes it purposefully cumbersome to remove all interests at once.

  4. Wait.

@RyanRoberts
Copy link

Thank you 💪

@ChronSyn
Copy link

Great work!

It's difficult to pin down a suitable interval, but 2000ms takes a very long time for anyone who's been on the site for more than a few months. Realistically, you could probably get away with 250-500ms.

I adapted your version:

document.querySelectorAll('div[aria-label="Remove"]').forEach((item, index) => {
    setTimeout(() => {
        item.click();
    }, index * 250)
})

This doesn't wait for the previous item to be clicked (i.e. for matching element at index 0), and instead cycles through each matching DOM node, and using a timeout that's offset by the index of the node * a suitable interval.

I found that with this version and 250ms, although I had to refresh the page 2-3 times and run the script each time, it managed to get through the entire process in about 3-4 minutes. With the original version posted, it would have taken over 40 minutes to clear out the list. The trade-off is either fire-and-forget (original version) or speed with some intervention required (my version).

@bnievera
Copy link

Thank the digital gods for this. Now if I could let this happen in the actual app, I'd be a happy camper. ditto the suggested or recommended ads.

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