user123
user123

Reputation: 33

Can I make adblockers see element as a ad

Is there a way I can mark a element as a ad so that adblock will hide it? I have a user upset because what he considers a ad isnt blocked by his ad blocker.

Upvotes: 0

Views: 700

Answers (1)

Michael Riccio
Michael Riccio

Reputation: 48

So adblock works by searching through the scripts before load and removing anything that matches a list of known ads.

Technically all you would have to do is search for this element and add a class that would be picked up by the normal ad blocker.

//get the elements you're looking for, turn into NodeList
  const makeAd = document.querySelectorAll(".the-element-youre-looking-for");
    
//function for adding a class called ".adContent"
  const addAds = (currentNode) => {
  currentNode.classlist.add('.adContent');

//iterating through each of the possible items in the NodeList
for(const i of makeAd) {
window.addEventListener('DOMContentLoaded', function() {addAds( makeAd[i] );}
)};

Upvotes: 2

Related Questions