| Index: abp2blocklist.js |
| =================================================================== |
| --- a/abp2blocklist.js |
| +++ b/abp2blocklist.js |
| @@ -5,6 +5,7 @@ |
| var typeMap = filterClasses.RegExpFilter.typeMap; |
| +var params = {}; |
| var requestFilters = []; |
| var requestExceptions = []; |
| var elemhideFilters = []; |
| @@ -69,6 +70,18 @@ |
| recordSelectorException(filter); |
| } |
| +function parseLine(line) { |
| + var paramMatch = /^\s*!\s*([\w ]+)\s*:\s*(.*)/.exec(line); |
|
Sebastian Noack
2015/10/13 11:25:08
I think we should leave the parsing to the core co
|
| + if (paramMatch) { |
| + var key = paramMatch[1]; |
| + var paramsToKeep = ["version", "title", "last modified", "expires", "homepage", "licence"]; |
| + if (paramsToKeep.indexOf(key.toLowerCase()) != -1) |
| + params[key] = paramMatch[2]; |
| + return; |
| + } |
| + parseFilter(line); |
| +} |
| + |
| function escapeRegExp(s) { |
| return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); |
| } |
| @@ -265,9 +278,12 @@ |
| for (i = 0; i < requestExceptions.length; i++) |
| addRule(convertFilter(requestExceptions[i], "ignore-previous-rules", true)); |
| + for (key in params) |
| + if (params.hasOwnProperty(key)) |
| + console.log("// " + key + ": " + params[key]); |
|
Sebastian Noack
2015/10/13 11:25:08
But anyway, valid JSON cannot have comments. So NO
Felix Dahlke
2015/10/13 11:37:26
Did you read https://issues.adblockplus.org/ticket
Felix Dahlke
2015/10/13 11:52:15
But well, different approaches shouldn't be discus
|
| console.log(JSON.stringify(rules, null, "\t")); |
| } |
| var rl = readline.createInterface({input: process.stdin, terminal: false}); |
| -rl.on("line", parseFilter); |
| +rl.on("line", parseLine); |
| rl.on("close", logRules); |