iOS 内容拦截器白名单网站

iOS Content Blocker Whitelist Website

在我的内容拦截器中,有没有办法防止某个网站上的广告拦截?例如,如果我想屏蔽除 The Verge 之外的所有网站上的广告,有没有办法避免我提供的屏蔽规则影响此页面?

我想你会做这样的事情。

 "action": {
  "type": “ignore-previous-rules”
  },
  "trigger": {
  “if-domain”: “theverge.com”
  }

一些不错的链接可以查看。

Safari Extensibility: Content Blocking and Shared Links

Safari Content Blocking in iOS 9: a tutorial by example

不幸的是,上述答案不正确有两个原因,url-filter 属性在触发器中是必需的,而 if-domain 属性必须是域数组,而不是单个值。经过大量试验和错误后,我找到了将网站列入白名单的有效解决方案。

{
    "trigger": {
        "url-filter": ".*",
        "if-domain": ["the verge.com"]
    },
    "action": {
        "type": "ignore-previous-rules"
    }
}

我能够找到关于使用上述答案导致各种错误的唯一文档是在此处搜索源代码:https://github.com/WebKit/webkit/tree/67985c34ffc405f69995e8a35f9c38618625c403/Source/WebCore/contentextensions

本文讲述解决方法http://comments.gmane.org/gmane.os.opendarwin.webkit.user/3971

{
    "action": {
        "type": "ignore-previous-rules"
    },
    "trigger": {
        "url-filter": ".*",
        "if-domain": ["*apple.com"]
    }
}