| 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 if (this.tracer) | 493 if (this.tracer) |
| 494 { | 494 { |
| 495 browser.runtime.sendMessage({ | 495 browser.runtime.sendMessage({ |
| 496 type: "devtools.traceElemHide", | 496 type: "devtools.traceElemHide", |
| 497 selectors: [], | 497 selectors: [], |
| 498 filters | 498 filters |
| 499 }); | 499 }); |
| 500 } | 500 } |
| 501 }, | 501 }, |
| 502 | 502 |
| 503 apply() | 503 apply({trace, inline, inlineEmulated, selectors, emulatedPatterns = []}) |
| 504 { | 504 { |
| 505 browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response => | 505 if (this.tracer) |
| 506 { | 506 this.tracer.disconnect(); |
| 507 if (this.tracer) | 507 this.tracer = null; |
| 508 this.tracer.disconnect(); | |
| 509 this.tracer = null; | |
| 510 | 508 |
| 511 if (response.trace) | 509 if (trace) |
| 512 this.tracer = new ElementHidingTracer(); | 510 this.tracer = new ElementHidingTracer(); |
| 513 | 511 |
| 514 this.inline = response.inline; | 512 this.inline = inline; |
| 515 this.inlineEmulated = !!response.inlineEmulated; | 513 this.inlineEmulated = !!inlineEmulated; |
| 516 | 514 |
| 517 if (this.inline) | 515 if (this.inline) |
| 518 this.addSelectorsInline(response.selectors, "standard"); | 516 this.addSelectorsInline(selectors, "standard"); |
| 519 | 517 |
| 520 if (this.tracer) | 518 if (this.tracer) |
| 521 this.tracer.addSelectors(response.selectors); | 519 this.tracer.addSelectors(selectors); |
| 522 | 520 |
| 523 // Prefer CSS selectors for -abp-has and -abp-contains unless the | 521 // Prefer CSS selectors for -abp-has and -abp-contains unless the |
| 524 // background page has asked us to use inline styles. | 522 // background page has asked us to use inline styles. |
| 525 this.elemHideEmulation.useInlineStyles = this.inline || | 523 this.elemHideEmulation.useInlineStyles = this.inline || |
| 526 this.inlineEmulated; | 524 this.inlineEmulated; |
| 527 | 525 |
| 528 this.elemHideEmulation.apply(response.emulatedPatterns); | 526 this.elemHideEmulation.apply(emulatedPatterns); |
| 529 }); | |
| 530 } | 527 } |
| 531 }; | 528 }; |
| 532 | 529 |
| 533 if (document instanceof HTMLDocument) | 530 if (document instanceof HTMLDocument) |
| 534 { | 531 { |
| 535 checkSitekey(); | 532 checkSitekey(); |
| 536 | 533 |
| 537 elemhide = new ElemHide(); | 534 elemhide = new ElemHide(); |
| 538 elemhide.apply(); | 535 |
| 536 browser.runtime.onMessage.addListener(message => |
| 537 { |
| 538 if (message.type == "elemhide.apply") |
| 539 elemhide.apply(message); |
| 540 }); |
| 539 | 541 |
| 540 document.addEventListener("error", event => | 542 document.addEventListener("error", event => |
| 541 { | 543 { |
| 542 checkCollapse(event.target); | 544 checkCollapse(event.target); |
| 543 }, true); | 545 }, true); |
| 544 | 546 |
| 545 document.addEventListener("load", event => | 547 document.addEventListener("load", event => |
| 546 { | 548 { |
| 547 let element = event.target; | 549 let element = event.target; |
| 548 if (/^i?frame$/.test(element.localName)) | 550 if (/^i?frame$/.test(element.localName)) |
| 549 checkCollapse(element); | 551 checkCollapse(element); |
| 550 }, true); | 552 }, true); |
| 551 } | 553 } |
| 552 | 554 |
| 553 window.checkCollapse = checkCollapse; | 555 window.checkCollapse = checkCollapse; |
| 554 window.elemhide = elemhide; | 556 window.elemhide = elemhide; |
| 555 window.typeMap = typeMap; | 557 window.typeMap = typeMap; |
| 556 window.getURLsFromElement = getURLsFromElement; | 558 window.getURLsFromElement = getURLsFromElement; |
| OLD | NEW |