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 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 { | 268 { |
269 let record = panel.records[i]; | 269 let record = panel.records[i]; |
270 | 270 |
271 // If an added filter matches a request shown in the devtools panel, | 271 // If an added filter matches a request shown in the devtools panel, |
272 // update that record to show the new filter. Ignore filters that aren't | 272 // update that record to show the new filter. Ignore filters that aren't |
273 // associated with any sub-resource request. There is no record for these | 273 // associated with any sub-resource request. There is no record for these |
274 // if they don't already match. In particular, in case of element hiding | 274 // if they don't already match. In particular, in case of element hiding |
275 // filters, we also wouldn't know if any new element matches. | 275 // filters, we also wouldn't know if any new element matches. |
276 if (added) | 276 if (added) |
277 { | 277 { |
278 if (nonRequestTypes.indexOf(record.request.type) != -1) | 278 if (nonRequestTypes.includes(record.request.type)) |
279 continue; | 279 continue; |
280 | 280 |
281 let filter = matchRequest(record.request); | 281 let filter = matchRequest(record.request); |
282 if (filters.indexOf(filter) == -1) | 282 if (!filters.includes(filter)) |
283 continue; | 283 continue; |
284 | 284 |
285 record.filter = filter; | 285 record.filter = filter; |
286 } | 286 } |
287 | 287 |
288 // If a filter shown in the devtools panel got removed, update that | 288 // If a filter shown in the devtools panel got removed, update that |
289 // record to show the filter that matches now, or none, instead. | 289 // record to show the filter that matches now, or none, instead. |
290 // For filters that aren't associated with any sub-resource request, | 290 // For filters that aren't associated with any sub-resource request, |
291 // just remove the record. We wouldn't know whether another filter | 291 // just remove the record. We wouldn't know whether another filter |
292 // matches instead until the page is reloaded. | 292 // matches instead until the page is reloaded. |
293 else | 293 else |
294 { | 294 { |
295 if (filters.indexOf(record.filter) == -1) | 295 if (!filters.includes(record.filter)) |
296 continue; | 296 continue; |
297 | 297 |
298 if (nonRequestTypes.indexOf(record.request.type) != -1) | 298 if (nonRequestTypes.includes(record.request.type)) |
299 { | 299 { |
300 panel.port.postMessage({ | 300 panel.port.postMessage({ |
301 type: "remove-record", | 301 type: "remove-record", |
302 index: i | 302 index: i |
303 }); | 303 }); |
304 panel.records.splice(i--, 1); | 304 panel.records.splice(i--, 1); |
305 continue; | 305 continue; |
306 } | 306 } |
307 | 307 |
308 record.filter = matchRequest(record.request); | 308 record.filter = matchRequest(record.request); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 panels.set(inspectedTabId, {port: newPort, records: []}); | 377 panels.set(inspectedTabId, {port: newPort, records: []}); |
378 }); | 378 }); |
379 | 379 |
380 port.on("devtools.traceElemHide", (message, sender) => | 380 port.on("devtools.traceElemHide", (message, sender) => |
381 { | 381 { |
382 logHiddenElements( | 382 logHiddenElements( |
383 sender.page, message.selectors, message.filters, | 383 sender.page, message.selectors, message.filters, |
384 extractHostFromFrame(sender.frame) | 384 extractHostFromFrame(sender.frame) |
385 ); | 385 ); |
386 }); | 386 }); |
OLD | NEW |