mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
see if this fixes #307
This commit is contained in:
parent
ebb77833d8
commit
0c3ec0fea8
@ -654,15 +654,26 @@ var getUserData = function(callback) {
|
||||
/******************************************************************************/
|
||||
|
||||
var restoreUserData = function(userData) {
|
||||
var countdown = 5;
|
||||
var onCountdown = function() {
|
||||
countdown -= 1;
|
||||
if ( countdown === 0 ) {
|
||||
µb.XAL.restart();
|
||||
}
|
||||
};
|
||||
|
||||
var onAllRemoved = function() {
|
||||
// Be sure to adjust `countdown` if adding/removing anything below
|
||||
µBlock.saveLocalSettings(onCountdown);
|
||||
µb.XAL.keyvalSetMany(userData.userSettings, onCountdown);
|
||||
µb.XAL.keyvalSetOne('remoteBlacklists', userData.filterLists, onCountdown);
|
||||
µb.XAL.keyvalSetOne('netWhitelist', userData.netWhitelist, onCountdown);
|
||||
µb.assets.put('assets/user/filters.txt', userData.userFilters, onCountdown);
|
||||
};
|
||||
|
||||
// If we are going to restore all, might as well wipe out clean local
|
||||
// storage
|
||||
µb.XAL.keyvalRemoveAll();
|
||||
µBlock.saveLocalSettings();
|
||||
µb.XAL.keyvalSetMany(userData.userSettings);
|
||||
µb.XAL.keyvalSetOne('remoteBlacklists', userData.filterLists);
|
||||
µb.XAL.keyvalSetOne('netWhitelist', userData.netWhitelist);
|
||||
µb.assets.put('assets/user/filters.txt', userData.userFilters);
|
||||
µb.XAL.restart();
|
||||
µb.XAL.keyvalRemoveAll(onAllRemoved);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -60,16 +60,16 @@ exports.injectScript = function(id, details) {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
exports.keyvalSetOne = function(key, val) {
|
||||
exports.keyvalSetOne = function(key, val, callback) {
|
||||
var bin = {};
|
||||
bin[key] = val;
|
||||
chrome.storage.local.set(bin);
|
||||
chrome.storage.local.set(bin, callback || noopFunc);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
exports.keyvalSetMany = function(dict) {
|
||||
chrome.storage.local.set(dict);
|
||||
exports.keyvalSetMany = function(dict, callback) {
|
||||
chrome.storage.local.set(dict, callback || noopFunc);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user