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-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 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 } | 77 } |
78 | 78 |
79 function hasRecord(panel, request, filter) | 79 function hasRecord(panel, request, filter) |
80 { | 80 { |
81 return panel.records.some(record => | 81 return panel.records.some(record => |
82 record.request.url == request.url && | 82 record.request.url == request.url && |
83 record.request.docDomain == request.docDomain && | 83 record.request.docDomain == request.docDomain && |
84 | 84 |
85 // Ignore partial (e.g. ELEMHIDE) whitelisting if there is already | 85 // Ignore partial (e.g. ELEMHIDE) whitelisting if there is already |
86 // a DOCUMENT exception which disables all means of blocking. | 86 // a DOCUMENT exception which disables all means of blocking. |
87 ( | 87 (record.request.type == "DOCUMENT" ? |
88 record.request.type == "DOCUMENT" ? | 88 nonRequestTypes.includes(request.type) : |
89 nonRequestTypes.indexOf(request.type) != -1 : | 89 record.request.type == request.type) && |
90 record.request.type == request.type | |
91 ) && | |
92 | 90 |
93 // Matched element hiding filters don't relate to a particular request, | 91 // Matched element hiding filters don't relate to a particular request, |
94 // so we also have to match the CSS selector in order to distinguish them. | 92 // so we have to compare the selector in order to avoid duplicates. |
95 (record.filter && record.filter.selector) == (filter && filter.selector) | 93 (record.filter && record.filter.selector) == (filter && filter.selector) |
96 ); | 94 ); |
97 } | 95 } |
98 | 96 |
99 function addRecord(panel, request, filter) | 97 function addRecord(panel, request, filter) |
100 { | 98 { |
101 if (!hasRecord(panel, request, filter)) | 99 if (!hasRecord(panel, request, filter)) |
102 { | 100 { |
103 panel.port.postMessage({ | 101 panel.port.postMessage({ |
104 type: "add-record", | 102 type: "add-record", |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 * @param {?BlockingFilter} filter The matched filter or null if there is no | 134 * @param {?BlockingFilter} filter The matched filter or null if there is no |
137 * match | 135 * match |
138 */ | 136 */ |
139 exports.logRequest = function(page, url, type, docDomain, | 137 exports.logRequest = function(page, url, type, docDomain, |
140 thirdParty, sitekey, | 138 thirdParty, sitekey, |
141 specificOnly, filter) | 139 specificOnly, filter) |
142 { | 140 { |
143 let panel = getActivePanel(page); | 141 let panel = getActivePanel(page); |
144 if (panel) | 142 if (panel) |
145 { | 143 { |
146 addRecord(panel, {url, type, docDomain, thirdParty, sitekey, specificOnly}, | 144 let request = {url, type, docDomain, thirdParty, sitekey, specificOnly}; |
Sebastian Noack
2017/03/29 17:14:16
I'd rather keep the "request" variable, in order t
kzar
2017/03/30 07:20:48
Done.
| |
147 filter); | 145 addRecord(panel, request, filter); |
148 } | 146 } |
149 }; | 147 }; |
150 | 148 |
151 /** | 149 /** |
152 * Logs active element hiding filters to the devtools panel. | 150 * Logs active element hiding filters to the devtools panel. |
153 * | 151 * |
154 * @param {Page} page The page the elements were hidden on | 152 * @param {Page} page The page the elements were hidden on |
155 * @param {string[]} selectors The CSS selectors of active elemhide filters | 153 * @param {string[]} selectors The CSS selectors of active elemhide filters |
156 * @param {string} docDomain The IDN-decoded hostname of the document | 154 * @param {string} docDomain The IDN-decoded hostname of the document |
157 */ | 155 */ |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 panels[inspectedTabId] = {port: newPort, records: []}; | 377 panels[inspectedTabId] = {port: newPort, records: []}; |
380 }); | 378 }); |
381 | 379 |
382 port.on("devtools.traceElemHide", (message, sender) => | 380 port.on("devtools.traceElemHide", (message, sender) => |
383 { | 381 { |
384 logHiddenElements( | 382 logHiddenElements( |
385 sender.page, message.selectors, | 383 sender.page, message.selectors, |
386 extractHostFromFrame(sender.frame) | 384 extractHostFromFrame(sender.frame) |
387 ); | 385 ); |
388 }); | 386 }); |
LEFT | RIGHT |