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:
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?
For example, perhaps you run Google Adsense or some Google AdSense alternatives. If an ad blocker is detected you could have it fallback to an affiliate ad instead. Typically affiliate ads are just image banners and shouldn't be impacted by ad blockers.
If you use Google Chrome, use the Adblock Plus extension to get rid of all annoying advertising. Adblock Plus blocks all annoying ads on the web, like YouTube video ads, flashy banner ads, Facebook ads and much more. It even blocks pop-ups which are not blocked by your browser.
If a consumer is using an ad blocker, they're not being shown ads, therefore the creators of the videos they watch aren't able to receive revenue from those viewers. While this can impact their income, we've discovered that the majority of YouTube users aren't using these tools.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With