Remove all advertisers and targeted ads from facebook in 2 minutes
Tags: facebookads, deletefacebookdata, deletefacebookads, removefacebookads
Published: 2019-02-19 19:28:53

---
title: Remove all advertisers and targeted ads from facebook in 2 minutes
published: true
tags: facebook-ads,delete-facebook-data,delete-facebook-ads,remove-facebook-ads
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/0*GwUqD0Na69pz4_Jk)<figcaption>Photo by <a href="https://unsplash.com/@thoughtcatalog?utm_source=medium&amp;utm_medium=referral">Thought Catalog</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption>

**User** – Hey Facebook, what do you do for living?

**Facebook** – We _curate_ people’s News Feed based on what they like, what information they share with us in their profile, what websites they visit – where that website gives us money to follow the users 24 X 7, and more.

**User** – How can I stop that? Can I remove all that targeted ads and advertisers?

**Facebook** – Yes, now you can. Just remove all advertisers from your profile — _one by one._

**User** – But I have them in thousands.

**Facebook** – I can’t hear you.

Yes, some things are made difficult deliberately to discourage you from doing it. You can’t delete all the advertisers once in for all by just clicking one button. But we can make that happen by running just _one line of code._

Steps below work for both sections:  
1) [Who use a contact list added to Facebook](https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen#).  
2) [Whose website or app you’ve used](https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen#)

Here’s how to do it:

Step 1: Go to **Ads** section in your profile:

![](https://cdn-images-1.medium.com/max/1024/1*Pk6iJnp9jUMzuP5XyRZ90Q.png)

Step 2: **Click** on Advertisers tab

![](https://cdn-images-1.medium.com/max/1024/1*LDu8TjiIqHqZil1jrxd-mA.png)

Step 3: **Right click** on first Advertiser and click inspect element.

![](https://cdn-images-1.medium.com/max/1024/1*E12f242qo4KK7et7PNMK7w.png)

If you want to remove all the advertisers, you have to bring them in the browser view. For that, keep clicking _See more_ until all the advertisers have loaded and then you can continue the following steps. In case, you just want to give it a shot. You don’t have to do anything.

If you are lazy like me and don’t even want to keep clicking “_See more”_ hundred times, here’s the code for that too.   
This will invoke click on “_See more_” for 50 times. If you want to trigger click more than 50 times, replace 50 with some bigger number.

```
[...new Array(50)].forEach(() => document.querySelector('#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45yq._5946 > div > div').click());
```

Step 4: Clicking inspect will open a section at the bottom or on the side of your browser.

Now head over to **console** section in that menu. You will see a big STOP sign. Ignore it (Trust me 😃). Just execute this code:

```
document.querySelectorAll(
    '#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45ys > div._2b2e > div._3viq > div._2b2h > button > div._2b2n'
  )
  .forEach(advSection => advSection.click())

```

This should remove all advertisers. This may freeze your screen for sometime.

Here is the code to add them back again:

```
document.querySelectorAll(
    '#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45ys > div._2b2e > div._3viq > div._2b2h > button > div._2b2m'
  )
  .forEach(advSection => advSection.click())

```

> The above code should work. If you are curious to know how we formed that code and just in case the above doesn’t work for you. Keep following to know the steps to form that code.

If the above code doesn’t work then may be it is because of the class names, it seems it could be different for you. So, you need to write code specific to your machine. Notice that whole Advertisers sections follows _same pattern_ of naming (`<div class="_2b2e">`) each section. I have tagged that as _Parent Element_.

![](https://cdn-images-1.medium.com/max/1024/1*m-WtRS_TcexqfajHYjR66w.png)

Toggle the Parent Element section to hide the code and you should see something like below. As you can see, all individual advertiser section have same code, only the data in it is different.

![](https://cdn-images-1.medium.com/max/1024/1*tV3gxw1Rrfs9cJYrsmwxhQ.png)

**NOTE:** You may have different class value(\_2b2e in my case) from me probably. But don’t worry, follow the steps with whatever values you have. It is all good until all the sections have same class values.

Now, the main part. We need to trigger click on that remove button which only appears when we hover our mouse on each Advertiser section. Let’s locate that in code. You can click the first Parent element and keep opening the code until you find that remove button.

![](https://cdn-images-1.medium.com/max/1024/1*2Kb_vI-Old2_7lIOPV2l0Q.png)

Let’s do the coding now. Right click on the first **Parent element** and go to **Copy** and then **Copy Selector.** After clicking **console** tab, you might see a big STOP sign with warning. Ignore that. (Trust me!). Now if you paste the code, it will look something like this. The values starting with **dot(.)** could be different for you.

```
#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45ys > div:nth-child(1)
```

![](https://cdn-images-1.medium.com/max/1024/1*_iYHhZAfoi2_j8whF7QRrQ.png)

Replace the last part of code which says — ‘**_:nth-child(1)_**’ with the class value of ‘ **Parent Element** ’. In my case, it is **_\_2b2e._** So I would replace it with **_‘.\_2b2e’._** Don’t forget to add a **_dot(.)_** before. It will look something like this:

```
#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45ys > div._2b2e
```

This gives us code to reach to the Parent element but we need to reach to the Remove button and hit click on that. For that we need to go down each level and get the class value of all the elements to form the code to execute. All target values are marked with red arrows.

![](https://cdn-images-1.medium.com/max/1024/1*HAHtjD4mSSrwg_Ulnw7vOw.png)

Let’s form the code. If you have different class names, code accordingly. After the parent element (div.\_2b2e), keep adding angular bracket and the class values with **‘div.’** prepended to it. And put that value in document.querySelectorAll() and add a for loop to trigger click on all. Something like this:

```
document.querySelectorAll(
    '#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45ys > div._2b2e > div._3viq > div._2b2h > button > div._2b2n'
).forEach(advSection => advSection.click());
```

That’s it. It should remove all the Advertisers.

Wait, what if I want to add them back again. Locate the remove button again.

![](https://cdn-images-1.medium.com/max/1024/1*QsSegMBQftO9bzxXtL5Lyw.png)

You can see the value **_\_2b2n_** is replaced with **_\_2b2m._** Just replace the class in the above code and execute it again.

```
document.querySelectorAll(
'#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45ys > div._2b2e > div._3viq > div._2b2h > button > div._2b2m'
).forEach(advSection => advSection.click());
```

This should add the advertisers back.

Moreover, you can got to Ad Settings and choose ‘Not allowed’ in all sections to further stop the curation and targeted ads.

I am curious to know if you have different class names. Let me know in the comment section if they are and also if you are facing any issues. _Have fun!_

Check out my another blog to unlike all facebook pages at once.

[Unlike all pages on facebook in 2 minutes](https://dev.to/parthchokshi/unlike-all-pages-on-facebook-in-2-minutes-3ao1)