Index: lib/elemHide.js |
=================================================================== |
--- a/lib/elemHide.js |
+++ b/lib/elemHide.js |
@@ -204,47 +204,23 @@ let ElemHide = exports.ElemHide = |
* @return {Boolean} |
*/ |
shouldHide: function(message) |
{ |
let filter = ElemHide.getFilterByKey(message.key); |
if (!filter || !message.frames.length) |
return false; |
- let fakeFrame = null; |
- for (let i = message.frames.length - 1; i >= 0; i--) |
- { |
- fakeFrame = { |
- parent: fakeFrame, |
- location: { |
- href: message.frames[i].location |
- }, |
- document: { |
- documentElement: {} |
- }, |
- QueryInterface: function() {return this;}, |
- getInterface: function() {return this;}, |
- usePrivateBrowsing: (fakeFrame ? fakeFrame.usePrivateBrowsing : message.frames[i].privateBrowsing) |
- }; |
- fakeFrame.top = fakeFrame.parent || fakeFrame; |
- if (!fakeFrame.parent) |
- fakeFrame.parent = fakeFrame; |
- |
- let sitekey = message.frames[i].sitekey || null; |
- fakeFrame.document.documentElement.getAttribute = function(attr) |
- { |
- if (attr == "data-adblockkey") |
- return sitekey; |
- else |
- return null; |
- }; |
- } |
- |
let {Policy} = require("contentPolicy"); |
- return !Policy.processNode(fakeFrame, fakeFrame.document, Policy.type.ELEMHIDE, filter); |
+ return Policy.shouldLoad({ |
+ contentType: "ELEMHIDE", |
+ location: filter, |
+ frames: message.frames, |
+ isPrivate: message.isPrivate |
+ }).block; |
}, |
/** |
* Will be set to true if apply() is running (reentrance protection). |
* @type Boolean |
*/ |
_applying: false, |