LEFT | RIGHT |
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 Loading... |
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); |
LEFT | RIGHT |