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

Side by Side Diff: abp2blocklist.js

Issue 29336525: Issue 3584 - Work around WebKit uppercase ID matching bug (Closed)
Patch Set: Created Feb. 16, 2016, 7:43 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, matchDomain) => 285 groupedElemhideFilters.forEach((selectors, matchDomain) =>
286 { 286 {
287 while (selectors.length) 287 while (selectors.length)
288 { 288 {
289 let selector = selectors.splice(0, selectorLimit).join(", ");
289 addRule({ 290 addRule({
290 trigger: {"url-filter": matchDomain}, 291 trigger: {"url-filter": matchDomain},
291 action: {type: "css-display-none", 292 action: {type: "css-display-none",
292 selector: selectors.splice(0, selectorLimit).join(", ")} 293 selector: selector}
293 }); 294 });
295
296 // FIXME - Hack to work around WebKit bug whereby element IDs are
Sebastian Noack 2016/02/17 08:04:28 I feel that this won't be just a temporary workaro
kzar 2016/02/17 13:45:26 Done.
297 // converted to lowercase before being matched.
298 let lowercaseSelector = selector.replace(
299 /#[\w-]+/g, match => match.toLowerCase()
Sebastian Noack 2016/02/17 08:04:28 ID selectors can have escaped special chars, e.g #
kzar 2016/02/17 13:45:26 Acknowledged.
300 );
301 if (lowercaseSelector != selector)
302 addRule({
Sebastian Noack 2016/02/17 08:04:28 Ideally, we merge the lowercase variants with the
kzar 2016/02/17 13:45:26 Acknowledged.
303 trigger: {"url-filter": matchDomain},
304 action: {type: "css-display-none",
305 selector: lowercaseSelector}
306 });
294 } 307 }
295 }); 308 });
296 309
297 for (let filter of elemhideExceptions) 310 for (let filter of elemhideExceptions)
298 addRule(convertFilter(filter, "ignore-previous-rules", false)); 311 addRule(convertFilter(filter, "ignore-previous-rules", false));
299 312
300 for (let filter of requestFilters) 313 for (let filter of requestFilters)
301 addRule(convertFilter(filter, "block", true)); 314 addRule(convertFilter(filter, "block", true));
302 for (let filter of requestExceptions) 315 for (let filter of requestExceptions)
303 addRule(convertFilter(filter, "ignore-previous-rules", true)); 316 addRule(convertFilter(filter, "ignore-previous-rules", true));
304 317
305 console.log(JSON.stringify(rules, null, "\t")); 318 console.log(JSON.stringify(rules, null, "\t"));
306 } 319 }
307 320
308 let rl = readline.createInterface({input: process.stdin, terminal: false}); 321 let rl = readline.createInterface({input: process.stdin, terminal: false});
309 rl.on("line", parseFilter); 322 rl.on("line", parseFilter);
310 rl.on("close", logRules); 323 rl.on("close", logRules);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld