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

Delta Between Two Patch Sets: abp2blocklist.js

Issue 29336349: Issue 3585 - Merge element hiding rules for the same domain (Closed)
Left Patch Set: Addressed more feedback Created Feb. 16, 2016, 3 p.m.
Right Patch Set: Fixed mistake in generated JSON structure Created Feb. 16, 2016, 7:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 "use strict"; 1 "use strict";
2 2
3 let readline = require("readline"); 3 let readline = require("readline");
4 let punycode = require("punycode"); 4 let punycode = require("punycode");
5 let tldjs = require("tldjs"); 5 let tldjs = require("tldjs");
6 let filterClasses = require("./adblockplus.js"); 6 let filterClasses = require("./adblockplus.js");
7 7
8 let typeMap = filterClasses.RegExpFilter.typeMap; 8 let typeMap = filterClasses.RegExpFilter.typeMap;
9 9
10 const selectorLimit = 5000; 10 const selectorLimit = 5000;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 result.matchDomains = ["^https?://"]; 275 result.matchDomains = ["^https?://"];
276 276
277 for (let matchDomain of result.matchDomains) 277 for (let matchDomain of result.matchDomains)
278 { 278 {
279 let group = groupedElemhideFilters.get(matchDomain) || []; 279 let group = groupedElemhideFilters.get(matchDomain) || [];
280 group.push(result.selector); 280 group.push(result.selector);
281 groupedElemhideFilters.set(matchDomain, group); 281 groupedElemhideFilters.set(matchDomain, group);
282 } 282 }
283 } 283 }
284 284
285 groupedElemhideFilters.forEach((selectors, domain) => 285 groupedElemhideFilters.forEach((selectors, matchDomain) =>
286 { 286 {
287 while (selectors.length) 287 while (selectors.length)
288 { 288 {
289 addRule({ 289 addRule({
290 trigger: {"url-filter": domain}, 290 trigger: {"url-filter": matchDomain},
291 action: {type: "css-display-none"}, 291 action: {type: "css-display-none",
292 selector: selectors.splice(0, selectorLimit).join(", ") 292 selector: selectors.splice(0, selectorLimit).join(", ")}
293 }); 293 });
294 } 294 }
295 }); 295 });
296 296
297 for (let filter of elemhideExceptions) 297 for (let filter of elemhideExceptions)
298 addRule(convertFilter(filter, "ignore-previous-rules", false)); 298 addRule(convertFilter(filter, "ignore-previous-rules", false));
299 299
300 for (let filter of requestFilters) 300 for (let filter of requestFilters)
301 addRule(convertFilter(filter, "block", true)); 301 addRule(convertFilter(filter, "block", true));
302 for (let filter of requestExceptions) 302 for (let filter of requestExceptions)
303 addRule(convertFilter(filter, "ignore-previous-rules", true)); 303 addRule(convertFilter(filter, "ignore-previous-rules", true));
304 304
305 console.log(JSON.stringify(rules, null, "\t")); 305 console.log(JSON.stringify(rules, null, "\t"));
306 } 306 }
307 307
308 let rl = readline.createInterface({input: process.stdin, terminal: false}); 308 let rl = readline.createInterface({input: process.stdin, terminal: false});
309 rl.on("line", parseFilter); 309 rl.on("line", parseFilter);
310 rl.on("close", logRules); 310 rl.on("close", logRules);
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld