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: Addressed initial comments Created July 8, 2015, 6:13 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 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 },
150 WhitelistFilter: function(text)
151 {
152 modules.filterClasses.Filter.call(this, text);
149 } 153 }
150 }; 154 };
151 modules.filterClasses.Filter.fromText = function(text) 155 modules.filterClasses.Filter.fromText = function(text)
152 { 156 {
157 if (text.indexOf("@@") == 0)
158 return new modules.filterClasses.WhitelistFilter(text);
153 return new modules.filterClasses.Filter(text); 159 return new modules.filterClasses.Filter(text);
154 }; 160 };
155 161
162 modules.filterValidation =
163 {
164 parseFilter: function(text)
165 {
166 return {filter: modules.filterClasses.Filter.fromText(text)};
167 },
168 parseFilters: function(text)
169 {
170 var lines = text.split("\n");
171 var filters = [];
172 var errors = [];
173
174 for (var i = 0; i < lines.length; i++)
175 filters.push(modules.filterValidation.parseFilter(lines[i]).filter);
176
177 return {filters: filters, errors: errors};
178 }
179 };
180
156 modules.synchronizer = { 181 modules.synchronizer = {
157 Synchronizer: {} 182 Synchronizer: {}
158 }; 183 };
159 184
160 modules.matcher = { 185 modules.matcher = {
161 defaultMatcher: { 186 defaultMatcher: {
162 matchesAny: function(url, requestType, docDomain, thirdParty) 187 matchesAny: function(url, requestType, docDomain, thirdParty)
163 { 188 {
164 var params = {blockedURLs: ""}; 189 var params = {blockedURLs: ""};
165 updateFromURL(params); 190 updateFromURL(params);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 { 239 {
215 return parseFloat(v1) - parseFloat(v2); 240 return parseFloat(v1) - parseFloat(v2);
216 } 241 }
217 } 242 }
218 }; 243 };
219 244
220 var filters = [ 245 var filters = [
221 "@@||alternate.de^$document", 246 "@@||alternate.de^$document",
222 "@@||der.postillion.com^$document", 247 "@@||der.postillion.com^$document",
223 "@@||taz.de^$document", 248 "@@||taz.de^$document",
224 "@@||amazon.de^$document" 249 "@@||amazon.de^$document",
250 "||biglemon.am/bg_poster/banner.jpg",
251 "winfuture.de###header_logo_link",
252 "###WerbungObenRechts10_GesamtDIV",
253 "###WerbungObenRechts8_GesamtDIV",
254 "###WerbungObenRechts9_GesamtDIV",
255 "###WerbungUntenLinks4_GesamtDIV",
256 "###WerbungUntenLinks7_GesamtDIV",
257 "###WerbungUntenLinks8_GesamtDIV",
258 "###WerbungUntenLinks9_GesamtDIV",
259 "###Werbung_Sky",
260 "###Werbung_Wide",
261 "###__ligatus_placeholder__",
262 "###ad-bereich1-08",
263 "###ad-bereich1-superbanner",
264 "###ad-bereich2-08",
265 "###ad-bereich2-skyscrapper"
225 ]; 266 ];
226 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); 267 var knownFilters = filters.map(modules.filterClasses.Filter.fromText);
227 268
228 var subscriptions = [ 269 var subscriptions = [
229 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", 270 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
230 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", 271 "https://easylist-downloads.adblockplus.org/exceptionrules.txt",
231 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", 272 "https://easylist-downloads.adblockplus.org/fanboy-social.txt",
232 "~user~786254" 273 "~user~786254"
233 ]; 274 ];
234 var knownSubscriptions = Object.create(null); 275 var knownSubscriptions = Object.create(null);
(...skipping 18 matching lines...) Expand all
253 type: "message", 294 type: "message",
254 payload: { 295 payload: {
255 title: "Custom subscription", 296 title: "Custom subscription",
256 url: "http://example.com/custom.txt", 297 url: "http://example.com/custom.txt",
257 type: "add-subscription" 298 type: "add-subscription"
258 } 299 }
259 }, "*"); 300 }, "*");
260 }, 1000); 301 }, 1000);
261 } 302 }
262 })(this); 303 })(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