| LEFT | RIGHT |
| 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 22 matching lines...) Expand all Loading... |
| 33 /** | 33 /** |
| 34 * Container for snippet filters | 34 * Container for snippet filters |
| 35 * @class | 35 * @class |
| 36 */ | 36 */ |
| 37 let Snippets = Object.assign(new EventEmitter(), { | 37 let Snippets = Object.assign(new EventEmitter(), { |
| 38 /** | 38 /** |
| 39 * Removes all known filters | 39 * Removes all known filters |
| 40 */ | 40 */ |
| 41 clear() | 41 clear() |
| 42 { | 42 { |
| 43 if (filters.size == 0) |
| 44 return; |
| 45 |
| 43 filters.clear(); | 46 filters.clear(); |
| 44 | 47 |
| 45 this.emit("snippets.filtersCleared"); | 48 this.emit("snippets.filtersCleared"); |
| 46 }, | 49 }, |
| 47 | 50 |
| 48 /** | 51 /** |
| 49 * Add a new snippet filter | 52 * Add a new snippet filter |
| 50 * @param {SnippetFilter} filter | 53 * @param {SnippetFilter} filter |
| 51 */ | 54 */ |
| 52 add(filter) | 55 add(filter) |
| 53 { | 56 { |
| 57 let {size} = filters; |
| 58 |
| 54 filters.add(filter.text); | 59 filters.add(filter.text); |
| 55 | 60 |
| 56 this.emit("snippets.filterAdded", filter); | 61 if (size != filters.size) |
| 62 this.emit("snippets.filterAdded", filter); |
| 57 }, | 63 }, |
| 58 | 64 |
| 59 /** | 65 /** |
| 60 * Removes a snippet filter | 66 * Removes a snippet filter |
| 61 * @param {SnippetFilter} filter | 67 * @param {SnippetFilter} filter |
| 62 */ | 68 */ |
| 63 remove(filter) | 69 remove(filter) |
| 64 { | 70 { |
| 71 let {size} = filters; |
| 72 |
| 65 filters.delete(filter.text); | 73 filters.delete(filter.text); |
| 66 | 74 |
| 67 this.emit("snippets.filterRemoved", filter); | 75 if (size != filters.size) |
| 76 this.emit("snippets.filterRemoved", filter); |
| 68 }, | 77 }, |
| 69 | 78 |
| 70 /** | 79 /** |
| 71 * Returns a list of all scripts active on a particular domain | 80 * Returns a list of all scripts active on a particular domain |
| 72 * @param {string} domain | 81 * @param {string} domain |
| 73 * @return {string[]} | 82 * @return {string[]} |
| 74 */ | 83 */ |
| 75 getScriptsForDomain(domain) | 84 getScriptsForDomain(domain) |
| 76 { | 85 { |
| 77 let result = []; | 86 let result = []; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 let value = imports[name]; | 204 let value = imports[name]; |
| 196 if (typeof value == "function") | 205 if (typeof value == "function") |
| 197 value(...args); | 206 value(...args); |
| 198 } | 207 } |
| 199 } | 208 } |
| 200 } | 209 } |
| 201 `; | 210 `; |
| 202 } | 211 } |
| 203 | 212 |
| 204 exports.compileScript = compileScript; | 213 exports.compileScript = compileScript; |
| LEFT | RIGHT |