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

Easylist to Adblock Script #402

Closed
jhreis opened this issue Nov 14, 2018 · 1 comment
Closed

Easylist to Adblock Script #402

jhreis opened this issue Nov 14, 2018 · 1 comment

Comments

@jhreis
Copy link
Contributor

@jhreis jhreis commented Nov 14, 2018

Rules come to us in the format:

"text","count"
"||01net.com/track/",118
"/0/ads/*",10
"_120_60.",29
"_120_600_",1
"_120_600.",3
"/120_600.",39
"_120x240.",1
"-120x240.",31

And need to be massaged into a format that the iOS content blocking extension API wants:

e.g.

{
    "trigger": {
        "url-filter": "^[^:]+:(//)?.*/[0i]/ads/",
        "resource-type": [
            "image",
            "style-sheet",
            "script",
            "font",
            "media",
            "raw"
        ]
    },
    "action": {
        "type": "block"
    }
},

This adblockplus script does a decent job but is still shy of what is needed. More specifically, the writeup that @kylehickinson created (copied verbatim):

Library issues:

  • Doesn't deal with exception/ignore rules (prefixed: @@||)

    • Creates a rule with the url-filter literally containing escaped @@|| characters
  • Doesn't deal with items that are surrounded with quotes ("{rule}")

    • Creates a rule with the url-filter literally containing quotes
  • When no type is provided I would assume resource-type could be omitted instead of including most of the types. Maybe there's a reason for this?

    • Creates a rule with the following resource-types: "image", "style-sheet", "script", "font", "media", and "raw". Missing: "document", "svg-document"
  • Rules with wildcard suffixes don't generate regex for it? /0/ads/* -> ^[^:]+:(//)?.*/[0i]/ads/

    • Shouldn't it be ^[^:]+:(//)?.*/[0i]/ads/.+ or at least ^[^:]+:(//)?.*/[0i]/ads/.*. On top of that, what's with the [0i]? Isn't /0/ads/.+ enough?
  • Not sure how it handles CSS because our subset of rules doesn't include any (further testing required)

  • It seems to be applying case-sensitivity based on the use of a separator character? ||quantcount.com^$third-party creates this:

    {
      "trigger": {
        "url-filter": "^[^:]+:(//)?([^/]+\\.)?quantcount\\.com([^-_.%a-z0-9].*)?$",
        "url-filter-is-case-sensitive": true,
        "resource-type": [
          "image",
          "style-sheet",
          "script",
          "font",
          "media",
          "raw",
          "document"
        ],
        "load-type": [
          "third-party"
        ],
        "unless-top-url": [
          "^[^:]+:(//)?([^/]+\\.)?quantcount\\.com([^-_.%a-z0-9].*)?$"
        ],
        "top-url-filter-is-case-sensitive": true
      },
      "action": {
        "type": "block"
      }
    }

    Expected:

    {
      "trigger": {
        "url-filter": "^[^:]+:(//)?([^/]+\\.)?quantcount\\.com$",
        "load-type": [
          "third-party"
        ],
        "unless-top-url": [
          "[^:]+:(//)?([^/]+\\.)?quantcount\\.com"
        ]
      },
      "action": {
        "type": "block"
      }
    }

Other resources:
adblock rule format explainer
adblock static ruleset
Apple format docs

@jhreis
Copy link
Contributor Author

@jhreis jhreis commented Dec 5, 2018

@jhreis jhreis closed this Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.