| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-present eyeo GmbH | |
| 4 * | |
| 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 | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU General Public License | |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 16 */ | |
| 17 | |
| 18 "use strict"; | |
| 19 | |
| 20 /** | |
| 21 * @fileOverview Snippets implementation. | |
| 22 */ | |
| 23 | |
| 24 const {Filter} = require("./filterClasses"); | |
| 25 | |
| 26 let filters = new Set(); | |
| 27 | |
| 28 /** | |
| 29 * Container for snippet filters | |
| 30 * @class | |
| 31 */ | |
| 32 let Snippets = { | |
| 33 /** | |
| 34 * Removes all known filters | |
| 35 */ | |
| 36 clear() | |
| 37 { | |
| 38 filters.clear(); | |
| 39 }, | |
| 40 | |
| 41 /** | |
| 42 * Add a new snippet filter | |
| 43 * @param {SnippetFilter} filter | |
| 44 */ | |
| 45 add(filter) | |
| 46 { | |
| 47 filters.add(filter.text); | |
| 48 }, | |
| 49 | |
| 50 /** | |
| 51 * Removes a snippet filter | |
| 52 * @param {SnippetFilter} filter | |
| 53 */ | |
| 54 remove(filter) | |
| 55 { | |
| 56 filters.delete(filter.text); | |
| 57 }, | |
| 58 | |
| 59 /** | |
| 60 * Returns a list of all scripts active on a particular domain | |
| 61 * @param {string} domain | |
| 62 * @return {string[]} | |
| 63 */ | |
| 64 getScriptsForDomain(domain) | |
|
kzar
2018/07/10 12:53:23
This seems pretty inefficient. I would have expect
Manish Jethani
2018/07/10 18:29:21
See my comment here:
https://codereview.adblockpl
kzar
2018/07/10 18:54:00
Well, you're the expert.
Please could you add tha
Manish Jethani
2018/07/11 12:02:09
The issue is blocked by #6665 so it won't be close
kzar
2018/07/11 12:17:49
Well if we plan to do a release which includes #65
Manish Jethani
2018/07/11 12:45:18
OK, but we set the milestone on the Platform issue
kzar
2018/07/11 17:17:51
That's right.
| |
| 65 { | |
| 66 let result = []; | |
| 67 for (let text of filters) | |
| 68 { | |
| 69 let filter = Filter.fromText(text); | |
| 70 if (filter.isActiveOnDomain(domain)) | |
| 71 result.push(filter.script); | |
| 72 } | |
| 73 return result; | |
| 74 } | |
| 75 }; | |
| 76 | |
| 77 exports.Snippets = Snippets; | |
| OLD | NEW |