Skip to content

Instantly share code, notes, and snippets.

@shaneog
Last active October 30, 2023 20:42
Show Gist options
  • Save shaneog/f0a84ed120a31b6c0a7dc3bb10a019b0 to your computer and use it in GitHub Desktop.
Save shaneog/f0a84ed120a31b6c0a7dc3bb10a019b0 to your computer and use it in GitHub Desktop.
Clean Facebook Ad Preferences
// This script will remove all Interests and Advertisers from your Facebook profile
//
// Instructions
//
// Go to: https://www.facebook.com/ads/preferences/
//
// Open the browser console
//
// Paste the following code into the console and execute it
// First open all expandable regions
console.log("Opening expandable regions");
for (i = 1; i < 2; i++) {
Array.from(document.querySelectorAll("div._2qo7"))[i].click();
}
// Expand see more areas
var see_more = document.querySelectorAll('div._5946');
while (see_more.length > 0) {
console.log("See more buttons found", see_more.length);
Array.from(see_more).forEach(button=>button.click());
see_more = document.querySelectorAll('div._5946')
}
console.log("Waiting for all categories to load...");
console.log("Removing categories");
Array.from(document.querySelectorAll("button._2b2p")).forEach(button=>button.click());
console.log("All categories removed");
@aumbriac
Copy link

aumbriac commented Apr 3, 2020

Good stuff - just a side note. You will need to go into the developer console and hover over the X remove button to snag the class name. They've updated it since this has been published.

@DNooch381
Copy link

Good stuff - just a side note. You will need to go into the developer console and hover over the X remove button to snag the class name. They've updated it since this has been published.

Hey! Where do we insert the class name for the "X remove button" in the code?

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