EasyListParser is an iOS Framework for creating Safari Content Blocker lists from EasyList filters.
let easyListURI = "https://easylist-downloads.adblockplus.org/easyprivacy_nointernational.txt"
var blockerEntries: [ELBlockerEntry] = []
var blockerJson: String?
let maxEntries = 50000 // max allowed by Safari
let trustedDomains = ["www.reddit.com"]
if let easyListURL = NSURL(string: easyListURI) {
do {
let easyListContent = try String(contentsOfURL: easyListURL)
blockerEntries = ELListParser.parse(easyListContent, maxEntries: maxEntries, trustedDomains: trustedDomains)
blockerJson = try blockerEntries.serialize()
} catch let error as NSError {
print(error.localizedDescription)
}
}
EasyListParser is released under the MIT license. See LICENSE for details.