LEFT | RIGHT |
(no file at all) | |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 function ElemHide() | 342 function ElemHide() |
343 { | 343 { |
344 this.shadow = this.createShadowTree(); | 344 this.shadow = this.createShadowTree(); |
345 this.style = null; | 345 this.style = null; |
346 this.tracer = null; | 346 this.tracer = null; |
347 this.inject = true; | 347 this.inject = true; |
348 this.emulatedPatterns = null; | 348 this.emulatedPatterns = null; |
349 | 349 |
350 this.elemHideEmulation = new ElemHideEmulation( | 350 this.elemHideEmulation = new ElemHideEmulation( |
351 window, | |
352 callback => callback(this.emulatedPatterns), | |
353 this.addSelectors.bind(this), | 351 this.addSelectors.bind(this), |
354 this.hideElements.bind(this) | 352 this.hideElements.bind(this) |
355 ); | 353 ); |
356 } | 354 } |
357 ElemHide.prototype = { | 355 ElemHide.prototype = { |
358 selectorGroupSize: 200, | 356 selectorGroupSize: 200, |
359 | 357 |
360 createShadowTree() | 358 createShadowTree() |
361 { | 359 { |
362 // Use Shadow DOM if available as to not mess with with web pages that | 360 // Use Shadow DOM if available as to not mess with with web pages that |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 if (response.trace) | 492 if (response.trace) |
495 this.tracer = new ElementHidingTracer(); | 493 this.tracer = new ElementHidingTracer(); |
496 | 494 |
497 this.inject = response.inject; | 495 this.inject = response.inject; |
498 | 496 |
499 if (this.inject) | 497 if (this.inject) |
500 this.addSelectors(response.selectors); | 498 this.addSelectors(response.selectors); |
501 else if (this.tracer) | 499 else if (this.tracer) |
502 this.tracer.addSelectors(response.selectors); | 500 this.tracer.addSelectors(response.selectors); |
503 | 501 |
504 this.emulatedPatterns = response.emulatedPatterns; | 502 this.elemHideEmulation.apply(response.emulatedPatterns); |
505 this.elemHideEmulation.apply(); | |
506 this.emulatedPatterns = null; | |
507 }); | 503 }); |
508 } | 504 } |
509 }; | 505 }; |
510 | 506 |
511 if (document instanceof HTMLDocument) | 507 if (document instanceof HTMLDocument) |
512 { | 508 { |
513 checkSitekey(); | 509 checkSitekey(); |
514 | 510 |
515 elemhide = new ElemHide(); | 511 elemhide = new ElemHide(); |
516 elemhide.apply(); | 512 elemhide.apply(); |
517 | 513 |
518 document.addEventListener("error", event => | 514 document.addEventListener("error", event => |
519 { | 515 { |
520 checkCollapse(event.target); | 516 checkCollapse(event.target); |
521 }, true); | 517 }, true); |
522 | 518 |
523 document.addEventListener("load", event => | 519 document.addEventListener("load", event => |
524 { | 520 { |
525 let element = event.target; | 521 let element = event.target; |
526 if (/^i?frame$/.test(element.localName)) | 522 if (/^i?frame$/.test(element.localName)) |
527 checkCollapse(element); | 523 checkCollapse(element); |
528 }, true); | 524 }, true); |
529 } | 525 } |
LEFT | RIGHT |