Skip to content

Instantly share code, notes, and snippets.

@scarlac
Last active June 7, 2021 09:36
Show Gist options
  • Save scarlac/3c4b9d9868148ef31e2ea5082e59a0f1 to your computer and use it in GitHub Desktop.
Save scarlac/3c4b9d9868148ef31e2ea5082e59a0f1 to your computer and use it in GitHub Desktop.
Facebook Hack: Purge list of "Advertisers you've interacted with"

For those of you who want to remove all in “Advertisers and Businesses” / "Who uploaded a list with your info and advertised to it":

  1. Go to https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen and open the section "Advertisers you've interacted with"
  2. Collapse all sections but keep "Advertisers and Businesses" open
  3. Open Web Inspector
  4. Copy-paste this script to load all advertisers: smt=setInterval(() => {let x=document.querySelector('div[shade=medium]'); x ? x.click() : clearInterval(smt), console.log('done')}, 1000)
  5. It will output a number. Wait for it to say “done” in the console. This may take a long time. you'll notice the scrollbar changing while it's loading all advertisers.
  6. Copy-paste this and press enter: document.querySelectorAll('[data-tooltip-content="Hide all ads from this advertiser"]').forEach(el => el.click())
  7. Wait for advertisers to turn grey, indicating they've been removed (this may take a while as well)

That's it.

@sloscheider
Copy link

Fantastic! Thanks :) note: during the Remove process Firefox prompted multiple times that at script was slowing down Firefox so I just kept telling it to wait until it finished.

@timheuer
Copy link

👍 -- put "javascript:" in front of these two and drag to bookmark for scriplet for routine use :-)

@atomicbird
Copy link

As of today it looks like the page has changed slightly. Step 5 should now read document.querySelectorAll('[data-tooltip-content="Hide ads from this advertiser"]').forEach(el => el.click()).

@danwallach
Copy link

Facebook has totally changed how the web UI works. To rebuild this, you'll need to click all the "view details" links, then click each and every "Hide all ads from this advertiser" button. Should be do-able.

@scarlac
Copy link
Author

scarlac commented Aug 15, 2019

Thanks @danwallach

Have you tested the solution @atomicbird posted? I can update it if provided with the necessary change :)

@dailyvideo
Copy link

So when we use the first script from the original post in Firefox Inspector>Console it does give a number then "done" but when we try the second script or the updated one from atomicbird it just shows "undefined" and nothing happens. Would you please post an update? This has been a Godsend. Thanks!

@atomicbird
Copy link

@dailyvideo Facebook has changed the page in various ways over time, sometimes going back to previous versions. There may even be something like A/B testing going on where different people see different pages, or where people see different pages at different times, etc. As of right now, for me, my version works as intended. It's a dynamic page though, so it might not work for me tomorrow, or for you now. The page does not seem to be static enough for one approach to work for everyone for any length of time.

@atomicbird
Copy link

To follow up a little, that page changes enough that I'm surprised my version works right now. I had given up on it, because the page I was getting was very different. It's back to the previous design though-- for me, and for now, at least.

@dailyvideo
Copy link

dailyvideo commented Oct 5, 2019 via email

@mjleo
Copy link

mjleo commented Jan 15, 2020

UPDATE -- JAN 15TH 2020
The below works when all advertisers are loaded on the page:

document.querySelectorAll('[data-tooltip-content="Hide all ads from this advertiser"]').forEach(el => el.click())

@scarlac
Copy link
Author

scarlac commented Jan 15, 2020

@mjleo I've updated the instructions. Thanks!

@drnic1
Copy link

drnic1 commented Feb 24, 2020

They have killed this technique by enabling a console disable "feature"
See here
https://stackoverflow.com/questions/21692646/how-does-facebook-disable-the-browsers-integrated-developer-tools
Any additional methods to automate this - I cannot keep up manually with the junk they throw into my feed

@scarlac
Copy link
Author

scarlac commented Feb 24, 2020

@drnic1 It works fine for me in Safari. It's not possible to disable the console entirely. If they disabled the console.log statement, then just pay attention to the Network tab to see when it stops loading something.

@drnic1
Copy link

drnic1 commented Feb 24, 2020

Not working for me (where it used to and was awesome!)
Chrome and Firefox no longer work for the above reasons. Had to disable one fo my blockers for this page to even work in Safari (uBlock) THen I get

smt=setInterval(() => {let x=document.querySelector('div[shade=medium]'); x ? x.click() : clearInterval(smt), console.log('done')}, 1000)
< 3030
[Log] done
document.querySelectorAll('[data-tooltip-content="Hide all ads from this advertiser"]').forEach(el => el.click())
< undefined

Not sure what I am lookign at in the network tab which shows a long list of activities and a timeline

@scarlac
Copy link
Author

scarlac commented Feb 24, 2020

@drnic1 The log statement is clearly working from your paste. It's saying "done". Make sure you followed the instructions. Expand the relevant panels and collapse all others.

@drnic1
Copy link

drnic1 commented Feb 24, 2020

OK - thanks - appreciate the feedback
I think I may be confusing this working with the new tab of "Advertisers who have uploaded information about you"....
Another huge list of people that require manual deleting with 4 clicks per company

@vdias
Copy link

vdias commented Jun 7, 2021

Not working...

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