From a992875c94e0b3320e1c7bd6eb8a6ed716a5d3ea Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 5 Jul 2019 07:33:09 -0400 Subject: [PATCH] Save only modified immediate hidden settings --- src/js/storage.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/js/storage.js b/src/js/storage.js index 75b2ebadc..df8d2f2ec 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -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'); + } }; /******************************************************************************/