Skip to content

Loading…

-- #1268

Closed
wants to merge 9 commits into from
Commits on Apr 10, 2015
  1. @gorhill
Commits on Apr 11, 2015
  1. @gorhill
  2. @gorhill
Commits on Apr 12, 2015
  1. @gorhill
Commits on Apr 13, 2015
  1. @gorhill
  2. @gorhill
Commits on Apr 14, 2015
  1. @gorhill
Commits on Apr 16, 2015
  1. @gorhill
  2. @gorhill

    this fixes #63

    gorhill committed
This page is out of date. Refresh to see the latest.
Showing with 50 additions and 26 deletions.
  1. +0 −3 platform/firefox/frameModule.js
  2. +0 −3 platform/firefox/vapi-background.js
  3. +20 −11 src/js/messaging.js
  4. +30 −9 src/js/storage.js
View
3 platform/firefox/frameModule.js
@@ -168,9 +168,6 @@ const contentObserver = {
type: type,
url: location.spec
};
- if ( type === 7 ) {
- details.attrSrc = context.frameElement.getAttribute('src');
- }
if ( typeof messageManager.sendRpcMessage === 'function' ) {
// https://bugzil.la/1092216
View
3 platform/firefox/vapi-background.js
@@ -1312,9 +1312,6 @@ vAPI.net.registerListeners = function() {
type: details.type,
url: details.url
};
- if ( details.attrSrc !== undefined ) {
- lastRequest[0].attrSrc = details.attrSrc;
- }
};
vAPI.messaging.globalMessageManager.addMessageListener(
View
31 src/js/messaging.js
@@ -974,16 +974,19 @@ var getLocalData = function(callback) {
/******************************************************************************/
var backupUserData = function(callback) {
- var onUserFiltersReady = function(details) {
- var userData = {
- timeStamp: Date.now(),
- version: vAPI.app.version,
- userSettings: µb.userSettings,
- filterLists: µb.extractSelectedFilterLists(),
- netWhitelist: µb.stringFromWhitelistb.netWhitelist),
- dynamicFilteringString: µb.permanentFirewall.toString(),
- userFilters: details.content
- };
+ var userData = {
+ timeStamp: Date.now(),
+ version: vAPI.app.version,
+ userSettings: µb.userSettings,
+ filterLists: {},
+ netWhitelist: µb.stringFromWhitelistb.netWhitelist),
+ dynamicFilteringString: µb.permanentFirewall.toString(),
+ userFilters: ''
+ };
+
+ var onSelectedListsReady = function(filterLists) {
+ userData.filterLists = filterLists;
+
var now = new Date();
var filename = vAPI.i18n('aboutBackupFilename')
.replace('{{datetime}}', now.toLocaleString())
@@ -1001,6 +1004,12 @@ var backupUserData = function(callback) {
getLocalData(callback);
};
+ var onUserFiltersReady = function(details) {
+ userData.userFilters = details.content;
+ µb.extractSelectedFilterLists(onSelectedListsReady);
+ };
+
+
µb.assets.get('assets/user/filters.txt', onUserFiltersReady);
};
@@ -1050,7 +1059,7 @@ var restoreUserData = function(request) {
/******************************************************************************/
var resetUserData = function() {
- vAPI.storage.clear(onAllRemoved);
+ vAPI.storage.clear();
// Keep global counts, people can become quite attached to numbers
µb.saveLocalSettings(true);
View
39 src/js/storage.js
@@ -102,19 +102,40 @@
// 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));
Block.extractSelectedFilterLists = function(callback) {
+ var µb = this;
- for ( var path in r ) {
- if ( r.hasOwnProperty(path) === false ) {
- continue;
+ var onBuiltinListsLoaded = function(details) {
+ var builtin;
+ try {
+ builtin = JSON.parse(details.content);
+ } catch (e) {
+ builtin = {};
}
- if ( r[path].off !== false ) {
- delete r[path];
+
+ var result = JSON.parse(JSON.stringifyb.remoteBlacklists));
+ var builtinPath;
+ var defaultState;
+
+ for ( var path in result ) {
+ if ( result.hasOwnProperty(path) === false ) {
+ continue;
+ }
+ builtinPath = path.replace(/^assets\/thirdparties\//, '');
+ defaultState = builtin.hasOwnProperty(builtinPath) === false ||
+ builtin[builtinPath].off === true;
+ if ( result[path].off === true && result[path].off === defaultState ) {
+ delete result[path];
+ }
}
- }
- return r;
+ callback(result);
+ };
+
+ // https://github.com/gorhill/uBlock/issues/63
+ // Get built-in block lists: this will help us determine whether a
+ // specific list must be included in the result.
+ this.assets.get('assets/ublock/filter-lists.json', onBuiltinListsLoaded);
};
/******************************************************************************/
Something went wrong with that request. Please try again.