Skip to content

Instantly share code, notes, and snippets.

@wcpines
Last active March 11, 2019 17:11
Show Gist options
  • Save wcpines/c1e2a1196ac079fc761eebc298a8a85f to your computer and use it in GitHub Desktop.
Save wcpines/c1e2a1196ac079fc761eebc298a8a85f to your computer and use it in GitHub Desktop.
Remove facebook advertisers
// NOTE: This is intended for moderately technical folks
// 1. Navigate to https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen
// 2. Click on "Advertisers you've interacted with"
// 3. Open a developer console and paste the script below
// 4. (This should also work for the "Your Interests" section)
// WARNING: The class names used in the query selectors are probably dynamically
// generated and may not be the same for you. Try manually running some of
// the selection lines to see if they work first
// expand list of advertisers all the way
while (true) {
seeMore = document.querySelector('._45yr');
if (!seeMore) {
break;
}
seeMore.click();
}
// get a list of your advertisers
all = Array.from(document.querySelectorAll('._2b2e'));
all.forEach(element =>
console.log(element.firstElementChild.lastElementChild.getAttribute('alt'))
);
// remove them
removals = Array.from(document.querySelectorAll('[data-tooltip-content="Remove"]'))
removals.forEach( removeButton => removeButton.click() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment