Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/cssInjection.js

Issue 29555932: Issue 5781 - Merge messages for regular and emulated element hiding filters (Closed)
Patch Set: Addressed comments Created Sept. 26, 2017, 9:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include.preload.js ('K') | « include.preload.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cssInjection.js
===================================================================
--- a/lib/cssInjection.js
+++ b/lib/cssInjection.js
@@ -21,6 +21,7 @@
const {RegExpFilter} = require("filterClasses");
const {ElemHide} = require("elemHide");
+const {ElemHideEmulation} = require("elemHideEmulation");
const {checkWhitelisted} = require("whitelisting");
const {extractHostFromFrame} = require("url");
const {port} = require("messaging");
@@ -43,6 +44,7 @@
port.on("elemhide.getSelectors", (msg, sender) =>
{
let selectors = [];
+ let emulatedPatterns = [];
let trace = devtools && devtools.hasPanel(sender.page);
let inject = !userStyleSheetsSupported;
@@ -50,18 +52,23 @@
RegExpFilter.typeMap.DOCUMENT |
RegExpFilter.typeMap.ELEMHIDE))
{
+ let hostname = extractHostFromFrame(sender.frame);
let specificOnly = checkWhitelisted(sender.page, sender.frame,
RegExpFilter.typeMap.GENERICHIDE);
+
selectors = ElemHide.getSelectorsForDomain(
- extractHostFromFrame(sender.frame),
+ hostname,
specificOnly ? ElemHide.SPECIFIC_ONLY : ElemHide.ALL_MATCHING
);
+
+ for (let filter of ElemHideEmulation.getRulesForDomain(hostname))
+ emulatedPatterns.push({selector: filter.selector, text: filter.text});
}
if (!inject && selectors.length > 0)
hideElements(sender.page.id, sender.frame.id, selectors);
- let response = {trace, inject};
+ let response = {trace, inject, emulatedPatterns};
if (trace || inject)
response.selectors = selectors;
« include.preload.js ('K') | « include.preload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld