| 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-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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 let selector = preparedSelectors.slice( | 434 let selector = preparedSelectors.slice( |
| 435 i, i + this.selectorGroupSize | 435 i, i + this.selectorGroupSize |
| 436 ).join(", "); | 436 ).join(", "); |
| 437 this.style.sheet.insertRule(selector + "{display: none !important;}", | 437 this.style.sheet.insertRule(selector + "{display: none !important;}", |
| 438 this.style.sheet.cssRules.length); | 438 this.style.sheet.cssRules.length); |
| 439 } | 439 } |
| 440 }, | 440 }, |
| 441 | 441 |
| 442 addSelectors(selectors, filters) | 442 addSelectors(selectors, filters) |
| 443 { | 443 { |
| 444 if (!selectors || selectors.length == 0) | 444 if (selectors.length == 0) |
| 445 return; | 445 return; |
| 446 | 446 |
| 447 if (this.inject) | 447 if (this.inject) |
| 448 { | 448 { |
| 449 // Insert the style rules inline if we have been instructed by the | 449 // Insert the style rules inline if we have been instructed by the |
| 450 // background page to do so. This is usually the case, except on platforms | 450 // background page to do so. This is usually the case, except on platforms |
| 451 // that do support user stylesheets via the chrome.tabs.insertCSS API | 451 // that do support user stylesheets via the chrome.tabs.insertCSS API |
| 452 // (Firefox 53 onwards for now and possibly Chrome in the near future). | 452 // (Firefox 53 onwards for now and possibly Chrome in the near future). |
| 453 // Once all supported platforms have implemented this API, we can remove | 453 // Once all supported platforms have implemented this API, we can remove |
| 454 // the code below. See issue #5090. | 454 // the code below. See issue #5090. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 if (this.style && this.style.parentElement) | 495 if (this.style && this.style.parentElement) |
| 496 this.style.parentElement.removeChild(this.style); | 496 this.style.parentElement.removeChild(this.style); |
| 497 this.style = null; | 497 this.style = null; |
| 498 | 498 |
| 499 if (response.trace) | 499 if (response.trace) |
| 500 this.tracer = new ElementHidingTracer(); | 500 this.tracer = new ElementHidingTracer(); |
| 501 | 501 |
| 502 this.inject = response.inject; | 502 this.inject = response.inject; |
| 503 | 503 |
| 504 if (this.inject) | 504 if (response.selectors) |
| 505 this.addSelectors(response.selectors); | 505 { |
| 506 else if (this.tracer) | 506 if (this.inject) |
| 507 this.tracer.addSelectors(response.selectors); | 507 this.addSelectors(response.selectors); |
| 508 else if (this.tracer) |
| 509 this.tracer.addSelectors(response.selectors); |
| 510 } |
| 508 | 511 |
| 509 this.elemHideEmulation.apply(); | 512 this.elemHideEmulation.apply(); |
| 510 }); | 513 }); |
| 511 } | 514 } |
| 512 }; | 515 }; |
| 513 | 516 |
| 514 if (document instanceof HTMLDocument) | 517 if (document instanceof HTMLDocument) |
| 515 { | 518 { |
| 516 checkSitekey(); | 519 checkSitekey(); |
| 517 | 520 |
| 518 elemhide = new ElemHide(); | 521 elemhide = new ElemHide(); |
| 519 elemhide.apply(); | 522 elemhide.apply(); |
| 520 | 523 |
| 521 document.addEventListener("error", event => | 524 document.addEventListener("error", event => |
| 522 { | 525 { |
| 523 checkCollapse(event.target); | 526 checkCollapse(event.target); |
| 524 }, true); | 527 }, true); |
| 525 | 528 |
| 526 document.addEventListener("load", event => | 529 document.addEventListener("load", event => |
| 527 { | 530 { |
| 528 let element = event.target; | 531 let element = event.target; |
| 529 if (/^i?frame$/.test(element.localName)) | 532 if (/^i?frame$/.test(element.localName)) |
| 530 checkCollapse(element); | 533 checkCollapse(element); |
| 531 }, true); | 534 }, true); |
| 532 } | 535 } |
| OLD | NEW |