Skip to content

Commit

Permalink
For third party requests differentiate if they are affiliated with fi…
Browse files Browse the repository at this point in the history
…rst party
  • Loading branch information
miasma13 committed Sep 24, 2024
1 parent cc3629f commit 6247837
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,13 @@ open class ContentBlockerRulesUserScript: NSObject, UserScript {
!isFirstParty(requestURL: trackerUrlString, websiteURL: pageUrlStr) else { return }

let entity = currentTrackerData.findEntity(forHost: requestETLDp1) ?? Entity(displayName: requestETLDp1, domains: nil, prevalence: nil)
let isAffiliated = resolver.isPageAffiliatedWithTrackerEntity(pageUrlString: pageUrlStr, trackerEntity: entity)

let thirdPartyRequest = DetectedRequest(url: trackerUrlString,
eTLDplus1: requestETLDp1,
knownTracker: nil,
entity: entity,
state: .allowed(reason: .otherThirdPartyRequest),
state: .allowed(reason: isAffiliated ? .ownedByFirstParty : .otherThirdPartyRequest),
pageUrl: pageUrlStr)
delegate.contentBlockerRulesUserScript(self, detectedThirdPartyRequest: thirdPartyRequest)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class TrackerResolver {
pageUrl: pageUrlString)
}

private func isPageAffiliatedWithTrackerEntity(pageUrlString: String, trackerEntity: Entity) -> Bool {
public func isPageAffiliatedWithTrackerEntity(pageUrlString: String, trackerEntity: Entity) -> Bool {
guard let pageHost = URL(string: pageUrlString)?.host,
let pageEntity = tds.findEntity(forHost: pageHost)
else { return false }
Expand Down

0 comments on commit 6247837

Please sign in to comment.