| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 const {RegExpFilter, | 20 const {RegExpFilter, WhitelistFilter, ElemHideFilter} = |
| 21 WhitelistFilter, | 21 require("filterClasses"); |
| 22 ElemHideFilter} = require("filterClasses"); | |
| 23 const {SpecialSubscription} = require("subscriptionClasses"); | 22 const {SpecialSubscription} = require("subscriptionClasses"); |
| 24 const {FilterStorage} = require("filterStorage"); | 23 const {FilterStorage} = require("filterStorage"); |
| 25 const {defaultMatcher} = require("matcher"); | 24 const {defaultMatcher} = require("matcher"); |
| 26 const {FilterNotifier} = require("filterNotifier"); | 25 const {FilterNotifier} = require("filterNotifier"); |
| 27 const {extractHostFromFrame} = require("url"); | 26 const {extractHostFromFrame} = require("url"); |
| 28 const {port} = require("messaging"); | 27 const {port} = require("messaging"); |
| 29 | 28 |
| 30 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", "GENERICBLOCK", "GENERICHIDE"]; | 29 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", "GENERICBLOCK", "GENERICHIDE"]; |
| 31 | 30 |
| 32 // Mapping of inspected tabs to their devpanel page | 31 // Mapping of inspected tabs to their devpanel page |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 74 } |
| 76 | 75 |
| 77 function hasRecord(panel, request, filter) | 76 function hasRecord(panel, request, filter) |
| 78 { | 77 { |
| 79 return panel.records.some(record => | 78 return panel.records.some(record => |
| 80 record.request.url == request.url && | 79 record.request.url == request.url && |
| 81 record.request.docDomain == request.docDomain && | 80 record.request.docDomain == request.docDomain && |
| 82 | 81 |
| 83 // Ignore partial (e.g. ELEMHIDE) whitelisting if there is already | 82 // Ignore partial (e.g. ELEMHIDE) whitelisting if there is already |
| 84 // a DOCUMENT exception which disables all means of blocking. | 83 // a DOCUMENT exception which disables all means of blocking. |
| 85 (record.request.type == "DOCUMENT" ? | 84 ( |
| 86 nonRequestTypes.includes(request.type) : | 85 record.request.type == "DOCUMENT" ? |
| 87 record.request.type == request.type) && | 86 nonRequestTypes.includes(request.type) : |
| 87 record.request.type == request.type |
| 88 ) && |
| 88 | 89 |
| 89 // Matched element hiding filters don't relate to a particular request, | 90 // Matched element hiding filters don't relate to a particular request, |
| 90 // so we have to compare the selector in order to avoid duplicates. | 91 // so we have to compare the selector in order to avoid duplicates. |
| 91 (record.filter && record.filter.selector) == (filter && filter.selector) | 92 (record.filter && record.filter.selector) == (filter && filter.selector) |
| 92 ); | 93 ); |
| 93 } | 94 } |
| 94 | 95 |
| 95 function addRecord(panel, request, filter) | 96 function addRecord(panel, request, filter) |
| 96 { | 97 { |
| 97 if (!hasRecord(panel, request, filter)) | 98 if (!hasRecord(panel, request, filter)) |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 panels.set(inspectedTabId, {port: newPort, records: []}); | 378 panels.set(inspectedTabId, {port: newPort, records: []}); |
| 378 }); | 379 }); |
| 379 | 380 |
| 380 port.on("devtools.traceElemHide", (message, sender) => | 381 port.on("devtools.traceElemHide", (message, sender) => |
| 381 { | 382 { |
| 382 logHiddenElements( | 383 logHiddenElements( |
| 383 sender.page, message.selectors, message.filters, | 384 sender.page, message.selectors, message.filters, |
| 384 extractHostFromFrame(sender.frame) | 385 extractHostFromFrame(sender.frame) |
| 385 ); | 386 ); |
| 386 }); | 387 }); |
| OLD | NEW |