Skip to content

Commit

Permalink
Ignore popup resources for top level default block
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayterDev committed May 17, 2024
1 parent 2a79006 commit 4b87ff8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sources/TrackerRadarKit/ContentBlockerRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public struct ContentBlockerRule: Codable, Hashable {
return Trigger(urlFilter: filter, unlessDomain: urls, ifDomain: nil, resourceType: nil, loadType: loadTypes, loadContext: nil)
}

public static func trigger(urlFilter filter: String, resourceType types: [ResourceType]?, loadTypes: [LoadType]?, loadContext: [LoadContext]?) -> Trigger {

Check failure on line 94 in Sources/TrackerRadarKit/ContentBlockerRule.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Line Length Violation: Line should be 150 characters or less; currently it has 163 characters (line_length)
return Trigger(urlFilter: filter, unlessDomain: nil, ifDomain: nil, resourceType: types, loadType: loadTypes, loadContext: loadContext)
}

public static func trigger(urlFilter filter: String, ifDomain domains: [String]?, resourceType types: [ResourceType]?) -> Trigger {
return Trigger(urlFilter: filter, unlessDomain: nil, ifDomain: domains, resourceType: types, loadType: [ .thirdParty ], loadContext: nil)
}
Expand Down
8 changes: 7 additions & 1 deletion Sources/TrackerRadarKit/ContentBlockerRulesBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ public struct ContentBlockerRulesBuilder {
return [ ContentBlockerRule(trigger: .trigger(urlFilter: urlFilter,
unlessDomain: trackerData.relatedDomains(for: tracker.owner)?.wildcards(),
loadTypes: loadTypes),
action: .block()) ]
action: .block()),
ContentBlockerRule(trigger: .trigger(urlFilter: urlFilter,
resourceType: [.popup],
loadTypes: loadTypes,
loadContext: [.topFrame]),
action: .ignorePreviousRules())
]
}

private func buildRules(fromRule r: KnownTracker.Rule,
Expand Down

0 comments on commit 4b87ff8

Please sign in to comment.