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 contentFiltering; |
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); |
+ contentFiltering.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 ContentFiltering() |
{ |
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 = { |
+ContentFiltering.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() |
+ apply(filterTypes) |
{ |
- browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response => |
+ let message = {type: "content.applyFilters"}; |
+ |
+ if (filterTypes) |
+ message.filterTypes = filterTypes; |
+ |
+ 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(); |
+ contentFiltering = new ContentFiltering(); |
+ contentFiltering.apply(); |
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.contentFiltering = contentFiltering; |
window.typeMap = typeMap; |
window.getURLsFromElement = getURLsFromElement; |