| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 |
| 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 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 let {splitSelector} = require("./adblockpluscore/lib/common"); | |
| 21 let {ElemHideEmulation} = | 20 let {ElemHideEmulation} = |
| 22 require("./adblockpluscore/lib/content/elemHideEmulation"); | 21 require("./adblockpluscore/lib/content/elemHideEmulation"); |
| 23 | 22 |
| 24 // This variable is also used by our other content scripts. | 23 // This variable is also used by our other content scripts. |
| 25 let contentFiltering; | 24 let contentFiltering; |
| 26 | 25 |
| 27 const typeMap = new Map([ | 26 const typeMap = new Map([ |
| 28 ["img", "IMAGE"], | 27 ["img", "IMAGE"], |
| 29 ["input", "IMAGE"], | 28 ["input", "IMAGE"], |
| 30 ["picture", "IMAGE"], | 29 ["picture", "IMAGE"], |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 } | 393 } |
| 395 }; | 394 }; |
| 396 | 395 |
| 397 function ContentFiltering() | 396 function ContentFiltering() |
| 398 { | 397 { |
| 399 this.styles = new Map(); | 398 this.styles = new Map(); |
| 400 this.tracer = null; | 399 this.tracer = null; |
| 401 this.inline = true; | 400 this.inline = true; |
| 402 | 401 |
| 403 this.elemHideEmulation = new ElemHideEmulation( | 402 this.elemHideEmulation = new ElemHideEmulation( |
| 404 () => {}, | 403 () => {}, |
|
Sebastian Noack
2018/09/29 00:18:47
It seems if ElemHideEmulation is no longer call ad
Manish Jethani
2018/09/29 01:58:50
Let's make this change part of https://codereview.
| |
| 405 this.hideElements.bind(this) | 404 this.hideElements.bind(this) |
| 406 ); | 405 ); |
| 407 } | 406 } |
| 408 ContentFiltering.prototype = { | 407 ContentFiltering.prototype = { |
| 409 selectorGroupSize: 1024, | 408 selectorGroupSize: 1024, |
| 410 | 409 |
| 411 addSelectorsInline(selectors, groupName, appendOnly = false) | 410 addSelectorsInline(selectors, groupName, appendOnly = false) |
| 412 { | 411 { |
| 413 let style = this.styles.get(groupName); | 412 let style = this.styles.get(groupName); |
| 414 | 413 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 // Once all supported platforms have implemented this API, we can remove | 469 // Once all supported platforms have implemented this API, we can remove |
| 471 // the code below. See issue #5090. | 470 // the code below. See issue #5090. |
| 472 // Related Chrome and Firefox issues: | 471 // Related Chrome and Firefox issues: |
| 473 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 | 472 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 |
| 474 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026 | 473 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026 |
| 475 this.addSelectorsInline(selectors, groupName, appendOnly); | 474 this.addSelectorsInline(selectors, groupName, appendOnly); |
| 476 } | 475 } |
| 477 else | 476 else |
| 478 { | 477 { |
| 479 browser.runtime.sendMessage({ | 478 browser.runtime.sendMessage({ |
| 480 type: "elemhide.injectSelectors", | 479 type: "content.injectSelectors", |
| 481 selectors, | 480 selectors, |
| 482 groupName, | 481 groupName, |
| 483 appendOnly | 482 appendOnly |
| 484 }); | 483 }); |
| 485 } | 484 } |
| 486 | 485 |
| 487 // Only trace selectors that are based directly on hiding filters | 486 // Only trace selectors that are based directly on hiding filters |
| 488 // (i.e. leave out collapsing selectors). | 487 // (i.e. leave out collapsing selectors). |
| 489 if (this.tracer && groupName != "collapsing") | 488 if (this.tracer && groupName != "collapsing") |
| 490 this.tracer.addSelectors(selectors, filters); | 489 this.tracer.addSelectors(selectors, filters); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 let element = event.target; | 549 let element = event.target; |
| 551 if (/^i?frame$/.test(element.localName)) | 550 if (/^i?frame$/.test(element.localName)) |
| 552 checkCollapse(element); | 551 checkCollapse(element); |
| 553 }, true); | 552 }, true); |
| 554 } | 553 } |
| 555 | 554 |
| 556 window.checkCollapse = checkCollapse; | 555 window.checkCollapse = checkCollapse; |
| 557 window.contentFiltering = contentFiltering; | 556 window.contentFiltering = contentFiltering; |
| 558 window.typeMap = typeMap; | 557 window.typeMap = typeMap; |
| 559 window.getURLsFromElement = getURLsFromElement; | 558 window.getURLsFromElement = getURLsFromElement; |
| LEFT | RIGHT |