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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // Finally since some users have both AdBlock and Adblock Plus installed we | 372 // Finally since some users have both AdBlock and Adblock Plus installed we |
373 // have to consider how the two extensions interact. For example we want to | 373 // have to consider how the two extensions interact. For example we want to |
374 // avoid creating the shadowRoot twice. | 374 // avoid creating the shadowRoot twice. |
375 let shadow = document.documentElement.shadowRoot || | 375 let shadow = document.documentElement.shadowRoot || |
376 document.documentElement.createShadowRoot(); | 376 document.documentElement.createShadowRoot(); |
377 shadow.appendChild(document.createElement("shadow")); | 377 shadow.appendChild(document.createElement("shadow")); |
378 | 378 |
379 return shadow; | 379 return shadow; |
380 }, | 380 }, |
381 | 381 |
382 addSelectorsInline(selectors, filters, groupName) | 382 addSelectorsInline(selectors, groupName) |
383 { | 383 { |
384 let style = this.styles.get(groupName); | 384 let style = this.styles.get(groupName); |
385 | 385 |
386 if (style) | 386 if (style) |
387 { | 387 { |
388 while (style.sheet.cssRules.length > 0) | 388 while (style.sheet.cssRules.length > 0) |
389 style.sheet.deleteRule(0); | 389 style.sheet.deleteRule(0); |
390 } | 390 } |
391 | 391 |
392 if (selectors.length == 0) | 392 if (selectors.length == 0) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 { | 451 { |
452 // Insert the style rules inline if we have been instructed by the | 452 // Insert the style rules inline if we have been instructed by the |
453 // background page to do so. This is usually the case, except on platforms | 453 // background page to do so. This is usually the case, except on platforms |
454 // that do support user stylesheets via the browser.tabs.insertCSS API | 454 // that do support user stylesheets via the browser.tabs.insertCSS API |
455 // (Firefox 53 onwards for now and possibly Chrome in the near future). | 455 // (Firefox 53 onwards for now and possibly Chrome in the near future). |
456 // Once all supported platforms have implemented this API, we can remove | 456 // Once all supported platforms have implemented this API, we can remove |
457 // the code below. See issue #5090. | 457 // the code below. See issue #5090. |
458 // Related Chrome and Firefox issues: | 458 // Related Chrome and Firefox issues: |
459 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 | 459 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 |
460 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026 | 460 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026 |
461 this.addSelectorsInline(selectors, filters, "emulated"); | 461 this.addSelectorsInline(selectors, "emulated"); |
462 } | 462 } |
463 else | 463 else |
464 { | 464 { |
465 browser.runtime.sendMessage({ | 465 browser.runtime.sendMessage({ |
466 type: "elemhide.injectSelectors", | 466 type: "elemhide.injectSelectors", |
467 selectors, | 467 selectors, |
468 groupName: "emulated" | 468 groupName: "emulated" |
469 }); | 469 }); |
470 } | 470 } |
471 | 471 |
(...skipping 23 matching lines...) Expand all Loading... |
495 if (this.tracer) | 495 if (this.tracer) |
496 this.tracer.disconnect(); | 496 this.tracer.disconnect(); |
497 this.tracer = null; | 497 this.tracer = 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.inline = response.inline; | 502 this.inline = response.inline; |
503 | 503 |
504 if (this.inline) | 504 if (this.inline) |
505 this.addSelectorsInline(response.selectors); | 505 this.addSelectorsInline(response.selectors, "standard"); |
506 | 506 |
507 if (this.tracer) | 507 if (this.tracer) |
508 this.tracer.addSelectors(response.selectors); | 508 this.tracer.addSelectors(response.selectors); |
509 | 509 |
510 this.elemHideEmulation.apply(response.emulatedPatterns); | 510 this.elemHideEmulation.apply(response.emulatedPatterns); |
511 }); | 511 }); |
512 } | 512 } |
513 }; | 513 }; |
514 | 514 |
515 if (document instanceof HTMLDocument) | 515 if (document instanceof HTMLDocument) |
(...skipping 13 matching lines...) Expand all Loading... |
529 let element = event.target; | 529 let element = event.target; |
530 if (/^i?frame$/.test(element.localName)) | 530 if (/^i?frame$/.test(element.localName)) |
531 checkCollapse(element); | 531 checkCollapse(element); |
532 }, true); | 532 }, true); |
533 } | 533 } |
534 | 534 |
535 window.checkCollapse = checkCollapse; | 535 window.checkCollapse = checkCollapse; |
536 window.elemhide = elemhide; | 536 window.elemhide = elemhide; |
537 window.typeMap = typeMap; | 537 window.typeMap = typeMap; |
538 window.getURLsFromElement = getURLsFromElement; | 538 window.getURLsFromElement = getURLsFromElement; |
OLD | NEW |