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

Unified Diff: include.preload.js

Issue 29738592: Issue 6507 - Inject style sheet proactively from background page (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created March 31, 2018, 5:47 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
« no previous file with comments | « composer.postload.js ('k') | lib/cssInjection.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.preload.js
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -495,52 +495,54 @@
browser.runtime.sendMessage({
type: "devtools.traceElemHide",
selectors: [],
filters
});
}
},
- apply()
+ apply({trace, inline, inlineEmulated, selectors, emulatedPatterns} = {})
{
- browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response =>
- {
- if (this.tracer)
- this.tracer.disconnect();
- this.tracer = null;
+ if (this.tracer)
+ this.tracer.disconnect();
+ this.tracer = null;
- if (response.trace)
- this.tracer = new ElementHidingTracer();
+ if (trace)
+ this.tracer = new ElementHidingTracer();
- this.inline = response.inline;
- this.inlineEmulated = !!response.inlineEmulated;
+ this.inline = inline;
+ this.inlineEmulated = !!inlineEmulated;
- if (this.inline)
- this.addSelectorsInline(response.selectors, "standard");
+ if (this.inline)
+ this.addSelectorsInline(selectors, "standard");
- if (this.tracer)
- this.tracer.addSelectors(response.selectors);
+ if (this.tracer)
+ this.tracer.addSelectors(selectors);
- // Prefer CSS selectors for -abp-has and -abp-contains unless the
- // background page has asked us to use inline styles.
- this.elemHideEmulation.useInlineStyles = this.inline ||
- this.inlineEmulated;
+ // Prefer CSS selectors for -abp-has and -abp-contains unless the
+ // background page has asked us to use inline styles.
+ this.elemHideEmulation.useInlineStyles = this.inline ||
+ this.inlineEmulated;
- this.elemHideEmulation.apply(response.emulatedPatterns);
- });
+ this.elemHideEmulation.apply(emulatedPatterns);
}
};
if (document instanceof HTMLDocument)
{
checkSitekey();
elemhide = new ElemHide();
- elemhide.apply();
+
+ browser.runtime.onMessage.addListener(message =>
+ {
+ if (message.type == "elemhide.apply")
+ elemhide.apply(message);
+ });
document.addEventListener("error", event =>
{
checkCollapse(event.target);
}, true);
document.addEventListener("load", event =>
{
« no previous file with comments | « composer.postload.js ('k') | lib/cssInjection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld