Index: lib/filterListener.js |
=================================================================== |
--- a/lib/filterListener.js |
+++ b/lib/filterListener.js |
@@ -212,47 +212,25 @@ |
ElemHideEmulation.remove(filter); |
else |
ElemHideExceptions.remove(filter); |
} |
else if (filter instanceof SnippetFilter) |
Snippets.remove(filter); |
} |
-const primes = [101, 109, 131, 149, 163, 179, 193, 211, 229, 241]; |
- |
-function addSubscriptionFilters(subscription) |
-{ |
- // We add filters using pseudo-random ordering. Reason is that ElemHide will |
- // assign consecutive filter IDs that might be visible to the website. The |
- // randomization makes sure that no conclusion can be made about the actual |
- // filters applying there. We have ten prime numbers to use as iteration step, |
- // any of those can be chosen as long as the array length isn't divisible by |
- // it. |
- let len = subscription.filterCount; |
- if (!len) |
- return; |
- |
- 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)); |
-} |
- |
function onSubscriptionAdded(subscription) |
{ |
FilterListener.setDirty(1); |
if (!subscription.disabled) |
- addSubscriptionFilters(subscription); |
+ { |
+ for (let filter of subscription.filters()) |
+ addFilter(filter); |
+ } |
} |
function onSubscriptionRemoved(subscription) |
{ |
FilterListener.setDirty(1); |
if (!subscription.disabled) |
{ |
@@ -264,17 +242,18 @@ |
function onSubscriptionDisabled(subscription, newValue) |
{ |
FilterListener.setDirty(1); |
if (filterStorage.knownSubscriptions.has(subscription.url)) |
{ |
if (newValue == false) |
{ |
- addSubscriptionFilters(subscription); |
+ for (let filter of subscription.filters()) |
+ addFilter(filter); |
} |
else |
{ |
for (let filter of subscription.filters()) |
removeFilter(filter); |
} |
} |
} |
@@ -284,17 +263,18 @@ |
FilterListener.setDirty(1); |
if (!subscription.disabled && |
filterStorage.knownSubscriptions.has(subscription.url)) |
{ |
for (let filter of oldFilters) |
removeFilter(filter); |
- addSubscriptionFilters(subscription); |
+ for (let filter of subscription.filters()) |
+ addFilter(filter); |
} |
} |
function onFilterHitCount(filter, newValue) |
{ |
if (newValue == 0) |
FilterListener.setDirty(0); |
else |
@@ -345,16 +325,19 @@ |
ElemHide.clear(); |
ElemHideEmulation.clear(); |
ElemHideExceptions.clear(); |
Snippets.clear(); |
for (let subscription of filterStorage.subscriptions()) |
{ |
if (!subscription.disabled) |
- addSubscriptionFilters(subscription); |
+ { |
+ for (let filter of subscription.filters()) |
+ addFilter(filter); |
+ } |
} |
} |
function onSave() |
{ |
isDirty = 0; |
} |