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 11 matching lines...) Expand all Loading... |
22 * instances and ElemHide. | 22 * instances and ElemHide. |
23 */ | 23 */ |
24 | 24 |
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 {defaultMatcher} = require("./matcher"); | 33 const {defaultMatcher} = require("./matcher"); |
33 const {ActiveFilter, RegExpFilter, | 34 const {ActiveFilter, RegExpFilter, |
34 ElemHideBase, ElemHideEmulationFilter} = require("./filterClasses"); | 35 ElemHideBase, ElemHideEmulationFilter, |
| 36 ElemHideException} = require("./filterClasses"); |
35 const {Prefs} = require("prefs"); | 37 const {Prefs} = require("prefs"); |
36 | 38 |
37 /** | 39 /** |
38 * Increases on filter changes, filters will be saved if it exceeds 1. | 40 * Increases on filter changes, filters will be saved if it exceeds 1. |
39 * @type {number} | 41 * @type {number} |
40 */ | 42 */ |
41 let isDirty = 0; | 43 let isDirty = 0; |
42 | 44 |
43 /** | 45 /** |
44 * This object can be used to change properties of the filter change listeners. | 46 * This object can be used to change properties of the filter change listeners. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 if (!filter.subscriptions[i].disabled) | 145 if (!filter.subscriptions[i].disabled) |
144 hasEnabled = true; | 146 hasEnabled = true; |
145 } | 147 } |
146 if (!hasEnabled) | 148 if (!hasEnabled) |
147 return; | 149 return; |
148 | 150 |
149 if (filter instanceof RegExpFilter) | 151 if (filter instanceof RegExpFilter) |
150 defaultMatcher.add(filter); | 152 defaultMatcher.add(filter); |
151 else if (filter instanceof ElemHideBase) | 153 else if (filter instanceof ElemHideBase) |
152 { | 154 { |
| 155 if (filter instanceof ElemHideException) |
| 156 ElemHideExceptions.add(filter); |
153 if (filter instanceof ElemHideEmulationFilter) | 157 if (filter instanceof ElemHideEmulationFilter) |
154 ElemHideEmulation.add(filter); | 158 ElemHideEmulation.add(filter); |
155 else | 159 else |
156 ElemHide.add(filter); | 160 ElemHide.add(filter); |
157 } | 161 } |
158 } | 162 } |
159 | 163 |
160 /** | 164 /** |
161 * Notifies Matcher instances or ElemHide object about removal of a filter | 165 * Notifies Matcher instances or ElemHide object about removal of a filter |
162 * if necessary. | 166 * if necessary. |
(...skipping 13 matching lines...) Expand all Loading... |
176 hasEnabled = true; | 180 hasEnabled = true; |
177 } | 181 } |
178 if (hasEnabled) | 182 if (hasEnabled) |
179 return; | 183 return; |
180 } | 184 } |
181 | 185 |
182 if (filter instanceof RegExpFilter) | 186 if (filter instanceof RegExpFilter) |
183 defaultMatcher.remove(filter); | 187 defaultMatcher.remove(filter); |
184 else if (filter instanceof ElemHideBase) | 188 else if (filter instanceof ElemHideBase) |
185 { | 189 { |
| 190 if (filter instanceof ElemHideException) |
| 191 ElemHideExceptions.remove(filter); |
186 if (filter instanceof ElemHideEmulationFilter) | 192 if (filter instanceof ElemHideEmulationFilter) |
187 ElemHideEmulation.remove(filter); | 193 ElemHideEmulation.remove(filter); |
188 else | 194 else |
189 ElemHide.remove(filter); | 195 ElemHide.remove(filter); |
190 } | 196 } |
191 } | 197 } |
192 | 198 |
193 const primes = [101, 109, 131, 149, 163, 179, 193, 211, 229, 241]; | 199 const primes = [101, 109, 131, 149, 163, 179, 193, 211, 229, 241]; |
194 | 200 |
195 function addFilters(filters) | 201 function addFilters(filters) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 FilterListener.setDirty(1); | 306 FilterListener.setDirty(1); |
301 } | 307 } |
302 | 308 |
303 function onLoad() | 309 function onLoad() |
304 { | 310 { |
305 isDirty = 0; | 311 isDirty = 0; |
306 | 312 |
307 defaultMatcher.clear(); | 313 defaultMatcher.clear(); |
308 ElemHide.clear(); | 314 ElemHide.clear(); |
309 ElemHideEmulation.clear(); | 315 ElemHideEmulation.clear(); |
| 316 ElemHideExceptions.clear(); |
310 for (let subscription of FilterStorage.subscriptions) | 317 for (let subscription of FilterStorage.subscriptions) |
311 { | 318 { |
312 if (!subscription.disabled) | 319 if (!subscription.disabled) |
313 addFilters(subscription.filters); | 320 addFilters(subscription.filters); |
314 } | 321 } |
315 } | 322 } |
316 | 323 |
317 function onSave() | 324 function onSave() |
318 { | 325 { |
319 isDirty = 0; | 326 isDirty = 0; |
320 } | 327 } |
OLD | NEW |