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

Unified Diff: include.preload.js

Issue 29737561: Issue 6539, 6782 - Implement support for snippets (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Rename ContentFiltering to Content Created July 19, 2018, 1:21 a.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
Index: include.preload.js
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -17,17 +17,17 @@
"use strict";
let {splitSelector} = require("./adblockpluscore/lib/common");
let {ElemHideEmulation} =
require("./adblockpluscore/lib/content/elemHideEmulation");
// This variable is also used by our other content scripts.
-let elemhide;
+let content;
const typeMap = new Map([
["img", "IMAGE"],
["input", "IMAGE"],
["picture", "IMAGE"],
["audio", "MEDIA"],
["video", "MEDIA"],
["frame", "SUBDOCUMENT"],
@@ -221,17 +221,17 @@
{
if (collapse)
{
if (selector)
{
if (!collapsingSelectors.has(selector))
{
collapsingSelectors.add(selector);
- elemhide.addSelectors([selector], null, "collapsing", true);
+ content.addSelectors([selector], null, "collapsing", true);
}
}
else
{
hideElement(element);
}
}
}
@@ -389,30 +389,30 @@
disconnect()
{
document.removeEventListener("DOMContentLoaded", this.trace);
this.observer.disconnect();
clearTimeout(this.timeout);
}
};
-function ElemHide()
+function Content()
{
this.shadow = this.createShadowTree();
this.styles = new Map();
this.tracer = null;
this.inline = true;
this.inlineEmulated = true;
this.elemHideEmulation = new ElemHideEmulation(
this.addSelectors.bind(this),
this.hideElements.bind(this)
);
}
-ElemHide.prototype = {
+Content.prototype = {
selectorGroupSize: 1024,
createShadowTree()
{
// Use Shadow DOM if available as to not mess with with web pages that
// rely on the order of their own <style> tags (#309). However, creating
// a shadow root breaks running CSS transitions. So we have to create
// the shadow root before transistions might start (#452).
@@ -553,19 +553,24 @@
browser.runtime.sendMessage({
type: "hitLogger.traceElemHide",
selectors: [],
filters
});
}
},
- apply()
+ applyFilters(filterTypes)
{
- browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response =>
+ let message = {type: "content.applyFilters"};
+
+ if (filterTypes)
+ message.filterTypes = filterTypes;
kzar 2018/07/19 12:24:18 Nit: We could assign the `undefined` instead? bro
Manish Jethani 2018/07/19 12:55:23 Yes, we could just pass undefined, I was just tryi
kzar 2018/07/19 13:28:54 Thanks, but looks like you didn't push that change
Manish Jethani 2018/07/19 14:04:34 Done.
+
+ browser.runtime.sendMessage(message, response =>
{
if (this.tracer)
this.tracer.disconnect();
this.tracer = null;
if (response.trace)
this.tracer = new ElementHidingTracer();
@@ -587,28 +592,28 @@
});
}
};
if (document instanceof HTMLDocument)
{
checkSitekey();
- elemhide = new ElemHide();
- elemhide.apply();
+ content = new Content();
+ content.applyFilters();
document.addEventListener("error", event =>
{
checkCollapse(event.target);
}, true);
document.addEventListener("load", event =>
{
let element = event.target;
if (/^i?frame$/.test(element.localName))
checkCollapse(element);
}, true);
}
window.checkCollapse = checkCollapse;
-window.elemhide = elemhide;
+window.content = content;
window.typeMap = typeMap;
window.getURLsFromElement = getURLsFromElement;

Powered by Google App Engine
This is Rietveld