Consider using `if-top-url/unless-top-url` in newer Safari versions
Example:
if-domain: [ "example.org", "*example.org" ] --> if-top-url: [ "^[htpsw]+:\\/\\/://([a-z0-9-]+\\.)?example.org/" ]
Ideally, we'll simply need a JSON built with this new approach. Once we have it, we'll be able to see how long it takes Safari to compile such a content blocker and whether it's faster or not.
Regex from the subject is not correct, I've used the next one.
{
"trigger": {
"url-filter": ".*",
"if-top-url": ["^[htpsw]+:\\/\\/([a-z0-9-]+\\.)?example.org"]
},
"action": {
"type": "css-display-none",
"selector": ".banner"
}
}
I've generated random 50000 rules like example.org##.banner and reloaded content blocker.
Rules with if-domain trigger were loaded faster
if-domain- 2.2 secondsif-top-url- 4.2 seconds
After that, I've tried the filter with real rules https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_2_English/filter.txt
And again rules with if-domain trigger were loaded faster
if-domain- 6-8 secondsif-top-url- 9-12 seconds
With both kinds of triggers I didn't notice that the browser become slowly
We should do that experiment one more time after iOS 15 is out and we can create content blockers with 150k rules. I am not yet sure how important this slowdown will be.