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: Created June 29, 2015, 11:21 a.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') | locale/en-US/options.json » ('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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 } 140 }
141 }; 141 };
142 142
143 modules.filterClasses = { 143 modules.filterClasses = {
144 BlockingFilter: function() {}, 144 BlockingFilter: function() {},
145 Filter: function(text) 145 Filter: function(text)
146 { 146 {
147 this.text = text; 147 this.text = text;
148 this.disabled = false; 148 this.disabled = false;
149 } 149 },
150 WhitelistFilter: function() {}
150 }; 151 };
151 modules.filterClasses.Filter.fromText = function(text) 152 modules.filterClasses.Filter.fromText = function(text)
152 { 153 {
153 return new modules.filterClasses.Filter(text); 154 return new modules.filterClasses.Filter(text);
154 }; 155 };
155 156
157 modules.filterValidation =
158 {
159 parseFilter: function(text)
160 {
161 return {filter: modules.filterClasses.Filter.fromText(text)};
162 },
163 parseFilters: function(text)
164 {
165 var lines = text.split("\n");
166 var filters = [];
167 var errors = [];
168
169 for (var i = 0; i < lines.length; i++)
170 filters.push(modules.filterValidation.parseFilter(lines[i]).filter);
171
172 return {filters: filters, errors: errors};
173 }
174 };
175
156 modules.synchronizer = { 176 modules.synchronizer = {
157 Synchronizer: {} 177 Synchronizer: {}
158 }; 178 };
159 179
160 modules.matcher = { 180 modules.matcher = {
161 defaultMatcher: { 181 defaultMatcher: {
162 matchesAny: function(url, requestType, docDomain, thirdParty) 182 matchesAny: function(url, requestType, docDomain, thirdParty)
163 { 183 {
164 var params = {blockedURLs: ""}; 184 var params = {blockedURLs: ""};
165 updateFromURL(params); 185 updateFromURL(params);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 { 234 {
215 return parseFloat(v1) - parseFloat(v2); 235 return parseFloat(v1) - parseFloat(v2);
216 } 236 }
217 } 237 }
218 }; 238 };
219 239
220 var filters = [ 240 var filters = [
221 "@@||alternate.de^$document", 241 "@@||alternate.de^$document",
222 "@@||der.postillion.com^$document", 242 "@@||der.postillion.com^$document",
223 "@@||taz.de^$document", 243 "@@||taz.de^$document",
224 "@@||amazon.de^$document" 244 "@@||amazon.de^$document",
245 "||biglemon.am/bg_poster/banner.jpg",
246 "winfuture.de###header_logo_link",
247 "###WerbungObenRechts10_GesamtDIV",
248 "###WerbungObenRechts8_GesamtDIV",
249 "###WerbungObenRechts9_GesamtDIV",
250 "###WerbungUntenLinks4_GesamtDIV",
251 "###WerbungUntenLinks7_GesamtDIV",
252 "###WerbungUntenLinks8_GesamtDIV",
253 "###WerbungUntenLinks9_GesamtDIV",
254 "###Werbung_Sky",
255 "###Werbung_Wide",
256 "###__ligatus_placeholder__",
257 "###ad-bereich1-08",
258 "###ad-bereich1-superbanner",
259 "###ad-bereich2-08",
260 "###ad-bereich2-skyscrapper"
225 ]; 261 ];
226 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); 262 var knownFilters = filters.map(modules.filterClasses.Filter.fromText);
263 global.WhitelistFilter = modules.filterClasses.WhitelistFilter;
Thomas Greiner 2015/06/30 09:23:26 This does not need to be in the global namespace.
saroyanm 2015/07/08 18:25:38 Done.
227 264
228 var subscriptions = [ 265 var subscriptions = [
229 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", 266 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
230 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", 267 "https://easylist-downloads.adblockplus.org/exceptionrules.txt",
231 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", 268 "https://easylist-downloads.adblockplus.org/fanboy-social.txt",
232 "~user~786254" 269 "~user~786254"
233 ]; 270 ];
234 var knownSubscriptions = Object.create(null); 271 var knownSubscriptions = Object.create(null);
235 for (var subscriptionUrl of subscriptions) 272 for (var subscriptionUrl of subscriptions)
236 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); 273 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl);
(...skipping 16 matching lines...) Expand all
253 type: "message", 290 type: "message",
254 payload: { 291 payload: {
255 title: "Custom subscription", 292 title: "Custom subscription",
256 url: "http://example.com/custom.txt", 293 url: "http://example.com/custom.txt",
257 type: "add-subscription" 294 type: "add-subscription"
258 } 295 }
259 }, "*"); 296 }, "*");
260 }, 1000); 297 }, 1000);
261 } 298 }
262 })(this); 299 })(this);
OLDNEW
« no previous file with comments | « no previous file | locale/en-US/options.json » ('j') | locale/en-US/options.json » ('J')

Powered by Google App Engine
This is Rietveld