| Left: | ||
| Right: |
| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 var filtersByDomain = Object.create(null); | 46 var filtersByDomain = Object.create(null); |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Indicates whether we are using (and maintaining) the filtersByDomain lookup. | 49 * Indicates whether we are using (and maintaining) the filtersByDomain lookup. |
| 50 * (Will be false for Firefox) | 50 * (Will be false for Firefox) |
| 51 * @type Boolean | 51 * @type Boolean |
| 52 */ | 52 */ |
| 53 var usingFiltersByDomain = !("nsIStyleSheetService" in Ci); | 53 var usingFiltersByDomain = !("nsIStyleSheetService" in Ci); |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Object to be used instead when a filter has a blank domains property. | |
| 57 */ | |
| 58 var defaultDomains = Object.create(null); | |
| 59 defaultDomains[""] = true; | |
| 60 | |
| 61 /** | |
| 56 * Lookup table, keys are known element hiding exceptions | 62 * Lookup table, keys are known element hiding exceptions |
| 57 * @type Object | 63 * @type Object |
| 58 */ | 64 */ |
| 59 var knownExceptions = Object.create(null); | 65 var knownExceptions = Object.create(null); |
| 60 | 66 |
| 61 /** | 67 /** |
| 62 * Lookup table, lists of element hiding exceptions by selector | 68 * Lookup table, lists of element hiding exceptions by selector |
| 63 * @type Object | 69 * @type Object |
| 64 */ | 70 */ |
| 65 var exceptions = Object.create(null); | 71 var exceptions = Object.create(null); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 let key; | 150 let key; |
| 145 do { | 151 do { |
| 146 key = Math.random().toFixed(15).substr(5); | 152 key = Math.random().toFixed(15).substr(5); |
| 147 } while (key in filterByKey); | 153 } while (key in filterByKey); |
| 148 | 154 |
| 149 filterByKey[key] = filter; | 155 filterByKey[key] = filter; |
| 150 keyByFilter[filter.text] = key; | 156 keyByFilter[filter.text] = key; |
| 151 | 157 |
| 152 if (usingFiltersByDomain) | 158 if (usingFiltersByDomain) |
| 153 { | 159 { |
| 154 let domainMatches = filter.domains || {"": true}; | 160 let domainMatches = filter.domains || defaultDomains; |
|
Wladimir Palant
2016/05/18 13:38:06
You are iterating over object keys below but {"":
Sebastian Noack
2016/05/18 13:48:25
Also note that for..in loops on objects in hash-ta
kzar
2016/05/18 14:23:00
Done.
kzar
2016/05/18 14:23:00
The only way I know to check if a function is deop
| |
| 155 for (let domain in domainMatches) | 161 for (let domain in domainMatches) |
| 156 { | 162 { |
| 157 domain = domain.toUpperCase(); | |
|
Wladimir Palant
2016/05/18 13:38:06
This operation is unnecessary, the domains are alr
kzar
2016/05/18 14:23:00
Done.
| |
| 158 let filters = filtersByDomain[domain]; | 163 let filters = filtersByDomain[domain]; |
| 159 if (!filters) | 164 if (!filters) |
| 160 filters = filtersByDomain[domain] = Object.create(null); | 165 filters = filtersByDomain[domain] = Object.create(null); |
| 161 filters[filter.text] = domainMatches[domain] && filter; | 166 |
|
Wladimir Palant
2016/05/18 13:38:05
I know, Sebastian loves such constructs. Still, I
kzar
2016/05/18 14:23:00
Done.
| |
| 167 if (domainMatches[domain]) | |
| 168 filters[filter.text] = filter; | |
| 169 else | |
| 170 filters[filter.text] = false; | |
| 162 } | 171 } |
| 163 } | 172 } |
| 164 | 173 |
| 165 ElemHide.isDirty = true; | 174 ElemHide.isDirty = true; |
| 166 } | 175 } |
| 167 }, | 176 }, |
| 168 | 177 |
| 169 /** | 178 /** |
| 170 * Removes an element hiding filter | 179 * Removes an element hiding filter |
| 171 * @param {ElemHideFilter} filter | 180 * @param {ElemHideFilter} filter |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 if (currentDomain == "") | 440 if (currentDomain == "") |
| 432 break; | 441 break; |
| 433 | 442 |
| 434 let nextDot = currentDomain.indexOf("."); | 443 let nextDot = currentDomain.indexOf("."); |
| 435 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); | 444 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
| 436 } | 445 } |
| 437 | 446 |
| 438 return selectors; | 447 return selectors; |
| 439 } | 448 } |
| 440 }; | 449 }; |
| LEFT | RIGHT |