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

Side by Side Diff: background.js

Issue 29321198: Issue 2376 - Implement custom filters in new options page (Closed)
Patch Set: updated mockup Created July 14, 2015, 3:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | locale/en-US/options.json » ('j') | messageResponder.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 { 146 {
147 this.text = text; 147 this.text = text;
148 this.disabled = false; 148 this.disabled = false;
149 } 149 }
150 }; 150 };
151 modules.filterClasses.Filter.fromText = function(text) 151 modules.filterClasses.Filter.fromText = function(text)
152 { 152 {
153 return new modules.filterClasses.Filter(text); 153 return new modules.filterClasses.Filter(text);
154 }; 154 };
155 155
156 modules.filterValidation =
157 {
158 FilterParsingError: function(type)
159 {
160 this.type = type;
161 },
162 parseFilter: function(text)
163 {
164 if (text[0] == "[")
165 return {error: new modules.filterValidation.FilterParsingError("Error-oc curred")};
166 else
167 return {filter: modules.filterClasses.Filter.fromText(text)};
168 },
169 parseFilters: function(text)
170 {
171 var lines = text.split("\n");
172 var filters = [];
173 var errors = [];
174
175 for (var i = 0; i < lines.length; i++)
176 {
177 var parseResult = modules.filterValidation.parseFilter(lines[i]);
178 if (parseResult.error)
179 errors.push(parseResult.error);
180 else
181 filters.push(parseResult.filter);
182 }
183
184 return {filters: filters, errors: errors};
185 }
186 };
187 modules.filterValidation.FilterParsingError.prototype.toString = function()
188 {
189 return this.type;
190 };
191
156 modules.synchronizer = { 192 modules.synchronizer = {
157 Synchronizer: {} 193 Synchronizer: {}
158 }; 194 };
159 195
160 modules.matcher = { 196 modules.matcher = {
161 defaultMatcher: { 197 defaultMatcher: {
162 matchesAny: function(url, requestType, docDomain, thirdParty) 198 matchesAny: function(url, requestType, docDomain, thirdParty)
163 { 199 {
164 var params = {blockedURLs: ""}; 200 var params = {blockedURLs: ""};
165 updateFromURL(params); 201 updateFromURL(params);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 { 250 {
215 return parseFloat(v1) - parseFloat(v2); 251 return parseFloat(v1) - parseFloat(v2);
216 } 252 }
217 } 253 }
218 }; 254 };
219 255
220 var filters = [ 256 var filters = [
221 "@@||alternate.de^$document", 257 "@@||alternate.de^$document",
222 "@@||der.postillion.com^$document", 258 "@@||der.postillion.com^$document",
223 "@@||taz.de^$document", 259 "@@||taz.de^$document",
224 "@@||amazon.de^$document" 260 "@@||amazon.de^$document",
261 "||biglemon.am/bg_poster/banner.jpg",
262 "winfuture.de###header_logo_link",
263 "###WerbungObenRechts10_GesamtDIV",
264 "###WerbungObenRechts8_GesamtDIV",
265 "###WerbungObenRechts9_GesamtDIV",
266 "###WerbungUntenLinks4_GesamtDIV",
267 "###WerbungUntenLinks7_GesamtDIV",
268 "###WerbungUntenLinks8_GesamtDIV",
269 "###WerbungUntenLinks9_GesamtDIV",
270 "###Werbung_Sky",
271 "###Werbung_Wide",
272 "###__ligatus_placeholder__",
273 "###ad-bereich1-08",
274 "###ad-bereich1-superbanner",
275 "###ad-bereich2-08",
276 "###ad-bereich2-skyscrapper"
225 ]; 277 ];
226 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); 278 var knownFilters = filters.map(modules.filterClasses.Filter.fromText);
227 279
228 var subscriptions = [ 280 var subscriptions = [
229 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", 281 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
230 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", 282 "https://easylist-downloads.adblockplus.org/exceptionrules.txt",
231 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", 283 "https://easylist-downloads.adblockplus.org/fanboy-social.txt",
232 "~user~786254" 284 "~user~786254"
233 ]; 285 ];
234 var knownSubscriptions = Object.create(null); 286 var knownSubscriptions = Object.create(null);
(...skipping 18 matching lines...) Expand all
253 type: "message", 305 type: "message",
254 payload: { 306 payload: {
255 title: "Custom subscription", 307 title: "Custom subscription",
256 url: "http://example.com/custom.txt", 308 url: "http://example.com/custom.txt",
257 type: "add-subscription" 309 type: "add-subscription"
258 } 310 }
259 }, "*"); 311 }, "*");
260 }, 1000); 312 }, 1000);
261 } 313 }
262 })(this); 314 })(this);
OLDNEW
« 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