Raymond Hill 2018-08-30 08:32:56 -04:00
parent 47b6ad3872
commit 8ca6239e64
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 9 additions and 32 deletions

View File

@ -100,48 +100,25 @@
/******************************************************************************/ /******************************************************************************/
µBlock.loadHiddenSettings = function() { µBlock.loadHiddenSettings = function() {
var onLoaded = function(bin) { vAPI.storage.get('hiddenSettings', bin => {
if ( bin instanceof Object === false ) { return; } if ( bin instanceof Object === false ) { return; }
var µb = µBlock, let hs = bin.hiddenSettings;
hs = bin.hiddenSettings;
// Remove following condition once 1.15.12+ is widespread.
if (
hs instanceof Object === false &&
typeof bin.hiddenSettingsString === 'string'
) {
vAPI.storage.remove('hiddenSettingsString');
hs = µBlock.hiddenSettingsFromString(bin.hiddenSettingsString);
}
if ( hs instanceof Object ) { if ( hs instanceof Object ) {
var hsDefault = µb.hiddenSettingsDefault; let hsDefault = this.hiddenSettingsDefault;
for ( var key in hsDefault ) { for ( let key in hsDefault ) {
if ( if (
hsDefault.hasOwnProperty(key) && hsDefault.hasOwnProperty(key) &&
hs.hasOwnProperty(key) && hs.hasOwnProperty(key) &&
typeof hs[key] === typeof hsDefault[key] typeof hs[key] === typeof hsDefault[key]
) { ) {
µb.hiddenSettings[key] = hs[key]; this.hiddenSettings[key] = hs[key];
} }
} }
// To remove once 1.15.26 is widespread. The reason is to ensure
// the change in the following commit is taken into account:
// https://github.com/gorhill/uBlock/commit/8071321e9104
if ( hs.manualUpdateAssetFetchPeriod === 2000 ) {
µb.hiddenSettings.manualUpdateAssetFetchPeriod =
µb.hiddenSettingsDefault.manualUpdateAssetFetchPeriod;
hs.manualUpdateAssetFetchPeriod = undefined;
µb.saveHiddenSettings();
}
} }
if ( vAPI.localStorage.getItem('immediateHiddenSettings') === null ) { if ( vAPI.localStorage.getItem('immediateHiddenSettings') === null ) {
µb.saveImmediateHiddenSettings(); this.saveImmediateHiddenSettings();
} }
}; });
vAPI.storage.get(
[ 'hiddenSettings', 'hiddenSettingsString'],
onLoaded
);
}; };
// Note: Save only the settings which values differ from the default ones. // Note: Save only the settings which values differ from the default ones.
@ -149,8 +126,8 @@
// which were not modified by the user. // which were not modified by the user.
µBlock.saveHiddenSettings = function(callback) { µBlock.saveHiddenSettings = function(callback) {
var bin = { hiddenSettings: {} }; let bin = { hiddenSettings: {} };
for ( var prop in this.hiddenSettings ) { for ( let prop in this.hiddenSettings ) {
if ( if (
this.hiddenSettings.hasOwnProperty(prop) && this.hiddenSettings.hasOwnProperty(prop) &&
this.hiddenSettings[prop] !== this.hiddenSettingsDefault[prop] this.hiddenSettings[prop] !== this.hiddenSettingsDefault[prop]