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

Unified Diff: background.js

Issue 29321198: Issue 2376 - Implement custom filters in new options page (Closed)
Patch Set: Created July 14, 2015, 1:11 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 | « no previous file | locale/en-US/options.json » ('j') | messageResponder.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -153,6 +153,44 @@
return new modules.filterClasses.Filter(text);
};
+ modules.filterValidation =
Sebastian Noack 2015/07/14 13:36:31 I wonder whezther this implementation might go a l
saroyanm 2015/07/14 13:53:28 parseFilter: In this case we wouldn't be able to r
Sebastian Noack 2015/07/14 14:10:09 Sorry, I meant: modules.filterValidation = {
Thomas Greiner 2015/07/14 14:20:29 That's true, for testing purposes we don't need to
Sebastian Noack 2015/07/14 14:25:27 +1 (this would also be in line with how we test th
saroyanm 2015/07/14 15:08:26 Please note that error should be an instance of "F
Sebastian Noack 2015/07/14 16:48:38 Actually, we don't need to implement the FilterPar
saroyanm 2015/07/14 18:28:27 Done.
+ {
+ FilterParsingError: function(type)
+ {
+ this.type = type;
+ },
+ parseFilter: function(text)
+ {
+ if (text)
+ {
+ if (text[0] == "[")
+ return {error: new modules.filterValidation.FilterParsingError("unexpected-filter-list-header")};
+ }
+ return {filter: modules.filterClasses.Filter.fromText(text)};
+ },
+ parseFilters: function(text)
+ {
+ var lines = text.split("\n");
+ var filters = [];
+ var errors = [];
+
+ for (var i = 0; i < lines.length; i++)
+ {
+ var parseResult = modules.filterValidation.parseFilter(lines[i]);
+ if (parseResult.error)
+ errors.push(parseResult.error);
+ else
+ filters.push(parseResult.filter);
+ }
+
+ return {filters: filters, errors: errors};
+ }
+ };
+ modules.filterValidation.FilterParsingError.prototype.toString = function()
+ {
+ return this.type;
+ };
+
modules.synchronizer = {
Synchronizer: {}
};
@@ -221,7 +259,23 @@
"@@||alternate.de^$document",
"@@||der.postillion.com^$document",
"@@||taz.de^$document",
- "@@||amazon.de^$document"
+ "@@||amazon.de^$document",
+ "||biglemon.am/bg_poster/banner.jpg",
+ "winfuture.de###header_logo_link",
+ "###WerbungObenRechts10_GesamtDIV",
+ "###WerbungObenRechts8_GesamtDIV",
+ "###WerbungObenRechts9_GesamtDIV",
+ "###WerbungUntenLinks4_GesamtDIV",
+ "###WerbungUntenLinks7_GesamtDIV",
+ "###WerbungUntenLinks8_GesamtDIV",
+ "###WerbungUntenLinks9_GesamtDIV",
+ "###Werbung_Sky",
+ "###Werbung_Wide",
+ "###__ligatus_placeholder__",
+ "###ad-bereich1-08",
+ "###ad-bereich1-superbanner",
+ "###ad-bereich2-08",
+ "###ad-bereich2-skyscrapper"
];
var knownFilters = filters.map(modules.filterClasses.Filter.fromText);
« no previous file with comments | « no previous file | locale/en-US/options.json » ('j') | messageResponder.js » ('J')

Powered by Google App Engine
This is Rietveld