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 emulated = []; |
Manish Jethani
2017/09/26 11:50:18
How about we call this emulationPatterns, similar
Sebastian Noack
2017/09/26 21:50:40
Done.
|
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); |
Manish Jethani
2017/09/26 11:50:18
I notice that this is a change in behavior, the ol
Sebastian Noack
2017/09/26 21:50:40
You are right, and extractHostFromFrame() should b
|
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)) |
+ emulated.push({selector: filter.selector, text: filter.text}); |
Manish Jethani
2017/09/26 11:50:18
Just an idea, this could be written idiomatically
Sebastian Noack
2017/09/26 21:50:40
This will result in less efficient code for two re
Manish Jethani
2017/09/26 22:45:18
Fair enough.
I just checked on both Node.js and C
|
} |
if (!inject && selectors.length > 0) |
hideElements(sender.page.id, sender.frame.id, selectors); |
- let response = {trace, inject}; |
+ let response = {trace, inject, emulated}; |
Manish Jethani
2017/09/26 11:50:18
Maybe not as part of this very change, but we shou
Sebastian Noack
2017/09/26 21:50:40
It seems you misunderstand the concept of emulatio
Manish Jethani
2017/09/26 22:45:18
Yes, it seems I misunderstood. I was thinking we c
|
if (trace || inject) |
response.selectors = selectors; |