Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using if-top-url/unless-top-url in newer Safari versions #20

Open
ameshkov opened this issue May 21, 2021 · 3 comments
Open

Consider using if-top-url/unless-top-url in newer Safari versions #20

ameshkov opened this issue May 21, 2021 · 3 comments
Labels
enhancement New feature or request Priority: P3

Comments

@ameshkov
Copy link
Member

ameshkov commented May 21, 2021

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.

@ameshkov ameshkov added the enhancement New feature or request label May 21, 2021
@ameshkov ameshkov changed the title Experiment with replacing if-domain and unless-domain to if-top-url and unless-top-url Experiment with replacing if-domain/unless-domain with if-top-url/unless-top-url May 21, 2021
@maximtop
Copy link
Contributor

maximtop commented Jun 21, 2021

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 seconds
  • if-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 seconds
  • if-top-url - 9-12 seconds

With both kinds of triggers I didn't notice that the browser become slowly

@ameshkov
Copy link
Member Author

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.

@adguard-bot adguard-bot changed the title Experiment with replacing if-domain/unless-domain with if-top-url/unless-top-url Consider using if-top-url/unless-top-url in newer Safari versions Dec 10, 2024
@ameshkov
Copy link
Member Author

UPDATE: Safari 18 supports using both if-top-url and if-domain in the same list.

This changes a lot.

For instance, we can use if-top-url for domain wildcards and regex domains ($domain=google.*, $domain=/.*\\.org/).
Additionally, it opens the path to support non-basic rule modifiers, i.e. [$path=/path]example.org##banner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Priority: P3
Projects
None yet
Development

No branches or pull requests

4 participants