In my content blocker I have a bunch of rules that block some content in Safari, but I want my users to be able to whiltelist a website so the blocker rules don't apply on that site.
I have something like this:
{
"action": {
"type":"css-display-none",
"selector":"a[href*='Bobbins']"
},
"trigger": {
"url-filter":".*"
}
},
{
"trigger": {
"url-filter": ".*",
"if-domain": ["*mydomain.com"]
},
"action": {
"type": "ignore-previous-rules"
}
}
I think that should block any a
link where the href
includes Bobbins
but not if the site is mydomain.com
. However, that simply doesn't work. It doesn't matter what I put in the array of domains to whitelist, it just doesn't apply it. In every case, the a
link is blocked.
How do you actually whitelist a website in a Safari content blocker?
Figured it out. The fix was literally staring me in the face!
The JSON I posted here was 100% correct, but what I had in my code was 1 character wrong.
Explanation:
"if-domain": ["*mydomain.com"]
is correct, but in my code I had an extra period in there:"if-domain": ["*.mydomain.com"]
, i.e. *.
.
You don't need a period in there; the *
covers that for you.