mirror of https://github.com/gorhill/uBlock.git
code review re advanced settings + added popupFontSize
This commit is contained in:
parent
bc379a123e
commit
ee4fc2aed6
|
@ -73,6 +73,7 @@ return {
|
|||
hiddenSettingsDefault: {
|
||||
ignoreRedirectFilters: false,
|
||||
ignoreScriptInjectFilters: false,
|
||||
popupFontSize: 'unset',
|
||||
suspendTabsUntilReady: false
|
||||
},
|
||||
// This will be filled ASAP:
|
||||
|
|
|
@ -282,8 +282,8 @@ var getFirewallRules = function(srcHostname, desHostnames) {
|
|||
/******************************************************************************/
|
||||
|
||||
var popupDataFromTabId = function(tabId, tabTitle) {
|
||||
var tabContext = µb.tabContextManager.mustLookup(tabId);
|
||||
var rootHostname = tabContext.rootHostname;
|
||||
var tabContext = µb.tabContextManager.mustLookup(tabId),
|
||||
rootHostname = tabContext.rootHostname;
|
||||
var r = {
|
||||
advancedUserEnabled: µb.userSettings.advancedUserEnabled,
|
||||
appName: vAPI.app.name,
|
||||
|
@ -294,6 +294,7 @@ var popupDataFromTabId = function(tabId, tabTitle) {
|
|||
firewallPaneMinimized: µb.userSettings.firewallPaneMinimized,
|
||||
globalAllowedRequestCount: µb.localSettings.allowedRequestCount,
|
||||
globalBlockedRequestCount: µb.localSettings.blockedRequestCount,
|
||||
fontSize: µb.hiddenSettings.popupFontSize,
|
||||
netFilteringSwitch: false,
|
||||
rawURL: tabContext.rawURL,
|
||||
pageURL: tabContext.normalURL,
|
||||
|
|
|
@ -29,6 +29,11 @@
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
var popupFontSize = vAPI.localStorage.getItem('popupFontSize');
|
||||
if ( typeof popupFontSize === 'string' && popupFontSize !== 'unset' ) {
|
||||
document.body.style.setProperty('font-size', popupFontSize);
|
||||
}
|
||||
|
||||
// Ensure the popup is properly sized as soon as possible. It is assume the DOM
|
||||
// content is ready at this point, which should be the case given where this
|
||||
// script file is included in the HTML file.
|
||||
|
@ -100,7 +105,6 @@ var rowsToRecycle = uDom();
|
|||
var cachedPopupHash = '';
|
||||
var statsStr = vAPI.i18n('popupBlockedStats');
|
||||
var domainsHitStr = vAPI.i18n('popupHitDomainCount');
|
||||
var reNetworkRelatedURL = /^(?:ftps?|https?|wss?):\/\//;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -386,6 +390,17 @@ var renderPrivacyExposure = function() {
|
|||
// Assume everything has to be done incrementally.
|
||||
|
||||
var renderPopup = function() {
|
||||
if ( popupData.fontSize !== popupFontSize ) {
|
||||
popupFontSize = popupData.fontSize;
|
||||
if ( popupFontSize !== 'unset' ) {
|
||||
document.body.style.setProperty('font-size', popupFontSize);
|
||||
vAPI.localStorage.setItem('popupFontSize', popupFontSize);
|
||||
} else {
|
||||
document.body.style.removeProperty('font-size');
|
||||
vAPI.localStorage.removeItem('popupFontSize');
|
||||
}
|
||||
}
|
||||
|
||||
if ( popupData.tabTitle ) {
|
||||
document.title = popupData.appName + ' - ' + popupData.tabTitle;
|
||||
}
|
||||
|
|
|
@ -282,18 +282,23 @@ var onAdminSettingsRestored = function() {
|
|||
/******************************************************************************/
|
||||
|
||||
µb.hiddenSettings = (function() {
|
||||
var json = vAPI.localStorage.getItem('hiddenSettings');
|
||||
var out = objectAssign({}, µb.hiddenSettingsDefault),
|
||||
json = vAPI.localStorage.getItem('hiddenSettings');
|
||||
if ( typeof json === 'string' ) {
|
||||
try {
|
||||
var out = JSON.parse(json);
|
||||
if ( out instanceof Object ) {
|
||||
return out;
|
||||
var o = JSON.parse(json);
|
||||
if ( o instanceof Object ) {
|
||||
for ( var k in o ) {
|
||||
if ( out.hasOwnProperty(k) ) {
|
||||
out[k] = o[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
}
|
||||
return objectAssign({}, µb.hiddenSettingsDefault);
|
||||
return out;
|
||||
})();
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -101,6 +101,9 @@
|
|||
out[name] = false;
|
||||
}
|
||||
break;
|
||||
case 'string':
|
||||
out[name] = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue