Save only modified immediate hidden settings

This commit is contained in:
Raymond Hill 2019-07-05 07:33:09 -04:00
parent 34073b41df
commit a992875c94
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 17 additions and 8 deletions

View File

@ -197,14 +197,23 @@
// through the vAPI.localStorage. Add/remove settings as needed.
µBlock.saveImmediateHiddenSettings = function() {
vAPI.localStorage.setItem(
'immediateHiddenSettings',
JSON.stringify({
consoleLogLevel: this.hiddenSettings.consoleLogLevel,
disableWebAssembly: this.hiddenSettings.disableWebAssembly,
suspendTabsUntilReady: this.hiddenSettings.suspendTabsUntilReady,
})
);
const props = [
'consoleLogLevel',
'disableWebAssembly',
'suspendTabsUntilReady',
];
const toSave = {};
for ( const prop of props ) {
if ( this.hiddenSettings[prop] !== this.hiddenSettingsDefault[prop] ) {
toSave[prop] = this.hiddenSettings[prop];
}
}
if ( Object.keys(toSave).length !== 0 ) {
vAPI.localStorage.setItem(
'immediateHiddenSettings', JSON.stringify(toSave));
} else {
vAPI.localStorage.removeItem('immediateHiddenSettings');
}
};
/******************************************************************************/