1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 07:22:28 +02:00

do not include unused entries in backup

This commit is contained in:
gorhill 2015-03-30 08:12:41 -04:00
parent d23b4e5a4f
commit 53d96cc88f
2 changed files with 21 additions and 1 deletions

View File

@ -980,7 +980,7 @@ var backupUserData = function(callback) {
timeStamp: Date.now(),
version: vAPI.app.version,
userSettings: µb.userSettings,
filterLists: µb.remoteBlacklists,
filterLists: µb.extractSelectedFilterLists(),
netWhitelist: µb.stringFromWhitelist(µb.netWhitelist),
dynamicFilteringString: µb.permanentFirewall.toString(),
hostnameSwitchesString: µb.hnSwitches.toString(),

View File

@ -91,6 +91,26 @@
/******************************************************************************/
// This will remove all unused filter list entries from
// µBlock.remoteBlacklists`. This helps reduce the size of backup files.
µBlock.extractSelectedFilterLists = function() {
var r = JSON.parse(JSON.stringify(this.remoteBlacklists));
for ( var path in r ) {
if ( r.hasOwnProperty(path) === false ) {
continue;
}
if ( r[path].off !== false ) {
delete r[path];
}
}
return r;
};
/******************************************************************************/
µBlock.saveUserFilters = function(content, callback) {
return this.assets.put(this.userFiltersPath, content, callback);
};