| Left: | ||
| Right: |
| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 | 423 |
| 424 this.elemHideEmulation = new ElemHideEmulation( | 424 this.elemHideEmulation = new ElemHideEmulation( |
| 425 window, | 425 window, |
| 426 callback => | 426 callback => |
| 427 { | 427 { |
| 428 ext.backgroundPage.sendMessage({ | 428 ext.backgroundPage.sendMessage({ |
| 429 type: "filters.get", | 429 type: "filters.get", |
| 430 what: "elemhideemulation" | 430 what: "elemhideemulation" |
| 431 }, callback); | 431 }, callback); |
| 432 }, | 432 }, |
| 433 this.addSelectors.bind(this) | 433 this.addSelectors.bind(this), |
| 434 this.hideElements.bind(this) | |
| 434 ); | 435 ); |
| 435 } | 436 } |
| 436 ElemHide.prototype = { | 437 ElemHide.prototype = { |
| 437 selectorGroupSize: 200, | 438 selectorGroupSize: 200, |
| 438 | 439 |
| 439 createShadowTree() | 440 createShadowTree() |
| 440 { | 441 { |
| 441 // Use Shadow DOM if available as to not mess with with web pages that | 442 // Use Shadow DOM if available as to not mess with with web pages that |
| 442 // rely on the order of their own <style> tags (#309). However, creating | 443 // rely on the order of their own <style> tags (#309). However, creating |
| 443 // a shadow root breaks running CSS transitions. So we have to create | 444 // a shadow root breaks running CSS transitions. So we have to create |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 i, i + this.selectorGroupSize | 535 i, i + this.selectorGroupSize |
| 535 ).join(", "); | 536 ).join(", "); |
| 536 this.style.sheet.insertRule(selector + "{display: none !important;}", | 537 this.style.sheet.insertRule(selector + "{display: none !important;}", |
| 537 this.style.sheet.cssRules.length); | 538 this.style.sheet.cssRules.length); |
| 538 } | 539 } |
| 539 | 540 |
| 540 if (this.tracer) | 541 if (this.tracer) |
| 541 this.tracer.addSelectors(selectors, filters || selectors); | 542 this.tracer.addSelectors(selectors, filters || selectors); |
| 542 }, | 543 }, |
| 543 | 544 |
| 545 hideElements(elements, filters) | |
| 546 { | |
| 547 for (let element of elements) | |
| 548 { | |
| 549 element.style.display = "none"; | |
|
Sebastian Noack
2017/04/04 10:14:45
We should use the same logic as we have in checkCo
hub
2017/04/05 09:05:53
Done.
| |
| 550 } | |
| 551 // XXX first arg is supposed to be selectors | |
| 552 if (this.tracer) | |
| 553 this.tracer.addSelectors(filters, filters); | |
|
Sebastian Noack
2017/04/04 10:14:45
ElementHidingTracer.addSelectors() will search for
hub
2017/04/05 09:05:53
Done.
| |
| 554 }, | |
| 555 | |
| 544 apply() | 556 apply() |
| 545 { | 557 { |
| 546 ext.backgroundPage.sendMessage({type: "get-selectors"}, response => | 558 ext.backgroundPage.sendMessage({type: "get-selectors"}, response => |
| 547 { | 559 { |
| 548 if (this.tracer) | 560 if (this.tracer) |
| 549 this.tracer.disconnect(); | 561 this.tracer.disconnect(); |
| 550 this.tracer = null; | 562 this.tracer = null; |
| 551 | 563 |
| 552 if (this.style && this.style.parentElement) | 564 if (this.style && this.style.parentElement) |
| 553 this.style.parentElement.removeChild(this.style); | 565 this.style.parentElement.removeChild(this.style); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 575 checkCollapse(event.target); | 587 checkCollapse(event.target); |
| 576 }, true); | 588 }, true); |
| 577 | 589 |
| 578 document.addEventListener("load", event => | 590 document.addEventListener("load", event => |
| 579 { | 591 { |
| 580 let element = event.target; | 592 let element = event.target; |
| 581 if (/^i?frame$/.test(element.localName)) | 593 if (/^i?frame$/.test(element.localName)) |
| 582 checkCollapse(element); | 594 checkCollapse(element); |
| 583 }, true); | 595 }, true); |
| 584 } | 596 } |
| OLD | NEW |