sagraham
sagraham

Reputation: 101

Detect if user has iOS content blocking enabled from a webpage

I've seen this question, but I think mine is sufficiently different that it's not a duplicate.

I want to determine if a user has turned on iOS Content Blocking and then conditionally load info based on that status. I'm finding that some third party widgets (Trip Advisor and a third-party booking widget) are causing pages not to render at all when some Content Blockers are active.

I'd like the option to detect this and not even try to load the content, instead offering the user a direct link to the third party rather than embed it in an iframe.

Upvotes: 10

Views: 874

Answers (1)

zhuravlyov
zhuravlyov

Reputation: 503

So if you would like to detect such blockers as adblock or adblockplus you have to insert an html bait into your page. Such blockers use masks to detect ads. For example banner sizes (468x60, 300x100 or so). Then try to check few times in (50ms interval) if this html bait code is still placed in your page. If you find your bait code after few attempts there is no any blocker on client side. Just remove bait code and render the rest part of your page.

Upvotes: 1

Related Questions