Skip to content

Commit ee4fc2a

Browse files
committed
code review re advanced settings + added popupFontSize
1 parent bc379a1 commit ee4fc2a

5 files changed

Lines changed: 33 additions & 8 deletions

File tree

src/js/background.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ return {
7373
hiddenSettingsDefault: {
7474
ignoreRedirectFilters: false,
7575
ignoreScriptInjectFilters: false,
76+
popupFontSize: 'unset',
7677
suspendTabsUntilReady: false
7778
},
7879
// This will be filled ASAP:

src/js/messaging.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ var getFirewallRules = function(srcHostname, desHostnames) {
282282
/******************************************************************************/
283283

284284
var popupDataFromTabId = function(tabId, tabTitle) {
285-
var tabContext = µb.tabContextManager.mustLookup(tabId);
286-
var rootHostname = tabContext.rootHostname;
285+
var tabContext = µb.tabContextManager.mustLookup(tabId),
286+
rootHostname = tabContext.rootHostname;
287287
var r = {
288288
advancedUserEnabled: µb.userSettings.advancedUserEnabled,
289289
appName: vAPI.app.name,
@@ -294,6 +294,7 @@ var popupDataFromTabId = function(tabId, tabTitle) {
294294
firewallPaneMinimized: µb.userSettings.firewallPaneMinimized,
295295
globalAllowedRequestCount: µb.localSettings.allowedRequestCount,
296296
globalBlockedRequestCount: µb.localSettings.blockedRequestCount,
297+
fontSize: µb.hiddenSettings.popupFontSize,
297298
netFilteringSwitch: false,
298299
rawURL: tabContext.rawURL,
299300
pageURL: tabContext.normalURL,

src/js/popup.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929

3030
/******************************************************************************/
3131

32+
var popupFontSize = vAPI.localStorage.getItem('popupFontSize');
33+
if ( typeof popupFontSize === 'string' && popupFontSize !== 'unset' ) {
34+
document.body.style.setProperty('font-size', popupFontSize);
35+
}
36+
3237
// Ensure the popup is properly sized as soon as possible. It is assume the DOM
3338
// content is ready at this point, which should be the case given where this
3439
// script file is included in the HTML file.
@@ -100,7 +105,6 @@ var rowsToRecycle = uDom();
100105
var cachedPopupHash = '';
101106
var statsStr = vAPI.i18n('popupBlockedStats');
102107
var domainsHitStr = vAPI.i18n('popupHitDomainCount');
103-
var reNetworkRelatedURL = /^(?:ftps?|https?|wss?):\/\//;
104108

105109
/******************************************************************************/
106110

@@ -386,6 +390,17 @@ var renderPrivacyExposure = function() {
386390
// Assume everything has to be done incrementally.
387391

388392
var renderPopup = function() {
393+
if ( popupData.fontSize !== popupFontSize ) {
394+
popupFontSize = popupData.fontSize;
395+
if ( popupFontSize !== 'unset' ) {
396+
document.body.style.setProperty('font-size', popupFontSize);
397+
vAPI.localStorage.setItem('popupFontSize', popupFontSize);
398+
} else {
399+
document.body.style.removeProperty('font-size');
400+
vAPI.localStorage.removeItem('popupFontSize');
401+
}
402+
}
403+
389404
if ( popupData.tabTitle ) {
390405
document.title = popupData.appName + ' - ' + popupData.tabTitle;
391406
}

src/js/start.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,23 @@ var onAdminSettingsRestored = function() {
282282
/******************************************************************************/
283283

284284
µb.hiddenSettings = (function() {
285-
var json = vAPI.localStorage.getItem('hiddenSettings');
285+
var out = objectAssign({}, µb.hiddenSettingsDefault),
286+
json = vAPI.localStorage.getItem('hiddenSettings');
286287
if ( typeof json === 'string' ) {
287288
try {
288-
var out = JSON.parse(json);
289-
if ( out instanceof Object ) {
290-
return out;
289+
var o = JSON.parse(json);
290+
if ( o instanceof Object ) {
291+
for ( var k in o ) {
292+
if ( out.hasOwnProperty(k) ) {
293+
out[k] = o[k];
294+
}
295+
}
291296
}
292297
}
293298
catch(ex) {
294299
}
295300
}
296-
return objectAssign({}, µb.hiddenSettingsDefault);
301+
return out;
297302
})();
298303

299304
/******************************************************************************/

src/js/storage.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
out[name] = false;
102102
}
103103
break;
104+
case 'string':
105+
out[name] = value;
106+
break;
104107
default:
105108
break;
106109
}

0 commit comments

Comments
 (0)