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,22 @@ |
browser.runtime.sendMessage({ |
type: "hitLogger.traceElemHide", |
selectors: [], |
filters |
}); |
} |
}, |
- apply() |
+ applyFilters(filterTypes) |
{ |
- browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response => |
+ browser.runtime.sendMessage({ |
+ type: "content.applyFilters", filterTypes |
+ }, |
+ response => |
{ |
if (this.tracer) |
this.tracer.disconnect(); |
this.tracer = null; |
if (response.trace) |
this.tracer = new ElementHidingTracer(); |
@@ -587,28 +590,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; |