Index: lib/filterListener.js |
=================================================================== |
--- a/lib/filterListener.js |
+++ b/lib/filterListener.js |
@@ -29,16 +29,17 @@ |
const {FilterNotifier} = require("./filterNotifier"); |
const {ElemHide} = require("./elemHide"); |
const {ElemHideEmulation} = require("./elemHideEmulation"); |
const {Snippets} = require("./snippets"); |
const {defaultMatcher} = require("./matcher"); |
const {ActiveFilter, RegExpFilter, |
ElemHideBase, 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} |
*/ |
let isDirty = 0; |
@@ -135,37 +136,48 @@ |
* @param {Filter} filter filter that has been added |
*/ |
function addFilter(filter) |
{ |
if (!(filter instanceof ActiveFilter) || filter.disabled) |
return; |
let hasEnabled = false; |
+ let allowSnippets = false; |
for (let i = 0; i < filter.subscriptions.length; i++) |
kzar
2018/07/10 14:38:35
Nit: `for (let subscription of filter.subscription
Manish Jethani
2018/07/10 18:33:22
I did this initially and then reverted it. There's
kzar
2018/07/10 18:56:00
Sure it's an unrelated change, but you're changing
Manish Jethani
2018/07/11 15:07:03
There are some performance implications of for..of
kzar
2018/07/11 17:22:07
Fine.
|
{ |
- if (!filter.subscriptions[i].disabled) |
+ let subscription = filter.subscriptions[i]; |
+ |
+ if (!subscription.disabled) |
{ |
hasEnabled = true; |
- break; |
+ |
+ // Allow snippets to be executed only by the circumvention lists or the |
+ // user's own filters. |
+ if (subscription.type == "circumvention" || |
+ subscription instanceof SpecialSubscription) |
+ { |
+ allowSnippets = true; |
+ break; |
+ } |
} |
} |
if (!hasEnabled) |
return; |
if (filter instanceof RegExpFilter) |
defaultMatcher.add(filter); |
else if (filter instanceof ElemHideBase) |
{ |
if (filter instanceof ElemHideEmulationFilter) |
ElemHideEmulation.add(filter); |
else |
ElemHide.add(filter); |
} |
- else if (filter instanceof SnippetFilter) |
+ else if (allowSnippets && filter instanceof SnippetFilter) |
Snippets.add(filter); |
} |
/** |
* Notifies Matcher instances or ElemHide object about removal of a filter |
* if necessary. |
* @param {Filter} filter filter that has been removed |
*/ |