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.
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.
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.
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.
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.
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