1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00
Raymond Hill 2018-07-24 09:17:18 -04:00
parent 8fbd6a0043
commit 7ae68c8d7d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 20 additions and 14 deletions

View File

@ -792,15 +792,21 @@ var restoreUserData = function(request) {
vAPI.localStorage.removeItem('immediateHiddenSettings');
};
// Remove all stored data but keep global counts, people can become
// quite attached to numbers
var resetUserData = function() {
vAPI.cacheStorage.clear();
vAPI.storage.clear();
let count = 3;
let countdown = ( ) => {
count -= 1;
if ( count === 0 ) {
vAPI.app.restart();
}
};
vAPI.cacheStorage.clear(countdown); // 1
vAPI.storage.clear(countdown); // 2
µb.saveLocalSettings(countdown); // 3
vAPI.localStorage.removeItem('immediateHiddenSettings');
// Keep global counts, people can become quite attached to numbers
µb.saveLocalSettings();
vAPI.app.restart();
};
/******************************************************************************/

View File

@ -1,7 +1,7 @@
/*******************************************************************************
uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2018 Raymond Hill
Copyright (C) 2014-present Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -52,17 +52,17 @@
/******************************************************************************/
µBlock.saveLocalSettings = (function() {
var saveAfter = 4 * 60 * 1000;
let saveAfter = 4 * 60 * 1000;
var save = function() {
let save = function(callback) {
this.localSettingsLastSaved = Date.now();
vAPI.storage.set(this.localSettings);
vAPI.storage.set(this.localSettings, callback);
};
var onTimeout = function() {
var µb = µBlock;
let onTimeout = ( ) => {
let µb = µBlock;
if ( µb.localSettingsLastModified > µb.localSettingsLastSaved ) {
save.call(µb);
µb.saveLocalSettings();
}
vAPI.setTimeout(onTimeout, saveAfter);
};