Index: lib/child/elemHideEmulation.js |
=================================================================== |
rename from lib/child/cssProperties.js |
rename to lib/child/elemHideEmulation.js |
--- a/lib/child/cssProperties.js |
+++ b/lib/child/elemHideEmulation.js |
@@ -26,46 +26,46 @@ |
let {RequestNotifier} = require("child/requestNotifier"); |
function getFilters(window, callback) |
{ |
let message = { |
frames: getFrames(window), |
payload: { |
type: "filters.get", |
- what: "cssproperties" |
+ what: "elemhideemulation" |
} |
}; |
port.emitWithResponse("ext_message", message).then(callback); |
} |
function addUserCSS(window, cssCode) |
{ |
let uri = Services.io.newURI("data:text/css," + encodeURIComponent(cssCode), |
null, null); |
let utils = window.QueryInterface(Ci.nsIInterfaceRequestor) |
.getInterface(Ci.nsIDOMWindowUtils); |
utils.loadSheet(uri, Ci.nsIDOMWindowUtils.USER_SHEET); |
} |
- function initCSSPropertyFilters() |
+ function initElemHideEmulation() |
{ |
- let scope = {}; |
+ let scope = Object.assign({}, require("common")); |
Services.scriptloader.loadSubScript( |
- "chrome://adblockplus/content/cssProperties.js", scope); |
+ "chrome://adblockplus/content/elemHideEmulation.js", scope); |
let onContentWindow = (subject, topic, data) => |
{ |
if (!(subject instanceof Ci.nsIDOMWindow)) |
return; |
let onReady = event => |
{ |
subject.removeEventListener("load", onReady); |
- let handler = new scope.CSSPropertyFilters( |
+ let handler = new scope.ElemHideEmulation( |
subject, getFilters.bind(null, subject), (selectors, filters) => |
{ |
if (selectors.length == 0) |
return; |
addUserCSS(subject, selectors.map( |
selector => selector + "{display: none !important;}" |
).join("\n")); |
@@ -89,17 +89,17 @@ |
{ |
RequestNotifier.addNodeData(subject.document, subject.top, { |
contentType: "ELEMHIDE", |
docDomain: docDomain, |
thirdParty: false, |
// TODO: Show the actual matching selector here? |
location: filter.replace(/^.*?##/, ""), |
filter: filter, |
- filterType: "cssproperty" |
+ filterType: "elemhideemulation" |
}); |
} |
} |
); |
handler.load(() => handler.apply()); |
}; |
@@ -110,10 +110,10 @@ |
false); |
onShutdown.add(() => |
{ |
Services.obs.removeObserver(onContentWindow, |
"content-document-global-created"); |
}); |
} |
- initCSSPropertyFilters(); |
+ initElemHideEmulation(); |
})(); |