| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; | 18 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; |
|
Felix Dahlke
2016/12/20 14:35:42
Caused by rebasing.
| |
| 19 | 19 |
| 20 var typeMap = { | 20 var typeMap = { |
| 21 "img": "IMAGE", | 21 "img": "IMAGE", |
| 22 "input": "IMAGE", | 22 "input": "IMAGE", |
| 23 "picture": "IMAGE", | 23 "picture": "IMAGE", |
| 24 "audio": "MEDIA", | 24 "audio": "MEDIA", |
| 25 "video": "MEDIA", | 25 "video": "MEDIA", |
| 26 "frame": "SUBDOCUMENT", | 26 "frame": "SUBDOCUMENT", |
| 27 "iframe": "SUBDOCUMENT", | 27 "iframe": "SUBDOCUMENT", |
| 28 "object": "OBJECT", | 28 "object": "OBJECT", |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 | 157 |
| 158 if (element.style.getPropertyValue(propertyName) != propertyValue || | 158 if (element.style.getPropertyValue(propertyName) != propertyValue || |
| 159 element.style.getPropertyPriority(propertyName) != "important") | 159 element.style.getPropertyPriority(propertyName) != "important") |
| 160 element.style.setProperty(propertyName, propertyValue, "important"); | 160 element.style.setProperty(propertyName, propertyValue, "important"); |
| 161 } | 161 } |
| 162 | 162 |
| 163 if (collapse) | 163 if (collapse) |
| 164 { | 164 { |
| 165 collapseElement(); | 165 collapseElement(); |
| 166 | 166 |
| 167 if (MutationObserver) | 167 if (MutationObserver) |
|
Felix Dahlke
2016/12/20 14:35:42
Caused by rebasing.
| |
| 168 new MutationObserver(collapseElement).observe( | 168 new MutationObserver(collapseElement).observe( |
| 169 element, { | 169 element, { |
| 170 attributes: true, | 170 attributes: true, |
| 171 attributeFilter: ["style"] | 171 attributeFilter: ["style"] |
| 172 } | 172 } |
| 173 ); | 173 ); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 ); | 176 ); |
| 177 } | 177 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 RealWebSocket.prototype.constructor = WebSocket; | 426 RealWebSocket.prototype.constructor = WebSocket; |
| 427 }, eventName); | 427 }, eventName); |
| 428 } | 428 } |
| 429 | 429 |
| 430 function ElemHide() | 430 function ElemHide() |
| 431 { | 431 { |
| 432 this.shadow = this.createShadowTree(); | 432 this.shadow = this.createShadowTree(); |
| 433 this.style = null; | 433 this.style = null; |
| 434 this.tracer = null; | 434 this.tracer = null; |
| 435 | 435 |
| 436 this.propertyFilters = new CSSPropertyFilters( | 436 this.elemHideEmulation = new ElemHideEmulation( |
| 437 window, | 437 window, |
| 438 function(callback) | 438 function(callback) |
| 439 { | 439 { |
| 440 ext.backgroundPage.sendMessage({ | 440 ext.backgroundPage.sendMessage({ |
| 441 type: "filters.get", | 441 type: "filters.get", |
| 442 what: "cssproperties" | 442 what: "elemhideemulation" |
| 443 }, callback); | 443 }, callback); |
| 444 }, | 444 }, |
| 445 this.addSelectors.bind(this) | 445 this.addSelectors.bind(this) |
| 446 ); | 446 ); |
| 447 } | 447 } |
| 448 ElemHide.prototype = { | 448 ElemHide.prototype = { |
| 449 selectorGroupSize: 200, | 449 selectorGroupSize: 200, |
| 450 | 450 |
| 451 createShadowTree: function() | 451 createShadowTree: function() |
| 452 { | 452 { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 { | 540 { |
| 541 var selector = selectors.slice(i, i + this.selectorGroupSize).join(", "); | 541 var selector = selectors.slice(i, i + this.selectorGroupSize).join(", "); |
| 542 this.style.sheet.insertRule(selector + "{display: none !important;}", | 542 this.style.sheet.insertRule(selector + "{display: none !important;}", |
| 543 this.style.sheet.cssRules.length); | 543 this.style.sheet.cssRules.length); |
| 544 } | 544 } |
| 545 }, | 545 }, |
| 546 | 546 |
| 547 apply: function() | 547 apply: function() |
| 548 { | 548 { |
| 549 var selectors = null; | 549 var selectors = null; |
| 550 var propertyFiltersLoaded = false; | 550 var elemHideEmulationLoaded = false; |
| 551 | 551 |
| 552 var checkLoaded = function() | 552 var checkLoaded = function() |
| 553 { | 553 { |
| 554 if (!selectors || !propertyFiltersLoaded) | 554 if (!selectors || !elemHideEmulationLoaded) |
| 555 return; | 555 return; |
| 556 | 556 |
| 557 if (this.tracer) | 557 if (this.tracer) |
| 558 this.tracer.disconnect(); | 558 this.tracer.disconnect(); |
| 559 this.tracer = null; | 559 this.tracer = null; |
| 560 | 560 |
| 561 if (this.style && this.style.parentElement) | 561 if (this.style && this.style.parentElement) |
| 562 this.style.parentElement.removeChild(this.style); | 562 this.style.parentElement.removeChild(this.style); |
| 563 this.style = null; | 563 this.style = null; |
| 564 | 564 |
| 565 this.addSelectors(selectors.selectors); | 565 this.addSelectors(selectors.selectors); |
| 566 this.propertyFilters.apply(); | 566 this.elemHideEmulation.apply(); |
| 567 | 567 |
| 568 if (selectors.trace) | 568 if (selectors.trace) |
| 569 this.tracer = new ElementHidingTracer(selectors.selectors); | 569 this.tracer = new ElementHidingTracer(selectors.selectors); |
| 570 }.bind(this); | 570 }.bind(this); |
| 571 | 571 |
| 572 ext.backgroundPage.sendMessage({type: "get-selectors"}, function(response) | 572 ext.backgroundPage.sendMessage({type: "get-selectors"}, function(response) |
| 573 { | 573 { |
| 574 selectors = response; | 574 selectors = response; |
| 575 checkLoaded(); | 575 checkLoaded(); |
| 576 }); | 576 }); |
| 577 | 577 |
| 578 this.propertyFilters.load(function() | 578 this.elemHideEmulation.load(function() |
| 579 { | 579 { |
| 580 propertyFiltersLoaded = true; | 580 elemHideEmulationLoaded = true; |
| 581 checkLoaded(); | 581 checkLoaded(); |
| 582 }); | 582 }); |
| 583 } | 583 } |
| 584 }; | 584 }; |
| 585 | 585 |
| 586 if (document instanceof HTMLDocument) | 586 if (document instanceof HTMLDocument) |
| 587 { | 587 { |
| 588 checkSitekey(); | 588 checkSitekey(); |
| 589 wrapWebSocket(); | 589 wrapWebSocket(); |
| 590 | 590 |
| 591 var elemhide = new ElemHide(); | 591 var elemhide = new ElemHide(); |
| 592 elemhide.apply(); | 592 elemhide.apply(); |
| 593 | 593 |
| 594 document.addEventListener("error", function(event) | 594 document.addEventListener("error", function(event) |
| 595 { | 595 { |
| 596 checkCollapse(event.target); | 596 checkCollapse(event.target); |
| 597 }, true); | 597 }, true); |
| 598 | 598 |
| 599 document.addEventListener("load", function(event) | 599 document.addEventListener("load", function(event) |
| 600 { | 600 { |
| 601 var element = event.target; | 601 var element = event.target; |
| 602 if (/^i?frame$/.test(element.localName)) | 602 if (/^i?frame$/.test(element.localName)) |
| 603 checkCollapse(element); | 603 checkCollapse(element); |
| 604 }, true); | 604 }, true); |
| 605 } | 605 } |
| OLD | NEW |