diff --git a/src/js/popup.js b/src/js/popup.js
index 3eec85f497..290bc02755 100644
--- a/src/js/popup.js
+++ b/src/js/popup.js
@@ -738,10 +738,13 @@ function refreshPopup() {
// if there are replaced widgets, get their names and append to that popup section
if (Object.keys(POPUP_DATA.replacedWidgets).length) {
- let name = POPUP_DATA.replacedWidgets.name;
- // prevent duplicate names from appearing, only append if it doesn't already exist
- if (!$('#instructions-widgets-description li:contains("' + name + '")').length) {
- $("#instructions-widgets-description").append("
" + name + "");
+ for (let widget in POPUP_DATA.replacedWidgets) {
+ POPUP_DATA.replacedWidgets[widget].forEach((widgetType) => {
+ // prevent duplicate names from appearing, only append if it doesn't already exist
+ if (!$('#instructions-widgets-description li:contains("' + widgetType + '")').length) {
+ $("#instructions-widgets-description").append("" + widgetType + "");
+ }
+ });
}
}
diff --git a/src/js/webrequest.js b/src/js/webrequest.js
index ca54268f42..e6f5c68009 100644
--- a/src/js/webrequest.js
+++ b/src/js/webrequest.js
@@ -34,7 +34,8 @@ let constants = require("constants"),
/************ Local Variables *****************/
let tempAllowlist = {},
- tempAllowedWidgets = {};
+ tempAllowedWidgets = {},
+ replacedWidgets = {};
/***************** Blocking Listener Functions **************/
@@ -882,6 +883,7 @@ function dispatcher(request, sender, sendResponse) {
"getBlockedFrameUrls",
"getReplacementButton",
"inspectLocalStorage",
+ "sendReplacedWidgetsToPopup",
"supercookieReport",
"unblockWidget",
];
@@ -1062,6 +1064,25 @@ function dispatcher(request, sender, sendResponse) {
break;
}
+ case "sendReplacedWidgetsToPopup": {
+ let tab_host;
+ // iframes send unreliable host responses, sender url and falsey frameId is to get top-level host
+ if (sender.frameId == 0 && sender.url) {
+ tab_host = sender.url;
+ }
+
+ // avoid setting undefined properties on local replaced widgets array, but establish a property for known host
+ if (!replacedWidgets[tab_host] && tab_host) {
+ replacedWidgets[tab_host] = [];
+ }
+
+ // only save widget name if it's not already present in local widgets array
+ if (!replacedWidgets[tab_host].includes(request.widgetName)) {
+ replacedWidgets[tab_host].push(request.widgetName);
+ }
+ break;
+ }
+
case "getPopupData": {
let tab_id = request.tabId;
@@ -1085,6 +1106,13 @@ function dispatcher(request, sender, sendResponse) {
}
}
+ // before sending response, remove old replaced widgets information from previous tabs
+ for (let host in replacedWidgets) {
+ if (!host.includes(tab_host)) {
+ delete replacedWidgets[host];
+ }
+ }
+
sendResponse({
cookieblocked,
criticalError: badger.criticalError,
@@ -1093,6 +1121,7 @@ function dispatcher(request, sender, sendResponse) {
isOnFirstParty: utils.firstPartyProtectionsEnabled(tab_host),
noTabData: false,
origins,
+ replacedWidgets: replacedWidgets,
settings: badger.getSettings().getItemClones(),
showLearningPrompt: badger.getPrivateSettings().getItem("showLearningPrompt"),
showWebRtcDeprecation: !!badger.getPrivateSettings().getItem("showWebRtcDeprecation"),