diff --git a/src/js/messaging.js b/src/js/messaging.js index 05b9ce9ea..98fd3534c 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -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(), diff --git a/src/js/storage.js b/src/js/storage.js index 8854fe9a0..66ec14390 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -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); };