我正在 iOS 应用程序中开发内容拦截器扩展。我已经屏蔽了某些网站上的特定内容,但是我可以使用内容屏蔽扩展程序来屏蔽整个网站吗?
最佳答案
我不认为拦截器扩展程序的目的是阻止特定的网站
。
In iOS, a Content Blocker extension customizes the way Safari and Safari View Controller handle your content. The extension tailors your content by hiding elements, blocking loads, and stripping cookies from Safari requests.
您应该在
中处理 URL blockwebView:shouldStartLoadWithRequest:navigationType
并在那里进行控制。一个例子:
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let url = request.URL?.absoluteString
if url == "http://www.test.com"{
return false
}
return true
}
关于ios - 我可以使用 iOS 中的内容拦截器扩展来阻止 Safari 上的特定网站吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39423170/