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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 /** | 107 /** |
108 * Initializes filter listener on startup, registers the necessary hooks. | 108 * Initializes filter listener on startup, registers the necessary hooks. |
109 */ | 109 */ |
110 function init() | 110 function init() |
111 { | 111 { |
112 FilterNotifier.on("filter.hitCount", onFilterHitCount); | 112 FilterNotifier.on("filter.hitCount", onFilterHitCount); |
113 FilterNotifier.on("filter.lastHit", onFilterLastHit); | 113 FilterNotifier.on("filter.lastHit", onFilterLastHit); |
114 FilterNotifier.on("filter.added", onFilterAdded); | 114 FilterNotifier.on("filter.added", onFilterAdded); |
115 FilterNotifier.on("filter.removed", onFilterRemoved); | 115 FilterNotifier.on("filter.removed", onFilterRemoved); |
116 FilterNotifier.on("filter.disabled", onFilterDisabled); | 116 FilterNotifier.on("filter.disabled", onFilterDisabled); |
117 FilterNotifier.on("filter.moved", onGenericChange); | |
117 | 118 |
118 FilterNotifier.on("subscription.added", onSubscriptionAdded); | 119 FilterNotifier.on("subscription.added", onSubscriptionAdded); |
119 FilterNotifier.on("subscription.removed", onSubscriptionRemoved); | 120 FilterNotifier.on("subscription.removed", onSubscriptionRemoved); |
120 FilterNotifier.on("subscription.disabled", onSubscriptionDisabled); | 121 FilterNotifier.on("subscription.disabled", onSubscriptionDisabled); |
121 FilterNotifier.on("subscription.updated", onSubscriptionUpdated); | 122 FilterNotifier.on("subscription.updated", onSubscriptionUpdated); |
123 FilterNotifier.on("subscription.moved", onGenericChange); | |
124 FilterNotifier.on("subscription.title", onGenericChange); | |
125 FilterNotifier.on("subscription.fixedTitle", onGenericChange); | |
126 FilterNotifier.on("subscription.homepage", onGenericChange); | |
127 FilterNotifier.on("subscription.downloadStatus", onGenericChange); | |
128 FilterNotifier.on("subscription.lastCheck", onGenericChange); | |
129 FilterNotifier.on("subscription.errors", onGenericChange); | |
122 | 130 |
123 FilterNotifier.on("load", onLoad); | 131 FilterNotifier.on("load", onLoad); |
124 FilterNotifier.on("save", onSave); | 132 FilterNotifier.on("save", onSave); |
125 | 133 |
126 | 134 |
127 if ("nsIStyleSheetService" in Ci) | 135 if ("nsIStyleSheetService" in Ci) |
128 ElemHide.init(); | 136 ElemHide.init(); |
129 else | 137 else |
130 flushElemHide = function() {}; // No global stylesheet in Chrome & Co. | 138 flushElemHide = function() {}; // No global stylesheet in Chrome & Co. |
131 FilterStorage.loadFromDisk(); | 139 FilterStorage.loadFromDisk(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 CSSRules.remove(filter); | 211 CSSRules.remove(filter); |
204 else | 212 else |
205 ElemHide.remove(filter); | 213 ElemHide.remove(filter); |
206 } | 214 } |
207 } | 215 } |
208 | 216 |
209 function onSubscriptionAdded(subscription) | 217 function onSubscriptionAdded(subscription) |
210 { | 218 { |
211 FilterListener.setDirty(1); | 219 FilterListener.setDirty(1); |
212 | 220 |
213 if (subscription.url in FilterStorage.knownSubscriptions && !subscription.disa bled) | 221 if (!subscription.disabled) |
kzar
2016/03/23 16:02:32
Nit: Mind wrapping this long line?
Wladimir Palant
2016/03/23 16:12:39
`subscription.url in FilterStorage.knownSubscripti
Sebastian Noack
2016/03/23 17:56:09
Done.
| |
214 { | 222 { |
215 subscription.filters.forEach(addFilter); | 223 subscription.filters.forEach(addFilter); |
216 flushElemHide(); | 224 flushElemHide(); |
217 } | 225 } |
218 } | 226 } |
219 | 227 |
220 function onSubscriptionRemoved(subscription) | 228 function onSubscriptionRemoved(subscription) |
221 { | 229 { |
222 FilterListener.setDirty(1); | 230 FilterListener.setDirty(1); |
223 | 231 |
(...skipping 14 matching lines...) Expand all Loading... | |
238 subscription.filters.forEach(addFilter); | 246 subscription.filters.forEach(addFilter); |
239 else | 247 else |
240 subscription.filters.forEach(removeFilter); | 248 subscription.filters.forEach(removeFilter); |
241 flushElemHide(); | 249 flushElemHide(); |
242 } | 250 } |
243 } | 251 } |
244 | 252 |
245 function onSubscriptionUpdated(subscription) | 253 function onSubscriptionUpdated(subscription) |
246 { | 254 { |
247 FilterListener.setDirty(1); | 255 FilterListener.setDirty(1); |
248 | 256 |
kzar
2016/03/23 16:02:32
Nit: ... and this one.
Sebastian Noack
2016/03/23 17:56:09
Done.
| |
249 if (subscription.url in FilterStorage.knownSubscriptions && !subscription.disa bled) | 257 if (subscription.url in FilterStorage.knownSubscriptions && |
258 !subscription.disabled) | |
250 { | 259 { |
251 subscription.oldFilters.forEach(removeFilter); | 260 subscription.oldFilters.forEach(removeFilter); |
252 subscription.filters.forEach(addFilter); | 261 subscription.filters.forEach(addFilter); |
253 flushElemHide(); | 262 flushElemHide(); |
254 } | 263 } |
255 } | 264 } |
256 | 265 |
257 function onFilterHitCount(filter, newValue) | 266 function onFilterHitCount(filter, newValue) |
258 { | 267 { |
259 if (newValue == 0) | 268 if (newValue == 0) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 | 300 |
292 function onFilterDisabled(filter, newValue) | 301 function onFilterDisabled(filter, newValue) |
293 { | 302 { |
294 FilterListener.setDirty(1); | 303 FilterListener.setDirty(1); |
295 | 304 |
296 if (newValue == false) | 305 if (newValue == false) |
297 addFilter(filter); | 306 addFilter(filter); |
298 else | 307 else |
299 removeFilter(filter); | 308 removeFilter(filter); |
300 flushElemHide(); | 309 flushElemHide(); |
310 } | |
311 | |
312 function onGenericChange() | |
313 { | |
314 FilterListener.setDirty(1); | |
301 } | 315 } |
302 | 316 |
303 function onLoad() | 317 function onLoad() |
304 { | 318 { |
305 isDirty = 0; | 319 isDirty = 0; |
306 | 320 |
307 defaultMatcher.clear(); | 321 defaultMatcher.clear(); |
308 ElemHide.clear(); | 322 ElemHide.clear(); |
309 CSSRules.clear(); | 323 CSSRules.clear(); |
310 for (let subscription of FilterStorage.subscriptions) | 324 for (let subscription of FilterStorage.subscriptions) |
311 if (!subscription.disabled) | 325 if (!subscription.disabled) |
312 subscription.filters.forEach(addFilter); | 326 subscription.filters.forEach(addFilter); |
313 flushElemHide(); | 327 flushElemHide(); |
314 } | 328 } |
315 | 329 |
316 function onSave() | 330 function onSave() |
317 { | 331 { |
318 isDirty = 0; | 332 isDirty = 0; |
319 } | 333 } |
LEFT | RIGHT |