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

Side by Side Diff: lib/snippets.js

Issue 29865583: Issue 6886 - Return snippet filters instead of just scripts (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: rename it getFiltersForDomain Created Aug. 27, 2018, 12: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 | test/snippets.js » ('j') | no next file with comments »
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 /** 54 /**
55 * Removes a snippet filter 55 * Removes a snippet filter
56 * @param {SnippetFilter} filter 56 * @param {SnippetFilter} filter
57 */ 57 */
58 remove(filter) 58 remove(filter)
59 { 59 {
60 filters.delete(filter.text); 60 filters.delete(filter.text);
61 }, 61 },
62 62
63 /** 63 /**
64 * Returns a list of all scripts active on a particular domain 64 * Returns a list of all snippet filters active on a particular domain
65 * @param {string} domain 65 * @param {string} domain
66 * @return {string[]} 66 * @return {Filter[]}
67 */ 67 */
68 getScriptsForDomain(domain) 68 getSnippetsForDomain(domain)
69 { 69 {
70 let result = []; 70 let result = [];
71 for (let text of filters) 71 for (let text of filters)
72 { 72 {
73 let filter = Filter.fromText(text); 73 let filter = Filter.fromText(text);
74 if (filter.isActiveOnDomain(domain)) 74 if (filter.isActiveOnDomain(domain))
75 result.push(filter.script); 75 result.push(filter);
76 } 76 }
77 return result; 77 return result;
78 } 78 }
79 }; 79 };
80 80
81 exports.Snippets = Snippets; 81 exports.Snippets = Snippets;
82 82
83 /** 83 /**
84 * Parses a script and returns a list of all its commands and their arguments 84 * Parses a script and returns a list of all its commands and their arguments
85 * @param {string} script 85 * @param {string} script
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 let value = imports[name]; 188 let value = imports[name];
189 if (typeof value == "function") 189 if (typeof value == "function")
190 value(...args); 190 value(...args);
191 } 191 }
192 } 192 }
193 } 193 }
194 `; 194 `;
195 } 195 }
196 196
197 exports.compileScript = compileScript; 197 exports.compileScript = compileScript;
OLDNEW
« no previous file with comments | « no previous file | test/snippets.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld