| 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 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 // | 450 // |
| 451 // Also, using shadow DOM causes issues on some Google websites, | 451 // Also, using shadow DOM causes issues on some Google websites, |
| 452 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687). | 452 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687). |
| 453 if ("createShadowRoot" in document.documentElement && | 453 if ("createShadowRoot" in document.documentElement && |
| 454 !/\.(?:google|blogger)\.com$/.test(document.domain)) | 454 !/\.(?:google|blogger)\.com$/.test(document.domain)) |
| 455 { | 455 { |
| 456 shadow = document.documentElement.createShadowRoot(); | 456 shadow = document.documentElement.createShadowRoot(); |
| 457 shadow.appendChild(document.createElement("shadow")); | 457 shadow.appendChild(document.createElement("shadow")); |
| 458 | 458 |
| 459 // Stop the website from messing with our shadowRoot | 459 // Stop the website from messing with our shadowRoot |
| 460 runInDocument(document, function() | 460 if ("shadowRoot" in Element.prototype) |
| 461 { | 461 { |
| 462 var ourShadowRoot = document.documentElement.shadowRoot; | 462 runInDocument(document, function() |
| 463 var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoot"
); | 463 { |
| 464 var shadowRoot = Function.prototype.call.bind(desc.get); | 464 var ourShadowRoot = document.documentElement.shadowRoot; |
| 465 var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoo
t"); |
| 466 var shadowRoot = Function.prototype.call.bind(desc.get); |
| 465 | 467 |
| 466 Object.defineProperty(Element.prototype, "shadowRoot", { | 468 Object.defineProperty(Element.prototype, "shadowRoot", { |
| 467 conifgurable: true, enumerable: true, get: function() | 469 conifgurable: true, enumerable: true, get: function() |
| 468 { | 470 { |
| 469 var shadow = shadowRoot(this); | 471 var shadow = shadowRoot(this); |
| 470 return shadow == ourShadowRoot ? null : shadow; | 472 return shadow == ourShadowRoot ? null : shadow; |
| 471 } | 473 } |
| 472 }); | 474 }); |
| 473 }, null); | 475 }, null); |
| 476 } |
| 474 } | 477 } |
| 475 | 478 |
| 476 function addElemHideSelectors(selectors) | 479 function addElemHideSelectors(selectors) |
| 477 { | 480 { |
| 478 if (selectors.length == 0) | 481 if (selectors.length == 0) |
| 479 return; | 482 return; |
| 480 | 483 |
| 481 if (!style) | 484 if (!style) |
| 482 { | 485 { |
| 483 // Create <style> element lazily, only if we add styles. Add it to | 486 // Create <style> element lazily, only if we add styles. Add it to |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 }, true); | 611 }, true); |
| 609 | 612 |
| 610 return updateStylesheet; | 613 return updateStylesheet; |
| 611 } | 614 } |
| 612 | 615 |
| 613 if (document instanceof HTMLDocument) | 616 if (document instanceof HTMLDocument) |
| 614 { | 617 { |
| 615 checkSitekey(); | 618 checkSitekey(); |
| 616 window.updateStylesheet = init(document); | 619 window.updateStylesheet = init(document); |
| 617 } | 620 } |
| OLD | NEW |