Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/elemHide.js

Issue 29342837: Issue 4054 - Remove filters from filtersByDomain (Closed)
Patch Set: Rename domainMatches for consistency Created May 20, 2016, 1:30 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 let key; 150 let key;
151 do { 151 do {
152 key = Math.random().toFixed(15).substr(5); 152 key = Math.random().toFixed(15).substr(5);
153 } while (key in filterByKey); 153 } while (key in filterByKey);
154 154
155 filterByKey[key] = filter; 155 filterByKey[key] = filter;
156 keyByFilter[filter.text] = key; 156 keyByFilter[filter.text] = key;
157 157
158 if (usingFiltersByDomain) 158 if (usingFiltersByDomain)
159 { 159 {
160 let domainMatches = filter.domains || defaultDomains; 160 let domains = filter.domains || defaultDomains;
161 for (let domain in domainMatches) 161 for (let domain in domains)
162 { 162 {
163 let filters = filtersByDomain[domain]; 163 let filters = filtersByDomain[domain];
164 if (!filters) 164 if (!filters)
165 filters = filtersByDomain[domain] = Object.create(null); 165 filters = filtersByDomain[domain] = Object.create(null);
166 166
167 if (domainMatches[domain]) 167 if (domains[domain])
168 filters[filter.text] = filter; 168 filters[filter.text] = filter;
169 else 169 else
170 filters[filter.text] = false; 170 filters[filter.text] = false;
171 } 171 }
172 } 172 }
173 173
174 ElemHide.isDirty = true; 174 ElemHide.isDirty = true;
175 } 175 }
176 }, 176 },
177 177
(...skipping 16 matching lines...) Expand all
194 } 194 }
195 else 195 else
196 { 196 {
197 if (!(filter.text in keyByFilter)) 197 if (!(filter.text in keyByFilter))
198 return; 198 return;
199 199
200 let key = keyByFilter[filter.text]; 200 let key = keyByFilter[filter.text];
201 delete filterByKey[key]; 201 delete filterByKey[key];
202 delete keyByFilter[filter.text]; 202 delete keyByFilter[filter.text];
203 ElemHide.isDirty = true; 203 ElemHide.isDirty = true;
204
205 if (usingFiltersByDomain)
206 {
207 let domains = filter.domains || defaultDomains;
208 for (let domain in domains)
209 {
210 let filters = filtersByDomain[domain];
211 if (filters)
212 delete filters[filter.text];
213 }
214 }
204 } 215 }
205 }, 216 },
206 217
207 /** 218 /**
208 * Checks whether an exception rule is registered for a filter on a particular 219 * Checks whether an exception rule is registered for a filter on a particular
209 * domain. 220 * domain.
210 */ 221 */
211 getException: function(/**Filter*/ filter, /**String*/ docDomain) /**ElemHideE xception*/ 222 getException: function(/**Filter*/ filter, /**String*/ docDomain) /**ElemHideE xception*/
212 { 223 {
213 if (!(filter.selector in exceptions)) 224 if (!(filter.selector in exceptions))
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if (currentDomain == "") 451 if (currentDomain == "")
441 break; 452 break;
442 453
443 let nextDot = currentDomain.indexOf("."); 454 let nextDot = currentDomain.indexOf(".");
444 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); 455 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
445 } 456 }
446 457
447 return selectors; 458 return selectors;
448 } 459 }
449 }; 460 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld