| 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 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 { | 152 { |
| 153 browser.tabs.reload(tabId, {bypassCache: true}); | 153 browser.tabs.reload(tabId, {bypassCache: true}); |
| 154 | 154 |
| 155 panel.reload = false; | 155 panel.reload = false; |
| 156 panel.reloading = true; | 156 panel.reloading = true; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 function updateFilters(subscription, filters, added) | 160 function updateFilters(subscription, filters, added) |
| 161 { | 161 { |
| 162 let includes = subscription ? | 162 let includes = subscription ? |
|
Manish Jethani
2018/12/18 17:12:16
It seems the parentheses are not required.
For in
Jon Sonesen
2018/12/19 10:05:20
Done.
Manish Jethani
2018/12/19 10:25:16
It should be aligned with the "b" in "subscription
| |
| 163 (filter => subscription.searchFilter(filter) != -1) : | 163 filter => filter && subscription.searchfilter(filter) != -1 : |
| 164 filters.includes.bind(filters); | 164 filters.includes.bind(filters); |
| 165 | 165 |
| 166 for (let panel of panels.values()) | 166 for (let panel of panels.values()) |
| 167 { | 167 { |
| 168 for (let i = 0; i < panel.records.length; i++) | 168 for (let i = 0; i < panel.records.length; i++) |
| 169 { | 169 { |
| 170 let record = panel.records[i]; | 170 let record = panel.records[i]; |
| 171 | 171 |
| 172 // If an added filter matches a request shown in the devtools panel, | 172 // If an added filter matches a request shown in the devtools panel, |
| 173 // update that record to show the new filter. Ignore filters that aren't | 173 // update that record to show the new filter. Ignore filters that aren't |
| 174 // associated with any sub-resource request. There is no record for these | 174 // associated with any sub-resource request. There is no record for these |
| 175 // if they don't already match. In particular, in case of element hiding | 175 // if they don't already match. In particular, in case of element hiding |
| 176 // filters, we also wouldn't know if any new element matches. | 176 // filters, we also wouldn't know if any new element matches. |
| 177 if (added) | 177 if (added) |
| 178 { | 178 { |
| 179 if (nonRequestTypes.includes(record.request.type)) | 179 if (nonRequestTypes.includes(record.request.type)) |
| 180 continue; | 180 continue; |
| 181 | 181 |
| 182 let filter = matchRequest(record.request); | 182 let filter = matchRequest(record.request); |
| 183 | 183 |
| 184 if (filter) | 184 if (!includes(filter)) |
|
kzar
2018/12/18 11:29:57
Nit: Please add braces since the body spans more t
| |
| 185 if (!includes(filter)) | 185 continue; |
|
kzar
2018/12/18 11:29:57
Woudln't it make more sense to do this:
if (filte
Manish Jethani
2018/12/18 17:12:16
This would have to be:
if (!filter || !includes
Jon Sonesen
2018/12/19 10:05:20
Done.
| |
| 186 continue; | |
| 187 | 186 |
| 188 record.filter = filter; | 187 record.filter = filter; |
| 189 } | 188 } |
| 190 | 189 |
| 191 // If a filter shown in the devtools panel got removed, update that | 190 // If a filter shown in the devtools panel got removed, update that |
| 192 // record to show the filter that matches now, or none, instead. | 191 // record to show the filter that matches now, or none, instead. |
| 193 // For filters that aren't associated with any sub-resource request, | 192 // For filters that aren't associated with any sub-resource request, |
| 194 // just remove the record. We wouldn't know whether another filter | 193 // just remove the record. We wouldn't know whether another filter |
| 195 // matches instead until the page is reloaded. | 194 // matches instead until the page is reloaded. |
| 196 else | 195 else |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 214 panel.port.postMessage({ | 213 panel.port.postMessage({ |
| 215 type: "update-record", | 214 type: "update-record", |
| 216 index: i, | 215 index: i, |
| 217 request: record.request, | 216 request: record.request, |
| 218 filter: getFilterInfo(record.filter) | 217 filter: getFilterInfo(record.filter) |
| 219 }); | 218 }); |
| 220 } | 219 } |
| 221 } | 220 } |
| 222 } | 221 } |
| 223 | 222 |
| 224 function onFilterAdded(filter, subscription) | 223 function onFilterAdded(filter) |
|
kzar
2018/12/18 11:29:57
It seems weird to add the `subscription` parameter
Jon Sonesen
2018/12/19 10:05:20
Done.
kzar
2018/12/19 10:16:52
Thanks, but why did you add it in the first place?
| |
| 225 { | 224 { |
| 226 updateFilters(null, [filter], true); | 225 updateFilters(null, [filter], true); |
| 227 } | 226 } |
| 228 | 227 |
| 229 function onFilterRemoved(filter, subscription) | 228 function onFilterRemoved(filter) |
| 230 { | 229 { |
| 231 updateFilters(null, [filter], false); | 230 updateFilters(null, [filter], false); |
| 232 } | 231 } |
| 233 | 232 |
| 234 function onSubscriptionAdded(subscription) | 233 function onSubscriptionAdded(subscription) |
| 235 { | 234 { |
| 236 if (subscription instanceof SpecialSubscription) | 235 if (subscription instanceof SpecialSubscription) |
| 237 updateFilters(subscription, null, true); | 236 updateFilters(subscription, null, true); |
| 238 } | 237 } |
| 239 | 238 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 ext.pages.onLoading.removeListener(onLoading); | 275 ext.pages.onLoading.removeListener(onLoading); |
| 277 filterNotifier.off("filter.added", onFilterAdded); | 276 filterNotifier.off("filter.added", onFilterAdded); |
| 278 filterNotifier.off("filter.removed", onFilterRemoved); | 277 filterNotifier.off("filter.removed", onFilterRemoved); |
| 279 filterNotifier.off("subscription.added", onSubscriptionAdded); | 278 filterNotifier.off("subscription.added", onSubscriptionAdded); |
| 280 } | 279 } |
| 281 }); | 280 }); |
| 282 | 281 |
| 283 HitLogger.addListener(inspectedTabId, hitListener); | 282 HitLogger.addListener(inspectedTabId, hitListener); |
| 284 panels.set(inspectedTabId, panel); | 283 panels.set(inspectedTabId, panel); |
| 285 }); | 284 }); |
| LEFT | RIGHT |