Skip to content

Instantly share code, notes, and snippets.

@heretoinfinity
Forked from wcpines/fbClean.js
Created April 11, 2018 05:03
Show Gist options
  • Save heretoinfinity/f18d4aa4f73b13a58f206af031d1e2ed to your computer and use it in GitHub Desktop.
Save heretoinfinity/f18d4aa4f73b13a58f206af031d1e2ed 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