| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 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/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * @fileOverview Element hiding exceptions implementation. | 21 * @fileOverview Element hiding exceptions implementation. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 const {EventEmitter} = require("./events"); | 24 const {EventEmitter} = require("./events"); |
| 25 const {FilterNotifier} = require("./filterNotifier"); | 25 const {FilterNotifier} = require("./filterNotifier"); |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Lookup table, lists of element hiding exceptions by selector | 28 * Lookup table, lists of element hiding exceptions by selector |
| 29 * @type {Map.<string,ElemHideException[]>} | 29 * @type {Map.<string,ElemHideException[]>} |
| 30 */ | 30 */ |
| 31 let exceptions = new Map(); | 31 let exceptions = new Map(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 * Checks whether any exception rules are registered for a selector | 100 * Checks whether any exception rules are registered for a selector |
| 101 * @param {string} selector | 101 * @param {string} selector |
| 102 * @returns {boolean} | 102 * @returns {boolean} |
| 103 */ | 103 */ |
| 104 hasExceptions(selector) | 104 hasExceptions(selector) |
| 105 { | 105 { |
| 106 return exceptions.has(selector); | 106 return exceptions.has(selector); |
| 107 }, | 107 }, |
| 108 | 108 |
| 109 /** | 109 /** |
| 110 * Checks whether an exception rule is registered for a filter on a particular | 110 * Checks whether an exception rule is registered for a selector on a |
| 111 * domain. | 111 * particular domain. |
| 112 * @param {ElemHideFilter|ElemHideEmulationFilter} filter | 112 * @param {string} selector |
| 113 * @param {?string} docDomain | 113 * @param {?string} docDomain |
| 114 * @return {?ElemHideException} | 114 * @return {?ElemHideException} |
| 115 */ | 115 */ |
| 116 getException(filter, docDomain) | 116 getException(selector, docDomain) |
| 117 { | 117 { |
| 118 let list = exceptions.get(filter.selector); | 118 let list = exceptions.get(selector); |
| 119 if (!list) | 119 if (!list) |
| 120 return null; | 120 return null; |
| 121 | 121 |
| 122 for (let i = list.length - 1; i >= 0; i--) | 122 for (let i = list.length - 1; i >= 0; i--) |
| 123 { | 123 { |
| 124 if (list[i].isActiveOnDomain(docDomain)) | 124 if (list[i].isActiveOnDomain(docDomain)) |
| 125 return list[i]; | 125 return list[i]; |
| 126 } | 126 } |
| 127 | 127 |
| 128 return null; | 128 return null; |
| 129 } | 129 } |
| 130 }); | 130 }); |
| LEFT | RIGHT |