Search code examples
swiftwebviewuiwebviewadblocksafari-content-blocker

How to disable all ads on webView swift


How to disable all ads like popups banner in webView for any URL.

I am using WKContentRuleListStore for block ads

I have use this json content block rule https://github.com/ShingoFukuyama/AdsBlock_WKWebView_for_iOS11/blob/master/AdsBlockWKWebView/adaway.json

All block rule assigning to listStore but it's not block all ads. It block some of the ads that mentioned in the json rule want to block all.

WKContentRuleListStore.default().lookUpContentRuleList(forIdentifier: ruleId1) { [weak self] (contentRuleList, error) in
}

I want to complete block ads on webView. Any help, suggestion appreciate.


Solution

  • To populate your content-blocking JSON file, you can check out several sources like EasyList, Adguard's filters or Brave lists (as suggested by @Mr Developer).

    There's also this utility that can help you generate Webkit block lists - abp2blocklist