Index: lib/devtools.js |
=================================================================== |
--- a/lib/devtools.js |
+++ b/lib/devtools.js |
@@ -15,19 +15,19 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
"use strict"; |
const {RegExpFilter, |
WhitelistFilter, |
ElemHideFilter} = require("../adblockpluscore/lib/filterClasses"); |
-const {SpecialSubscription} = |
+const {SpecialSubscription, Subscription} = |
require("../adblockpluscore/lib/subscriptionClasses"); |
-const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); |
+const {filterStorage} = require("../adblockpluscore/lib/filterStorage"); |
const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); |
const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier"); |
const {extractHostFromFrame} = require("./url"); |
const {port} = require("./messaging"); |
const {HitLogger, nonRequestTypes} = require("./hitLogger"); |
let panels = new Map(); |
@@ -152,18 +152,23 @@ |
{ |
browser.tabs.reload(tabId, {bypassCache: true}); |
panel.reload = false; |
panel.reloading = true; |
} |
} |
-function updateFilters(filters, added) |
+function updateFilters(filters, added, subscription = null) |
{ |
+ let includes = filters.includes.bind(filters); |
+ |
+ if (filters instanceof Subscription) |
+ includes = filter => filters.searchFilter(filter) != -1; |
+ |
for (let panel of panels.values()) |
{ |
for (let i = 0; i < panel.records.length; i++) |
{ |
let record = panel.records[i]; |
// If an added filter matches a request shown in the devtools panel, |
// update that record to show the new filter. Ignore filters that aren't |
@@ -171,30 +176,30 @@ |
// if they don't already match. In particular, in case of element hiding |
// filters, we also wouldn't know if any new element matches. |
if (added) |
{ |
if (nonRequestTypes.includes(record.request.type)) |
continue; |
let filter = matchRequest(record.request); |
- if (!filters.includes(filter)) |
+ if (!includes(filter)) |
continue; |
record.filter = filter; |
} |
// If a filter shown in the devtools panel got removed, update that |
// record to show the filter that matches now, or none, instead. |
// For filters that aren't associated with any sub-resource request, |
// just remove the record. We wouldn't know whether another filter |
// matches instead until the page is reloaded. |
else |
{ |
- if (!filters.includes(record.filter)) |
+ if (!includes(record.filter)) |
continue; |
if (nonRequestTypes.includes(record.request.type)) |
{ |
panel.port.postMessage({ |
type: "remove-record", |
index: i |
}); |
@@ -223,17 +228,17 @@ |
function onFilterRemoved(filter) |
{ |
updateFilters([filter], false); |
} |
function onSubscriptionAdded(subscription) |
{ |
if (subscription instanceof SpecialSubscription) |
- updateFilters(subscription.filters, true); |
+ updateFilters(subscription.filters, true, subscription); |
} |
browser.runtime.onConnect.addListener(newPort => |
{ |
let match = newPort.name.match(/^devtools-(\d+)$/); |
if (!match) |
return; |