Index: lib/devtools.js |
=================================================================== |
--- a/lib/devtools.js |
+++ b/lib/devtools.js |
@@ -19,9 +19,7 @@ |
const {RegExpFilter, |
WhitelistFilter, |
- ElemHideFilter, |
- ElemHideEmulationFilter} = require("filterClasses"); |
- |
+ ElemHideFilter} = require("filterClasses"); |
const {SpecialSubscription} = require("subscriptionClasses"); |
const {FilterStorage} = require("filterStorage"); |
const {defaultMatcher} = require("matcher"); |
@@ -150,10 +148,11 @@ |
* Logs active element hiding filters to the devtools panel. |
* |
* @param {Page} page The page the elements were hidden on |
- * @param {string[]} selectors The CSS selectors of active elemhide filters |
+ * @param {string[]} selectors The selectors of applied ElemHideFilters |
+ * @param {string[]} filters The text of applied ElemHideEmulationFilters |
* @param {string} docDomain The IDN-decoded hostname of the document |
*/ |
-function logHiddenElements(page, selectors, docDomain) |
+function logHiddenElements(page, selectors, filters, docDomain) |
{ |
let panel = getActivePanel(page); |
if (panel) |
@@ -165,15 +164,16 @@ |
for (let filter of subscription.filters) |
{ |
- if (!(filter instanceof ElemHideFilter) && |
- !(filter instanceof ElemHideEmulationFilter)) |
- continue; |
- if (selectors.indexOf(filter.selector) == -1) |
- continue; |
- if (!filter.isActiveOnDomain(docDomain)) |
- continue; |
+ // We only know the exact filter in case of element hiding emulation. |
+ // For regular element hiding filters, the content script only knows |
+ // the selector, so we have to find a filter that has an identical |
+ // selector and is active on the domain the match was reported from. |
+ let isActiveElemHideFilter = filter instanceof ElemHideFilter && |
+ selectors.includes(filter.selector) && |
+ filter.isActiveOnDomain(docDomain); |
- addRecord(panel, {type: "ELEMHIDE", docDomain}, filter); |
+ if (isActiveElemHideFilter || filters.includes(filter.text)) |
+ addRecord(panel, {type: "ELEMHIDE", docDomain}, filter); |
} |
} |
} |
@@ -380,7 +380,7 @@ |
port.on("devtools.traceElemHide", (message, sender) => |
{ |
logHiddenElements( |
- sender.page, message.selectors, |
+ sender.page, message.selectors, message.filters, |
extractHostFromFrame(sender.frame) |
); |
}); |