Index: lib/filterListener.js |
=================================================================== |
--- a/lib/filterListener.js |
+++ b/lib/filterListener.js |
@@ -27,17 +27,17 @@ |
const {filterStorage} = require("./filterStorage"); |
const {filterNotifier} = require("./filterNotifier"); |
const {ElemHide} = require("./elemHide"); |
const {ElemHideEmulation} = require("./elemHideEmulation"); |
const {ElemHideExceptions} = require("./elemHideExceptions"); |
const {Snippets} = require("./snippets"); |
const {defaultMatcher} = require("./matcher"); |
-const {ActiveFilter, RegExpFilter, |
+const {Filter, ActiveFilter, RegExpFilter, |
ElemHideBase, ElemHideFilter, ElemHideEmulationFilter, |
SnippetFilter} = require("./filterClasses"); |
const {SpecialSubscription} = require("./subscriptionClasses"); |
const {Prefs} = require("prefs"); |
/** |
* Increases on filter changes, filters will be saved if it exceeds 1. |
* @type {number} |
@@ -234,65 +234,69 @@ |
let current = (Math.random() * len) | 0; |
let step; |
do |
{ |
step = primes[(Math.random() * primes.length) | 0]; |
} while (len % step == 0); |
for (let i = 0; i < len; i++, current = (current + step) % len) |
- addFilter(subscription.filterAt(current)); |
+ { |
+ let filter = Filter.fromText(subscription.filterTextAt(current)); |
+ filter.addSubscription(subscription); |
Manish Jethani
2018/11/19 02:29:44
This was the bug. The filters did not belong to an
|
+ addFilter(filter); |
+ } |
} |
function onSubscriptionAdded(subscription) |
{ |
FilterListener.setDirty(1); |
if (!subscription.disabled) |
addSubscriptionFilters(subscription); |
} |
function onSubscriptionRemoved(subscription) |
{ |
FilterListener.setDirty(1); |
if (!subscription.disabled) |
{ |
- for (let filter of subscription.filters()) |
- removeFilter(filter); |
+ for (let text of subscription.filterText()) |
+ removeFilter(Filter.fromText(text)); |
} |
} |
function onSubscriptionDisabled(subscription, newValue) |
{ |
FilterListener.setDirty(1); |
if (filterStorage.knownSubscriptions.has(subscription.url)) |
{ |
if (newValue == false) |
{ |
addSubscriptionFilters(subscription); |
} |
else |
{ |
- for (let filter of subscription.filters()) |
- removeFilter(filter); |
+ for (let text of subscription.filterText()) |
+ removeFilter(Filter.fromText(text)); |
} |
} |
} |
-function onSubscriptionUpdated(subscription, oldFilters) |
+function onSubscriptionUpdated(subscription, oldFilterText) |
{ |
FilterListener.setDirty(1); |
if (!subscription.disabled && |
filterStorage.knownSubscriptions.has(subscription.url)) |
{ |
- for (let filter of oldFilters) |
- removeFilter(filter); |
+ for (let text of oldFilterText) |
+ removeFilter(Filter.fromText(text)); |
addSubscriptionFilters(subscription); |
} |
} |
function onFilterHitCount(filter, newValue) |
{ |
if (newValue == 0) |