ios - 我可以使用 iOS 中的内容拦截器扩展来阻止 Safari 上的特定网站吗

标签 ios swift safari-content-blocker

我正在 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 block
webView: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/

相关文章:

ios - iPad : Content view is not resized to fit popover

ios - 确定用户是否已启用应用程序的 Safari 内容拦截器扩展

iphone - 使用 HoughCircles 检测和测量瞳孔和虹膜

ios - OAuthSwift和Github-我应该使用哪个授权回调URL?

ios - XCode 场景 View 加载模型不正确

swift - Swift 中的子模块

ios - NavigationBar 标题文本不会随 titleTextAttributes 改变

ios - 将 Collection View 单元格垂直放置而不是水平放置?

safari - 更新 Safari 应用程序扩展内容拦截器列表