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-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 14 matching lines...) Expand all Loading... |
25 const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 25 const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
26 const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); | 26 const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); |
27 | 27 |
28 const {filterStorage} = require("./filterStorage"); | 28 const {filterStorage} = require("./filterStorage"); |
29 const {filterNotifier} = require("./filterNotifier"); | 29 const {filterNotifier} = require("./filterNotifier"); |
30 const {ElemHide} = require("./elemHide"); | 30 const {ElemHide} = require("./elemHide"); |
31 const {ElemHideEmulation} = require("./elemHideEmulation"); | 31 const {ElemHideEmulation} = require("./elemHideEmulation"); |
32 const {ElemHideExceptions} = require("./elemHideExceptions"); | 32 const {ElemHideExceptions} = require("./elemHideExceptions"); |
33 const {Snippets} = require("./snippets"); | 33 const {Snippets} = require("./snippets"); |
34 const {defaultMatcher} = require("./matcher"); | 34 const {defaultMatcher} = require("./matcher"); |
35 const {ActiveFilter, RegExpFilter, | 35 const {Filter, ActiveFilter, RegExpFilter, |
36 ElemHideBase, ElemHideFilter, ElemHideEmulationFilter, | 36 ElemHideBase, ElemHideFilter, ElemHideEmulationFilter, |
37 SnippetFilter} = require("./filterClasses"); | 37 SnippetFilter} = require("./filterClasses"); |
38 const {SpecialSubscription} = require("./subscriptionClasses"); | 38 const {SpecialSubscription} = require("./subscriptionClasses"); |
39 const {Prefs} = require("prefs"); | 39 const {Prefs} = require("prefs"); |
40 | 40 |
41 /** | 41 /** |
42 * Increases on filter changes, filters will be saved if it exceeds 1. | 42 * Increases on filter changes, filters will be saved if it exceeds 1. |
43 * @type {number} | 43 * @type {number} |
44 */ | 44 */ |
45 let isDirty = 0; | 45 let isDirty = 0; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 else if (filter instanceof SnippetFilter) | 216 else if (filter instanceof SnippetFilter) |
217 Snippets.remove(filter); | 217 Snippets.remove(filter); |
218 } | 218 } |
219 | 219 |
220 function onSubscriptionAdded(subscription) | 220 function onSubscriptionAdded(subscription) |
221 { | 221 { |
222 FilterListener.setDirty(1); | 222 FilterListener.setDirty(1); |
223 | 223 |
224 if (!subscription.disabled) | 224 if (!subscription.disabled) |
225 { | 225 { |
226 for (let filter of subscription.filters()) | 226 for (let text of subscription.filterText()) |
227 addFilter(filter); | 227 addFilter(Filter.fromText(text)); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 function onSubscriptionRemoved(subscription) | 231 function onSubscriptionRemoved(subscription) |
232 { | 232 { |
233 FilterListener.setDirty(1); | 233 FilterListener.setDirty(1); |
234 | 234 |
235 if (!subscription.disabled) | 235 if (!subscription.disabled) |
236 { | 236 { |
237 for (let filter of subscription.filters()) | 237 for (let text of subscription.filterText()) |
238 removeFilter(filter); | 238 removeFilter(Filter.fromText(text)); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 function onSubscriptionDisabled(subscription, newValue) | 242 function onSubscriptionDisabled(subscription, newValue) |
243 { | 243 { |
244 FilterListener.setDirty(1); | 244 FilterListener.setDirty(1); |
245 | 245 |
246 if (filterStorage.knownSubscriptions.has(subscription.url)) | 246 if (filterStorage.knownSubscriptions.has(subscription.url)) |
247 { | 247 { |
248 if (newValue == false) | 248 if (newValue == false) |
249 { | 249 { |
250 for (let filter of subscription.filters()) | 250 for (let text of subscription.filterText()) |
251 addFilter(filter); | 251 addFilter(Filter.fromText(text)); |
252 } | 252 } |
253 else | 253 else |
254 { | 254 { |
255 for (let filter of subscription.filters()) | 255 for (let text of subscription.filterText()) |
256 removeFilter(filter); | 256 removeFilter(Filter.fromText(text)); |
257 } | 257 } |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 function onSubscriptionUpdated(subscription, oldFilters) | 261 function onSubscriptionUpdated(subscription, oldFilterText) |
262 { | 262 { |
263 FilterListener.setDirty(1); | 263 FilterListener.setDirty(1); |
264 | 264 |
265 if (!subscription.disabled && | 265 if (!subscription.disabled && |
266 filterStorage.knownSubscriptions.has(subscription.url)) | 266 filterStorage.knownSubscriptions.has(subscription.url)) |
267 { | 267 { |
268 for (let filter of oldFilters) | 268 for (let text of oldFilterText) |
269 removeFilter(filter); | 269 removeFilter(Filter.fromText(text)); |
270 | 270 |
271 for (let filter of subscription.filters()) | 271 for (let text of subscription.filterText()) |
272 addFilter(filter); | 272 addFilter(Filter.fromText(text)); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 function onFilterHitCount(filter, newValue) | 276 function onFilterHitCount(filter, newValue) |
277 { | 277 { |
278 if (newValue == 0) | 278 if (newValue == 0) |
279 FilterListener.setDirty(0); | 279 FilterListener.setDirty(0); |
280 else | 280 else |
281 FilterListener.setDirty(0.002); | 281 FilterListener.setDirty(0.002); |
282 } | 282 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 defaultMatcher.clear(); | 324 defaultMatcher.clear(); |
325 ElemHide.clear(); | 325 ElemHide.clear(); |
326 ElemHideEmulation.clear(); | 326 ElemHideEmulation.clear(); |
327 ElemHideExceptions.clear(); | 327 ElemHideExceptions.clear(); |
328 Snippets.clear(); | 328 Snippets.clear(); |
329 | 329 |
330 for (let subscription of filterStorage.subscriptions()) | 330 for (let subscription of filterStorage.subscriptions()) |
331 { | 331 { |
332 if (!subscription.disabled) | 332 if (!subscription.disabled) |
333 { | 333 { |
334 for (let filter of subscription.filters()) | 334 for (let text of subscription.filterText()) |
335 addFilter(filter); | 335 addFilter(Filter.fromText(text)); |
336 } | 336 } |
337 } | 337 } |
338 } | 338 } |
339 | 339 |
340 function onSave() | 340 function onSave() |
341 { | 341 { |
342 isDirty = 0; | 342 isDirty = 0; |
343 } | 343 } |
OLD | NEW |