OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 * information required to reconstruct frame | 202 * information required to reconstruct frame |
203 * data for the hit | 203 * data for the hit |
204 * @return {Boolean} | 204 * @return {Boolean} |
205 */ | 205 */ |
206 shouldHide: function(message) | 206 shouldHide: function(message) |
207 { | 207 { |
208 let filter = ElemHide.getFilterByKey(message.key); | 208 let filter = ElemHide.getFilterByKey(message.key); |
209 if (!filter || !message.frames.length) | 209 if (!filter || !message.frames.length) |
210 return false; | 210 return false; |
211 | 211 |
212 let fakeFrame = null; | |
213 for (let i = message.frames.length - 1; i >= 0; i--) | |
214 { | |
215 fakeFrame = { | |
216 parent: fakeFrame, | |
217 location: { | |
218 href: message.frames[i].location | |
219 }, | |
220 document: { | |
221 documentElement: {} | |
222 }, | |
223 QueryInterface: function() {return this;}, | |
224 getInterface: function() {return this;}, | |
225 usePrivateBrowsing: message.isPrivate | |
226 }; | |
227 fakeFrame.top = fakeFrame.parent || fakeFrame; | |
228 if (!fakeFrame.parent) | |
229 fakeFrame.parent = fakeFrame; | |
230 | |
231 let sitekey = message.frames[i].sitekey || null; | |
232 fakeFrame.document.documentElement.getAttribute = function(attr) | |
233 { | |
234 if (attr == "data-adblockkey") | |
235 return sitekey; | |
236 else | |
237 return null; | |
238 }; | |
239 } | |
240 | |
241 let {Policy} = require("contentPolicy"); | 212 let {Policy} = require("contentPolicy"); |
242 return !Policy.processNode(fakeFrame, fakeFrame.document, "ELEMHIDE", filter
); | 213 return !Policy.shouldAllow({ |
| 214 contentType: "ELEMHIDE", |
| 215 location: filter, |
| 216 frames: message.frames, |
| 217 isPrivate: message.isPrivate |
| 218 }).allow; |
243 }, | 219 }, |
244 | 220 |
245 /** | 221 /** |
246 * Will be set to true if apply() is running (reentrance protection). | 222 * Will be set to true if apply() is running (reentrance protection). |
247 * @type Boolean | 223 * @type Boolean |
248 */ | 224 */ |
249 _applying: false, | 225 _applying: false, |
250 | 226 |
251 /** | 227 /** |
252 * Will be set to true if an apply() call arrives while apply() is already | 228 * Will be set to true if an apply() call arrives while apply() is already |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 let filter = filterByKey[key]; | 414 let filter = filterByKey[key]; |
439 if (specificOnly && (!filter.domains || filter.domains[""])) | 415 if (specificOnly && (!filter.domains || filter.domains[""])) |
440 continue; | 416 continue; |
441 | 417 |
442 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) | 418 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) |
443 result.push(filter.selector); | 419 result.push(filter.selector); |
444 } | 420 } |
445 return result; | 421 return result; |
446 } | 422 } |
447 }; | 423 }; |
OLD | NEW |