| Index: lib/filterClasses.js |
| =================================================================== |
| --- a/lib/filterClasses.js |
| +++ b/lib/filterClasses.js |
| @@ -45,16 +45,25 @@ Filter.prototype = |
| /** |
| * Filter subscriptions the filter belongs to |
| * @type Subscription[] |
| */ |
| subscriptions: null, |
| /** |
| + * Filter type as a string, e.g. "blocking". |
| + * @type String |
| + */ |
| + get type() |
| + { |
| + throw new Error("Please define filter type in the subclass"); |
| + }, |
| + |
| + /** |
| * Serializes the filter to an array of strings for writing out on the disk. |
| * @param {string[]} buffer buffer to push the serialization results into |
| */ |
| serialize: function(buffer) |
| { |
| buffer.push("[Filter]"); |
| buffer.push("text=" + this.text); |
| }, |
| @@ -201,16 +210,18 @@ function InvalidFilter(text, reason) |
| this.reason = reason; |
| } |
| exports.InvalidFilter = InvalidFilter; |
| InvalidFilter.prototype = |
| { |
| __proto__: Filter.prototype, |
| + type: "invalid", |
| + |
| /** |
| * Reason why this filter is invalid |
| * @type String |
| */ |
| reason: null, |
| /** |
| * See Filter.serialize() |
| @@ -229,16 +240,18 @@ function CommentFilter(text) |
| Filter.call(this, text); |
| } |
| exports.CommentFilter = CommentFilter; |
| CommentFilter.prototype = |
| { |
| __proto__: Filter.prototype, |
| + type: "comment", |
| + |
| /** |
| * See Filter.serialize() |
| */ |
| serialize: function(buffer) {} |
| }; |
| /** |
| * Abstract base class for filters that can get hits |
| @@ -796,16 +809,18 @@ function BlockingFilter(text, regexpSour |
| this.collapse = collapse; |
| } |
| exports.BlockingFilter = BlockingFilter; |
| BlockingFilter.prototype = |
| { |
| __proto__: RegExpFilter.prototype, |
| + type: "blocking", |
| + |
| /** |
| * Defines whether the filter should collapse blocked content. Can be null (use the global preference). |
| * @type Boolean |
| */ |
| collapse: null |
| }; |
| /** |
| @@ -823,17 +838,19 @@ BlockingFilter.prototype = |
| function WhitelistFilter(text, regexpSource, contentType, matchCase, domains, thirdParty, sitekeys) |
| { |
| RegExpFilter.call(this, text, regexpSource, contentType, matchCase, domains, thirdParty, sitekeys); |
| } |
| exports.WhitelistFilter = WhitelistFilter; |
| WhitelistFilter.prototype = |
| { |
| - __proto__: RegExpFilter.prototype |
| + __proto__: RegExpFilter.prototype, |
| + |
| + type: "whitelist" |
| }; |
| /** |
| * Base class for element hiding filters |
| * @param {String} text see Filter() |
| * @param {String} [domains] Host names or domains the filter should be restricted to |
| * @param {String} selector CSS selector for the HTML elements that should be hidden |
| * @constructor |
| @@ -954,17 +971,19 @@ ElemHideBase.fromText = function(text, d |
| function ElemHideFilter(text, domains, selector) |
| { |
| ElemHideBase.call(this, text, domains, selector); |
| } |
| exports.ElemHideFilter = ElemHideFilter; |
| ElemHideFilter.prototype = |
| { |
| - __proto__: ElemHideBase.prototype |
| + __proto__: ElemHideBase.prototype, |
| + |
| + type: "elemhide" |
| }; |
| /** |
| * Class for element hiding exceptions |
| * @param {String} text see Filter() |
| * @param {String} domains see ElemHideBase() |
| * @param {String} selector see ElemHideBase() |
| * @constructor |
| @@ -973,17 +992,19 @@ ElemHideFilter.prototype = |
| function ElemHideException(text, domains, selector) |
| { |
| ElemHideBase.call(this, text, domains, selector); |
| } |
| exports.ElemHideException = ElemHideException; |
| ElemHideException.prototype = |
| { |
| - __proto__: ElemHideBase.prototype |
| + __proto__: ElemHideBase.prototype, |
| + |
| + type: "elemhideexception" |
| }; |
| /** |
| * Class for CSS property filters |
| * @param {String} text see Filter() |
| * @param {String} domains see ElemHideBase() |
| * @param {String} selector see ElemHideBase() |
| * @param {String} regexpSource see CSSPropertyFilter.regexpSource |
| @@ -1002,16 +1023,18 @@ function CSSPropertyFilter(text, domains |
| this.selectorSuffix = selectorSuffix; |
| } |
| exports.CSSPropertyFilter = CSSPropertyFilter; |
| CSSPropertyFilter.prototype = |
| { |
| __proto__: ElemHideBase.prototype, |
| + type: "cssproperty", |
| + |
| /** |
| * Expression from which a regular expression should be generated for matching |
| * CSS properties - for delayed creation of the regexpString property |
| * @type String |
| */ |
| regexpSource: null, |
| /** |
| * Substring of CSS selector before properties for the HTML elements that |