I recently had an issue whereby a user was plaining that they couldn't access a certain page because the link wasn't where it was supposed to be.
After some head-scratching, I had them disable all browser extensions and sure enough the problem went away. Re-enable extensions one by one...
AdBlock.
For some reason, it was blocking the links to the pages the user wanted to access.
Now, I don't run ads and never plan to, so usually I just tell people with this problem to whitelist the site and all is well. But if someone never knew there was a problem to begin with, I would actually lose traffic because of this. So how can I avoid this?
The only thing I can really think of is to detect AdBlock and pop up a small notice explaining that AdBlock is known to corrupt the website and that, since we don't run ads, they may want to disable it for the site. I mean, the site is a game, and this isn't the first time a browser extension has broken it, but I don't think first-time visitors would be too happy to see a popup asking to disable their blocker, you know?
So any solution that would actually prevent AdBlock from corrupting the site in the first place would be great.
I recently had an issue whereby a user was plaining that they couldn't access a certain page because the link wasn't where it was supposed to be.
After some head-scratching, I had them disable all browser extensions and sure enough the problem went away. Re-enable extensions one by one...
AdBlock.
For some reason, it was blocking the links to the pages the user wanted to access.
Now, I don't run ads and never plan to, so usually I just tell people with this problem to whitelist the site and all is well. But if someone never knew there was a problem to begin with, I would actually lose traffic because of this. So how can I avoid this?
The only thing I can really think of is to detect AdBlock and pop up a small notice explaining that AdBlock is known to corrupt the website and that, since we don't run ads, they may want to disable it for the site. I mean, the site is a game, and this isn't the first time a browser extension has broken it, but I don't think first-time visitors would be too happy to see a popup asking to disable their blocker, you know?
So any solution that would actually prevent AdBlock from corrupting the site in the first place would be great.
Share Improve this question asked May 16, 2017 at 9:50 Niet the Dark AbsolNiet the Dark Absol 325k85 gold badges473 silver badges599 bronze badges 9- AFAIK, adBlock is also triggered by specific words. Changing the name/url might help :) – Martijn Commented May 16, 2017 at 9:53
-
I recently had a problem like this, Adblock was stopping the
onerror
attribute of animg
element working. I just told the tester to disable it, if anyone has an answer I'd like to know too. It was "AdBlock Ultimate" that was causing this issue, "AdBlock plus" worked fine – George Commented May 16, 2017 at 9:54 - does the url contain any ad keywords like ad buy sell – treyBake Commented May 16, 2017 at 9:55
- @ThisGuyHasTwoThumbs The link in question was to the site's forums. Oddly, one of two such links (which appear at different window sizes), but only one of the two was blocked. – Niet the Dark Absol Commented May 16, 2017 at 9:57
- click here to start the adventure against multiple adversaries adding hours of fun to your day – mplungjan Commented May 16, 2017 at 9:57
1 Answer
Reset to default 13You cannot prevent Chrome extensions from running. They operate in their own separate thread, with a privileged API, and hidden from page scripts.
Detecting adblockers is awkward. The easiest way is to create a 'sacrificial element' - a div with a class like 'ad_unit', for example - add it to the DOM and then wait a frame to see if it has been hidden (with display: none
, for example, or a getBoundingClientRect
check).
Element checking is tricky, though, because strictly speaking there's no guarantee an adblocker will run synchronously or before your checking code.
Because adblockers run in a privileged mode, their operation does not trigger events in the nonprivileged script space. To put it more simply: you can't use DOMMutationEvents
to spy when a foreign extension messes with your page.
The other option is to try and load a 'sacrificial file' - an image with a URI that looks like an advert, say - and then attach an onError
handler to the element. If it throws an error that looks suspicious (I think it's ERR_BLOCKED_BY_CLIENT
on Chrome), then you show your warning message.
Your final choice is to try and avoid incurring Adblock's wrath in the first place. Adblockers generally use open blacklists of URIs and CSS selectors, like EasyList (https://easylist.to/easylist/easylist.txt) - this is what AdblockPlus uses and a fair few others. You could just try and make sure your DOM elements never have IDs or classes that collide with any of those selectors. It's a big list, though, and it can change at any time.