You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Fernando Bunn 930f9cfa99 WIP: Documentation Draft 2 weeks ago
.github Set up GitHub Actions (#8) 3 weeks ago
.swiftpm/xcode Add a header template. 2 years ago
Sources Set up GitHub Actions (#8) 3 weeks ago
Tests/TrackerRadarKitTests Set up GitHub Actions (#8) 3 weeks ago
.gitignore add validator tool (#4) 1 year ago
.swiftlint.yml Update SwiftLint config to exclude the build directory. 2 years ago
LICENSE Initial commit 2 years ago
Package.resolved add validator tool (#4) 1 year ago
Package.swift add validator tool (#4) 1 year ago
README.md WIP: Documentation Draft 2 weeks ago
bitrise.yml Add bitrise.yml. 2 years ago

README.md

TrackerRadarKit

We are hiring!

DuckDuckGo is growing fast and we continue to expand our fully distributed team. We embrace diverse perspectives, and seek out passionate, self-motivated people, committed to our shared vision of raising the standard of trust online. If you are a senior software engineer capable in either iOS or Android, visit our careers page to find out more about our openings!

Building

TrackerRadarKit has one explicit dependency (https://github.com/apple/swift-argument-parser) that is automatically resolved when installing the swift package in Xcode. It can be added to an Xcode project as a swift package dependency or be used as an imported Swift package.

It can be built manually two ways:

  1. Build the TrackerRadarKit scheme by opening the Swift package in Xcode
  2. Run swift build -c release to build a release binary

SwiftLint

We use SwiftLint for enforcing Swift style and conventions, so you'll need to install it.

Validator

The Validator tool can be used to validate that Tracker Radar data can be parsed, transformed and compiled by WebKit's content rule list store. As such, it requires macos 10.13 to run.

To build, check out the code and run from the project root:

  • swift build

To run, execute the following from the project root:

  • .build/debug/Validator

Installation

We recommend the use of Swift Package Manager

How to block trackers

In order to block content on the web view you need to compile a content rule list using Apple's WKContentRuleListStore. TrackerRadarKit allows you to generate this list using DuckDuckGo's Tracker Radar as source. The main structs you'll need to use to create a content rule lists are:

Example

let trackerData: TrackerData = ...
let allowList: [String] = ...

let blockerBuilder = ContentBlockerRulesBuilder(trackerData: trackerData)
let rules = blockerBuilder.buildRules(withExceptions: allowList)

let data: Data

do {
    data = try JSONEncoder().encode(rules)
} catch {
    // Handle Error
}

let ruleList = String(data: data, encoding: .utf8)!

WKContentRuleListStore.default()
    .compileContentRuleList(forIdentifier: settings.ruleListIdentifier,
                            encodedContentRuleList: ruleList) { list, error in
    
        // return WKContentRuleList or error
    }

License

DuckDuckGo is distributed under the Apache 2.0 license.