Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 635
sagraham Avatar asked Jan 04 '16 12:01

sagraham


People also ask

Does Safari have a Content blocker?

Content blockers are app extensions that you build using Xcode. They indicate to Safari a set of rules to use to block content in the browser window. Blocking behaviors include hiding elements, blocking loads, and stripping cookies from Safari requests.

How do I turn off iPhone Content filtering?

Go to Settings and tap Screen Time. Tap Content & Privacy Restrictions, then tap Content Restrictions. Choose the settings that you want for each feature or setting under Allowed Store Content.

How do I bypass Content filter on Safari?

Launch Safari on your iOS device and navigate to the site in question. Tap the "aA" icon in the top-left corner of the screen to reveal the Website View menu. Tap Website Settings. Toggle the switch beside Use Content Blockers to the grey OFF position.


1 Answers

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.

like image 74
zhuravlyov Avatar answered Oct 08 '22 18:10

zhuravlyov