@@ -34,7 +34,8 @@ let constants = require("constants"),
34
34
35
35
/************ Local Variables *****************/
36
36
let tempAllowlist = { } ,
37
- tempAllowedWidgets = { } ;
37
+ tempAllowedWidgets = { } ,
38
+ replacedWidgets = { } ;
38
39
39
40
/***************** Blocking Listener Functions **************/
40
41
@@ -882,6 +883,7 @@ function dispatcher(request, sender, sendResponse) {
882
883
"getBlockedFrameUrls" ,
883
884
"getReplacementButton" ,
884
885
"inspectLocalStorage" ,
886
+ "sendReplacedWidgetsToPopup" ,
885
887
"supercookieReport" ,
886
888
"unblockWidget" ,
887
889
] ;
@@ -1062,6 +1064,25 @@ function dispatcher(request, sender, sendResponse) {
1062
1064
break ;
1063
1065
}
1064
1066
1067
+ case "sendReplacedWidgetsToPopup" : {
1068
+ let tab_host ;
1069
+ // iframes send unreliable host responses, sender url and falsey frameId is to get top-level host
1070
+ if ( sender . frameId == 0 && sender . url ) {
1071
+ tab_host = sender . url ;
1072
+ }
1073
+
1074
+ // avoid setting undefined properties on local replaced widgets array, but establish a property for known host
1075
+ if ( ! replacedWidgets [ tab_host ] && tab_host ) {
1076
+ replacedWidgets [ tab_host ] = [ ] ;
1077
+ }
1078
+
1079
+ // only save widget name if it's not already present in local widgets array
1080
+ if ( ! replacedWidgets [ tab_host ] . includes ( request . widgetName ) ) {
1081
+ replacedWidgets [ tab_host ] . push ( request . widgetName ) ;
1082
+ }
1083
+ break ;
1084
+ }
1085
+
1065
1086
case "getPopupData" : {
1066
1087
let tab_id = request . tabId ;
1067
1088
@@ -1085,6 +1106,13 @@ function dispatcher(request, sender, sendResponse) {
1085
1106
}
1086
1107
}
1087
1108
1109
+ // before sending response, remove old replaced widgets information from previous tabs
1110
+ for ( let host in replacedWidgets ) {
1111
+ if ( ! host . includes ( tab_host ) ) {
1112
+ delete replacedWidgets [ host ] ;
1113
+ }
1114
+ }
1115
+
1088
1116
sendResponse ( {
1089
1117
cookieblocked,
1090
1118
criticalError : badger . criticalError ,
@@ -1093,6 +1121,7 @@ function dispatcher(request, sender, sendResponse) {
1093
1121
isOnFirstParty : utils . firstPartyProtectionsEnabled ( tab_host ) ,
1094
1122
noTabData : false ,
1095
1123
origins,
1124
+ replacedWidgets : replacedWidgets ,
1096
1125
settings : badger . getSettings ( ) . getItemClones ( ) ,
1097
1126
showLearningPrompt : badger . getPrivateSettings ( ) . getItem ( "showLearningPrompt" ) ,
1098
1127
showWebRtcDeprecation : ! ! badger . getPrivateSettings ( ) . getItem ( "showWebRtcDeprecation" ) ,
0 commit comments