jasono
jasono

Reputation: 213

How does adblock block adsense ads?

I've been working on something to block ads (or rather hide them) utilizing plain javascript. For ads specific to a website using something like this:

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

Actually works to find the specific image and hide it. However, google seems to be inserting their ads in an iframe that contains it's own document with a header/body/footer. It looks like this:

google ads

I haven't been able to find a way to select the adsense ad and do something with it. How would you go about selecting anything within that block?

Upvotes: 6

Views: 1096

Answers (1)

user3823888
user3823888

Reputation: 11

I believe it uses a combination of things such as the url the add originates from, the size of the banner and the code for the ad within the html of the page.

I think that adblock actually keeps the ad from loading and not just hiding it.

Why are you wanting to hide the ad. Is it your webpage you placing the javascript?

Upvotes: 1

Related Questions