2

I am working on a content blocker extension in an iOS app. I already blocked specific content on some website, but can I block the whole website using a content blocker extension?

MendelG
  • 14,885
  • 4
  • 25
  • 52
ikbal
  • 1,114
  • 1
  • 11
  • 30

2 Answers2

1

I don´t think the purpose of the blocker extension is to block a specific webSite.

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.

You should instead handle the URL-block in the

webView:shouldStartLoadWithRequest:navigationType

And make your controls in there. An examlple:

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
}
Rashwan L
  • 38,237
  • 7
  • 103
  • 107
1

I got a solution.

[{
        "action": {
            "type": "block"
         },
         "trigger": {
            "url-filter": ".*reddit.*"
            
         }
}]

write this code in the content blocker extension of JSON file.

MendelG
  • 14,885
  • 4
  • 25
  • 52
ikbal
  • 1,114
  • 1
  • 11
  • 30