4 ms·
It's not possible to do that and use the fast JavaScript engine from WKWebView. I'm sorry but you have no idea what you're talking about.
by gcp 10y ago
It's not possible to do that and use the fast JavaScript engine from WKWebView. I'm sorry but you have no idea what you're talking about.
- azinman2 10y agoWhy not? WKWebView has a delegate callback for the policy to load any given URL. You can implement ad blocking that way. Or you can chose to inject CSS rules if that's your fancy. What's the technical issue?
- ash_gti 10y agoAre you referring to the `-[WKWebView navigationDelegate]`? Thats only used for user initiated navigation, not loading of assets. You could still inject a JavaScript file or CSS file though to help hide pieces of the view. But that would be content blocking after the HTTP requests have been made. I don’t know of a way to intercept the HTTP requests as they’re being made from a WKWebView like Safari does for content blocking.
- foodstances 10y agoThe technical issue is that WKWebView does not honor any custom classes registered with NSURLProtocol (`NSURLProtocol registerClass:`) like UIWebView does, so you don't get to intercept/change/deny every request (not just top-level requests) that the browser makes.