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

Side by Side Diff: lib/elemHide.js

Issue 5062082168881152: NO BUG Allow users to disable element hiding (Closed)
Patch Set: Created Feb. 18, 2015, 1:47 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 | « defaults/prefs.js ('k') | 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 */ 76 */
77 applied: false, 77 applied: false,
78 78
79 /** 79 /**
80 * Called on module startup. 80 * Called on module startup.
81 */ 81 */
82 init: function() 82 init: function()
83 { 83 {
84 Prefs.addListener(function(name) 84 Prefs.addListener(function(name)
85 { 85 {
86 if (name == "enabled") 86 if (name == "enabled" || name == "element_hiding_enabled")
87 ElemHide.apply(); 87 ElemHide.apply();
88 }); 88 });
89 onShutdown.add(function() 89 onShutdown.add(function()
90 { 90 {
91 ElemHide.unapply(); 91 ElemHide.unapply();
92 }); 92 });
93 93
94 let styleFile = IO.resolveFilePath(Prefs.data_directory); 94 let styleFile = IO.resolveFilePath(Prefs.data_directory);
95 styleFile.append("elemhide.css"); 95 styleFile.append("elemhide.css");
96 styleURL = Services.io.newFileURI(styleFile).QueryInterface(Ci.nsIFileURL); 96 styleURL = Services.io.newFileURI(styleFile).QueryInterface(Ci.nsIFileURL);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 * Generates stylesheet URL and applies it globally 205 * Generates stylesheet URL and applies it globally
206 */ 206 */
207 apply: function() 207 apply: function()
208 { 208 {
209 if (this._applying) 209 if (this._applying)
210 { 210 {
211 this._needsApply = true; 211 this._needsApply = true;
212 return; 212 return;
213 } 213 }
214 214
215 if (!ElemHide.isDirty || !Prefs.enabled) 215 let enabled = Prefs.enabled && Prefs.element_hiding_enabled;
216
217 if (!ElemHide.isDirty || !enabled)
216 { 218 {
217 // Nothing changed, looks like we merely got enabled/disabled 219 // Nothing changed, looks like we merely got enabled/disabled
218 if (Prefs.enabled && !ElemHide.applied) 220 if (enabled && !ElemHide.applied)
219 { 221 {
220 try 222 try
221 { 223 {
222 Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheetServ ice.USER_SHEET); 224 Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheetServ ice.USER_SHEET);
223 ElemHide.applied = true; 225 ElemHide.applied = true;
224 } 226 }
225 catch (e) 227 catch (e)
226 { 228 {
227 Cu.reportError(e); 229 Cu.reportError(e);
228 } 230 }
229 } 231 }
230 else if (!Prefs.enabled && ElemHide.applied) 232 else if (!enabled && ElemHide.applied)
231 { 233 {
232 ElemHide.unapply(); 234 ElemHide.unapply();
233 } 235 }
234 236
235 return; 237 return;
236 } 238 }
237 239
238 IO.writeToFile(styleURL.file, this._generateCSSContent(), function(e) 240 IO.writeToFile(styleURL.file, this._generateCSSContent(), function(e)
239 { 241 {
240 this._applying = false; 242 this._applying = false;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 let filter = filterByKey[key]; 385 let filter = filterByKey[key];
384 if (specificOnly && (!filter.domains || filter.domains[""])) 386 if (specificOnly && (!filter.domains || filter.domains[""]))
385 continue; 387 continue;
386 388
387 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) 389 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain))
388 result.push(filter.selector); 390 result.push(filter.selector);
389 } 391 }
390 return result; 392 return result;
391 } 393 }
392 }; 394 };
OLDNEW
« no previous file with comments | « defaults/prefs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld