OLD | NEW |
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 let {selector} = exception; | 64 let {selector} = exception; |
65 let list = exceptions.get(selector); | 65 let list = exceptions.get(selector); |
66 if (list) | 66 if (list) |
67 list.push(exception); | 67 list.push(exception); |
68 else | 68 else |
69 exceptions.set(selector, [exception]); | 69 exceptions.set(selector, [exception]); |
70 | 70 |
71 knownExceptions.add(exception); | 71 knownExceptions.add(exception); |
72 | 72 |
73 this.emit("added", exception); | 73 this.emit("added", exception); |
| 74 |
| 75 FilterNotifier.emit("elemhideupdate"); |
74 }, | 76 }, |
75 | 77 |
76 /** | 78 /** |
77 * Removes an element hiding exception | 79 * Removes an element hiding exception |
78 * @param {ElemHideException} exception | 80 * @param {ElemHideException} exception |
79 */ | 81 */ |
80 remove(exception) | 82 remove(exception) |
81 { | 83 { |
82 if (!knownExceptions.has(exception)) | 84 if (!knownExceptions.has(exception)) |
83 return; | 85 return; |
84 | 86 |
85 let list = exceptions.get(exception.selector); | 87 let list = exceptions.get(exception.selector); |
86 let index = list.indexOf(exception); | 88 let index = list.indexOf(exception); |
87 if (index >= 0) | 89 if (index >= 0) |
88 list.splice(index, 1); | 90 list.splice(index, 1); |
89 | 91 |
90 knownExceptions.delete(exception); | 92 knownExceptions.delete(exception); |
91 | 93 |
92 this.emit("removed", exception); | 94 this.emit("removed", exception); |
| 95 |
| 96 FilterNotifier.emit("elemhideupdate"); |
93 }, | 97 }, |
94 | 98 |
95 /** | 99 /** |
96 * Checks whether any exception rules are registered for a selector | 100 * Checks whether any exception rules are registered for a selector |
97 * @param {string} selector | 101 * @param {string} selector |
98 * @returns {boolean} | 102 * @returns {boolean} |
99 */ | 103 */ |
100 hasExceptions(selector) | 104 hasExceptions(selector) |
101 { | 105 { |
102 return exceptions.has(selector); | 106 return exceptions.has(selector); |
(...skipping 14 matching lines...) Expand all Loading... |
117 | 121 |
118 for (let i = list.length - 1; i >= 0; i--) | 122 for (let i = list.length - 1; i >= 0; i--) |
119 { | 123 { |
120 if (list[i].isActiveOnDomain(docDomain)) | 124 if (list[i].isActiveOnDomain(docDomain)) |
121 return list[i]; | 125 return list[i]; |
122 } | 126 } |
123 | 127 |
124 return null; | 128 return null; |
125 } | 129 } |
126 }); | 130 }); |
OLD | NEW |