@@ -112,15 +112,17 @@ function getCnameAliases(domain) {
112112 */
113113function makeDnrBlockRule ( domain , priority = constants . DNR_BLOCK ) {
114114 let id = badger . getDynamicRuleId ( ) ,
115- base = getBaseDomain ( domain ) ;
115+ base = getBaseDomain ( domain ) ,
116+ excluded_domains_prop = ( constants . DNR_HAS_EXCLUDEDTOPDOMAINS ?
117+ 'excludedTopDomains' : 'excludedInitiatorDomains' ) ;
116118
117119 let action = {
118120 type : 'block'
119121 } ;
120122
121123 let condition = {
122124 requestDomains : [ domain ] ,
123- excludedTopDomains : [ base ]
125+ [ excluded_domains_prop ] : [ base ]
124126 } ;
125127
126128 let cnames = getCnameAliases ( domain ) ;
@@ -132,7 +134,7 @@ function makeDnrBlockRule(domain, priority = constants.DNR_BLOCK) {
132134
133135 let mdfpList = mdfp . getEntityList ( base ) ;
134136 if ( mdfpList . length ) {
135- condition . excludedTopDomains = mdfpList ;
137+ condition [ excluded_domains_prop ] = mdfpList ;
136138 }
137139
138140 let rule = { id, action, condition, priority } ;
@@ -150,7 +152,9 @@ function makeDnrBlockRule(domain, priority = constants.DNR_BLOCK) {
150152 */
151153function makeDnrCookieblockRule ( domain , priority = constants . DNR_COOKIEBLOCK_HEADERS ) {
152154 let id = badger . getDynamicRuleId ( ) ,
153- base = getBaseDomain ( domain ) ;
155+ base = getBaseDomain ( domain ) ,
156+ excluded_domains_prop = ( constants . DNR_HAS_EXCLUDEDTOPDOMAINS ?
157+ 'excludedTopDomains' : 'excludedInitiatorDomains' ) ;
154158
155159 let action = {
156160 type : 'modifyHeaders' ,
@@ -160,7 +164,7 @@ function makeDnrCookieblockRule(domain, priority = constants.DNR_COOKIEBLOCK_HEA
160164
161165 let condition = {
162166 requestDomains : [ domain ] ,
163- excludedTopDomains : [ base ]
167+ [ excluded_domains_prop ] : [ base ]
164168 } ;
165169
166170 let cnames = getCnameAliases ( domain ) ;
@@ -172,7 +176,7 @@ function makeDnrCookieblockRule(domain, priority = constants.DNR_COOKIEBLOCK_HEA
172176
173177 let mdfpList = mdfp . getEntityList ( base ) ;
174178 if ( mdfpList . length ) {
175- condition . excludedTopDomains = mdfpList ;
179+ condition [ excluded_domains_prop ] = mdfpList ;
176180 }
177181
178182 let rule = { id, action, condition, priority } ;
@@ -229,7 +233,9 @@ function makeDnrAllowRule(domain, priority = constants.DNR_COOKIEBLOCK_ALLOW) {
229233function makeDnrSurrogateRule ( id , script_host , surrogate_path , extraConditions ,
230234 priority = constants . DNR_SURROGATE_REDIRECT , resource_type = 'script' ) {
231235
232- let script_base = getBaseDomain ( script_host ) ;
236+ let script_base = getBaseDomain ( script_host ) ,
237+ excluded_domains_prop = ( constants . DNR_HAS_EXCLUDEDTOPDOMAINS ?
238+ 'excludedTopDomains' : 'excludedInitiatorDomains' ) ;
233239
234240 let rule = {
235241 id,
@@ -243,13 +249,13 @@ function makeDnrSurrogateRule(id, script_host, surrogate_path, extraConditions,
243249 condition : {
244250 requestDomains : [ script_host ] ,
245251 resourceTypes : [ resource_type ] ,
246- excludedTopDomains : [ script_base ]
252+ [ excluded_domains_prop ] : [ script_base ]
247253 }
248254 } ;
249255
250256 let mdfpList = mdfp . getEntityList ( script_base ) ;
251257 if ( mdfpList . length ) {
252- rule . condition . excludedTopDomains = mdfpList ;
258+ rule . condition [ excluded_domains_prop ] = mdfpList ;
253259 }
254260
255261 if ( extraConditions ) {
@@ -336,11 +342,13 @@ function getDnrSurrogateRules(domain, is_user_action) {
336342 */
337343function makeDnrFpScriptBlockRule ( id , domain , path ) {
338344 let base = getBaseDomain ( domain ) ,
339- excludedTopDomains = [ base ] ;
345+ excludedDomains = [ base ] ,
346+ excluded_domains_prop = ( constants . DNR_HAS_EXCLUDEDTOPDOMAINS ?
347+ 'excludedTopDomains' : 'excludedInitiatorDomains' ) ;
340348
341349 let mdfpList = mdfp . getEntityList ( base ) ;
342350 if ( mdfpList . length ) {
343- excludedTopDomains = mdfpList ;
351+ excludedDomains = mdfpList ;
344352 }
345353
346354 return {
@@ -351,7 +359,7 @@ function makeDnrFpScriptBlockRule(id, domain, path) {
351359 requestDomains : [ domain ] ,
352360 resourceTypes : [ 'script' ] ,
353361 urlFilter : '||' + domain + path + '^' ,
354- excludedTopDomains
362+ [ excluded_domains_prop ] : excludedDomains
355363 }
356364 } ;
357365}
@@ -763,6 +771,9 @@ async function updateWidgetSiteAllowlistRules(widgetSiteAllowlist) {
763771 return ( r . priority == constants . DNR_WIDGET_ALLOW_ALL ) ;
764772 } ) . map ( r => r . id ) ;
765773
774+ let domains_prop = ( constants . DNR_HAS_TOPDOMAINS ?
775+ 'topDomains' : 'initiatorDomains' ) ;
776+
766777 for ( let site_host in widgetSiteAllowlist ) {
767778 let widgetDomains = widgetSiteAllowlist [ site_host ] . map ( widget_name => {
768779 let widget = badger . widgetList . find ( w => w . name == widget_name ) ;
@@ -779,7 +790,7 @@ async function updateWidgetSiteAllowlistRules(widgetSiteAllowlist) {
779790 priority : constants . DNR_WIDGET_ALLOW_ALL ,
780791 action : { type : 'allowAllRequests' } ,
781792 condition : {
782- topDomains : [ site_host ] ,
793+ [ domains_prop ] : [ site_host ] ,
783794 requestDomains : [ domain ] ,
784795 resourceTypes : [ 'sub_frame' ]
785796 }
@@ -797,7 +808,7 @@ async function updateWidgetSiteAllowlistRules(widgetSiteAllowlist) {
797808 priority : constants . DNR_WIDGET_ALLOW_ALL ,
798809 action : { type : 'allow' } ,
799810 condition : {
800- topDomains : [ site_host ] ,
811+ [ domains_prop ] : [ site_host ] ,
801812 requestDomains : [ domain ]
802813 }
803814 } ;
@@ -875,6 +886,9 @@ async function updateDntSignalHeaderRules() {
875886 } ) . map ( r => r . id ) ;
876887
877888 if ( badger . getSettings ( ) . getItem ( 'sendDNTSignal' ) ) {
889+ let excluded_domains_prop = ( constants . DNR_HAS_EXCLUDEDTOPDOMAINS ?
890+ 'excludedTopDomains' : 'excludedInitiatorDomains' ) ;
891+
878892 // set DNT and Sec-GPC on top-level documents
879893 let rule = {
880894 id : badger . getDynamicRuleId ( ) ,
@@ -898,7 +912,7 @@ async function updateDntSignalHeaderRules() {
898912 let exceptionSites = Object . keys (
899913 badger . getPrivateSettings ( ) . getItem ( "gpcDisabledSites" ) ) ;
900914 if ( exceptionSites . length ) {
901- rule . condition . excludedTopDomains = exceptionSites ;
915+ rule . condition [ excluded_domains_prop ] = exceptionSites ;
902916 }
903917 opts . addRules . push ( rule ) ;
904918
@@ -922,7 +936,7 @@ async function updateDntSignalHeaderRules() {
922936 condition : { }
923937 } ;
924938 if ( exceptionSites . length ) {
925- rule . condition . excludedTopDomains = exceptionSites ;
939+ rule . condition [ excluded_domains_prop ] = exceptionSites ;
926940 }
927941 opts . addRules . push ( rule ) ;
928942 }
0 commit comments