Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit 52811f8

Browse files
committed
Don't block ad hosts if they are 1st party
Fix #1353 Auditors: @bbondy
1 parent dd3c38e commit 52811f8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/adBlock.js

+6
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ let mapFilterType = {
2727
const startAdBlocking = (adblock, resourceName, shouldCheckMainFrame) => {
2828
Filtering.registerBeforeRequestFilteringCB((details) => {
2929
const firstPartyUrl = URL.parse(details.firstPartyUrl)
30+
let firstPartyUrlHost = firstPartyUrl.hostname || ''
31+
if (firstPartyUrlHost.startsWith('www.')) {
32+
firstPartyUrlHost = firstPartyUrlHost.substring(4)
33+
}
34+
const urlHost = URL.parse(details.url).hostname
3035
const cancel = firstPartyUrl.protocol &&
3136
(shouldCheckMainFrame || details.resourceType !== 'mainFrame') &&
3237
firstPartyUrl.protocol.startsWith('http') &&
3338
mapFilterType[details.resourceType] !== undefined &&
39+
urlHost !== firstPartyUrlHost &&
3440
adblock.matches(details.url, mapFilterType[details.resourceType], firstPartyUrl.host)
3541
return {
3642
cancel,

0 commit comments

Comments
 (0)