Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 clearTimeout(this.timeout); | 338 clearTimeout(this.timeout); |
339 } | 339 } |
340 }; | 340 }; |
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 | 348 this.emulatedPatterns = null; |
349 this.elemHideEmulationPatterns = null; | 349 |
350 this.elemHideEmulation = new ElemHideEmulation( | 350 this.elemHideEmulation = new ElemHideEmulation( |
351 window, | 351 window, |
352 callback => { callback(this.elemHideEmulationPatterns); }, | 352 callback => callback(this.emulatedPatterns), |
Sebastian Noack
2017/09/25 23:13:19
In the next step we should pass patterns just as a
Manish Jethani
2017/09/26 11:50:18
This might read better as another method of ElemHi
Sebastian Noack
2017/09/26 21:50:40
Since you don't have a strong opinion, I think I p
| |
353 this.addSelectors.bind(this), | 353 this.addSelectors.bind(this), |
354 this.hideElements.bind(this) | 354 this.hideElements.bind(this) |
355 ); | 355 ); |
356 } | 356 } |
357 ElemHide.prototype = { | 357 ElemHide.prototype = { |
358 selectorGroupSize: 200, | 358 selectorGroupSize: 200, |
359 | 359 |
360 createShadowTree() | 360 createShadowTree() |
361 { | 361 { |
362 // Use Shadow DOM if available as to not mess with with web pages that | 362 // 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) | 494 if (response.trace) |
495 this.tracer = new ElementHidingTracer(); | 495 this.tracer = new ElementHidingTracer(); |
496 | 496 |
497 this.inject = response.inject; | 497 this.inject = response.inject; |
498 | 498 |
499 if (this.inject) | 499 if (this.inject) |
500 this.addSelectors(response.selectors); | 500 this.addSelectors(response.selectors); |
501 else if (this.tracer) | 501 else if (this.tracer) |
502 this.tracer.addSelectors(response.selectors); | 502 this.tracer.addSelectors(response.selectors); |
503 | 503 |
504 this.elemHideEmulationPatterns = response.emulated; | 504 this.emulatedPatterns = response.emulatedPatterns; |
505 this.elemHideEmulation.apply(); | 505 this.elemHideEmulation.apply(); |
506 this.emulatedPatterns = null; | |
Sebastian Noack
2017/09/26 21:50:40
Don't leak memory.
| |
506 }); | 507 }); |
507 } | 508 } |
508 }; | 509 }; |
509 | 510 |
510 if (document instanceof HTMLDocument) | 511 if (document instanceof HTMLDocument) |
511 { | 512 { |
512 checkSitekey(); | 513 checkSitekey(); |
513 | 514 |
514 elemhide = new ElemHide(); | 515 elemhide = new ElemHide(); |
515 elemhide.apply(); | 516 elemhide.apply(); |
516 | 517 |
517 document.addEventListener("error", event => | 518 document.addEventListener("error", event => |
518 { | 519 { |
519 checkCollapse(event.target); | 520 checkCollapse(event.target); |
520 }, true); | 521 }, true); |
521 | 522 |
522 document.addEventListener("load", event => | 523 document.addEventListener("load", event => |
523 { | 524 { |
524 let element = event.target; | 525 let element = event.target; |
525 if (/^i?frame$/.test(element.localName)) | 526 if (/^i?frame$/.test(element.localName)) |
526 checkCollapse(element); | 527 checkCollapse(element); |
527 }, true); | 528 }, true); |
528 } | 529 } |
LEFT | RIGHT |