Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/filterListener.js

Issue 29737558: Issue 6538, 6781 - Implement support for snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Change ElemHideBase.fromText to ContentFilter.fromText Created July 6, 2018, 1:24 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/filterClasses.js ('k') | lib/snippets.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterListener.js
===================================================================
--- a/lib/filterListener.js
+++ b/lib/filterListener.js
@@ -24,19 +24,21 @@
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
const {FilterStorage} = require("./filterStorage");
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} = require("./filterClasses");
+ ElemHideBase, ElemHideEmulationFilter,
+ SnippetFilter} = require("./filterClasses");
const {Prefs} = require("prefs");
/**
* Increases on filter changes, filters will be saved if it exceeds 1.
* @type {number}
*/
let isDirty = 0;
@@ -153,16 +155,18 @@
defaultMatcher.add(filter);
else if (filter instanceof ElemHideBase)
{
if (filter instanceof ElemHideEmulationFilter)
ElemHideEmulation.add(filter);
else
ElemHide.add(filter);
}
+ else if (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
*/
function removeFilter(filter)
@@ -189,16 +193,18 @@
defaultMatcher.remove(filter);
else if (filter instanceof ElemHideBase)
{
if (filter instanceof ElemHideEmulationFilter)
ElemHideEmulation.remove(filter);
else
ElemHide.remove(filter);
}
+ else if (filter instanceof SnippetFilter)
+ Snippets.remove(filter);
}
const primes = [101, 109, 131, 149, 163, 179, 193, 211, 229, 241];
function addFilters(filters)
{
// We add filters using pseudo-random ordering. Reason is that ElemHide will
// assign consecutive filter IDs that might be visible to the website. The
@@ -308,16 +314,17 @@
function onLoad()
{
isDirty = 0;
defaultMatcher.clear();
ElemHide.clear();
ElemHideEmulation.clear();
+ Snippets.clear();
for (let subscription of FilterStorage.subscriptions)
{
if (!subscription.disabled)
addFilters(subscription.filters);
}
}
function onSave()
« no previous file with comments | « lib/filterClasses.js ('k') | lib/snippets.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld