3

In my content blocker, is there a way to prevent ad-blocking on a certain website? For example, if I want to block ads on all websites besides The Verge, is there a way to prevent the blocking rules I provided from affecting this page?

fbailey
  • 303
  • 5
  • 17
erdekhayser
  • 6,537
  • 2
  • 37
  • 69

3 Answers3

6

The above answer is unfortunately incorrect for two reasons, the url-filter attribute is required in the trigger and the if-domain attribute must be an array of domain(s), not a single value. After a lot of trial and error I have found a working solution to whitelist a website.

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

The only documentation I was able to find on what was causing various errors using the above answer was scouring the source code here: https://github.com/WebKit/webkit/tree/67985c34ffc405f69995e8a35f9c38618625c403/Source/WebCore/contentextensions

fbailey
  • 303
  • 5
  • 17
3

this article tells the solution http://comments.gmane.org/gmane.os.opendarwin.webkit.user/3971

{
    "action": {
        "type": "ignore-previous-rules"
    },
    "trigger": {
        "url-filter": ".*",
        "if-domain": ["*apple.com"]
    }
}
Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87
Michael Yang
  • 1,403
  • 2
  • 18
  • 27
  • Please don't add "thanks" or "this answer worked" as answers. Invest some time in the site and you will gain sufficient [privileges](http://stackoverflow.com/privileges/vote-up) to upvote answers you like, which is the Stack Overflow way of saying thank you. – Nathan Tuggy Dec 11 '15 at 04:40
1

I think you would do something like this.

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

Some good links to check out.

Safari Extensibility: Content Blocking and Shared Links

Safari Content Blocking in iOS 9: a tutorial by example

cr_wells
  • 11
  • 1