How does adblock block adsense ads?

I was working on something to block ads (or rather hide them) using simple javascript. For site-targeted ads using something like this:

document.querySelector("img[src*='domain.com/path/to/ad/']").style.display="none" 

It actually works to find a specific image and hide it. However, Google seems to be inserting its ads in an iframe that contains its own document with a header / body / footer. It looks like this:

google ads

I could not find a way to select an adense ad and do something with it. How would you choose something in this block?

+6
source share
1 answer

I believe that it uses a combination of things such as the URL from which the add is added, the banner size and the code for the ad in the html page.

I think adblock actually saves the ad from loading, and not just hides it.

Why do you want to hide the ad. Is this your web page where you host javascript?

+1
source

Source: https://habr.com/ru/post/972135/


All Articles