Using EasyList Syntax for iOS Safari Content Blocker

Posting here is no longer possible, please use the forum of a filter list project, such as EasyList
Locked
justin
Posts: 1
Joined: Sun Aug 30, 2015 6:41 am

Using EasyList Syntax for iOS Safari Content Blocker

Post by justin »

Hi guys,
I'm Justin. With some fellow developer, we made http://openadblock.org. It is a FOSS. We are using a JSON content blocker. I am wondering if someone could be able to explain me the syntax of EasyList so that I can translate it into JSON. I am a beginner a this. I know basic java and some web development. If someone could explain me how you block thing and how your list is applied, I could be able to write a java program that would transfert it in a JSON.
Thanks,
Justin

P.s. you can try our beta or fork us on github!
lewisje
Posts: 2743
Joined: Mon Jun 14, 2010 12:07 pm

Re: Using EasyList Syntax for iOS Safari Content Blocker

Post by lewisje »

It would be even better if you wrote the conversion into the binary itself (I presume that you would use Swift, rather than Java, to do it), so that your content-blocker will fetch the lists and convert all convertible rules to JSON.

I'm not sure whether you've seen this blog post yet, but here's a simple example of a Safari content-blocker: http://murphyapps.co/blog/2015/6/24/an- ... r-in-ios-9
This shows how the blocking rules will look in JSON: https://gist.github.com/CraftyDeano/777 ... b3d8d50f25

It looks as if hiding rules are the easiest to convert: <domain>,<domain2>##<selector> would translate to

Code: Select all

{
  "action": {
    "type": "css-display-none",
    "selector": "<selector>"
  },
  "trigger": {
    "url-filter": ".*",
    "if-domain": [
      "<domain>",
      "*.<domain>",
      "<domain2>",
      "*.<domain2>"
    ]
  }
}
and /ads.js$script,stylesheet,image,font,third-party,domain=<domain>|<domain2> would translate to

Code: Select all

{
  "action": {
    "type": "block"
  },
  "trigger": {
    "url-filter": ".*\/ads\.js.*"
    "resource-type": [
      "script",
      "style-sheet",
      "image",
      "font"
    ],
    "load-type": ["third-party"],
    "if-domain": [
      "<domain>",
      "*.<domain>",
      "<domain2>",
      "*.<domain2>"
    ]
  }
}
You might want to look into adblock2privoxy (built in Haskell) and our own Python script for generating TPLs for IE 9-11 (though we had an older one made with Perl) for ideas about how to make ABP syntax best fit the capabilities of the new iOS content blockers.
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
Locked