mirror of https://github.com/gorhill/uBlock.git
fix #2340
This commit is contained in:
parent
393d0b2d08
commit
aadf4a6427
|
@ -171,12 +171,14 @@ api.listKeyAliases = {
|
||||||
"https://s3.amazonaws.com/lists.disconnect.me/simple_malware.txt": "disconnect-malware",
|
"https://s3.amazonaws.com/lists.disconnect.me/simple_malware.txt": "disconnect-malware",
|
||||||
"https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt": "disconnect-tracking",
|
"https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt": "disconnect-tracking",
|
||||||
"https://www.certyficate.it/adblock/adblock.txt": "POL-0",
|
"https://www.certyficate.it/adblock/adblock.txt": "POL-0",
|
||||||
|
"https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-adblock-filters/adblock.txt": "POL-0",
|
||||||
"https://easylist-downloads.adblockplus.org/antiadblockfilters.txt": "awrl-0",
|
"https://easylist-downloads.adblockplus.org/antiadblockfilters.txt": "awrl-0",
|
||||||
"http://adb.juvander.net/Finland_adb.txt": "FIN-0",
|
"http://adb.juvander.net/Finland_adb.txt": "FIN-0",
|
||||||
"https://raw.githubusercontent.com/gfmaster/adblock-korea-contrib/master/filter.txt": "KOR-0",
|
"https://raw.githubusercontent.com/gfmaster/adblock-korea-contrib/master/filter.txt": "KOR-0",
|
||||||
"https://raw.githubusercontent.com/yous/YousList/master/youslist.txt": "KOR-1",
|
"https://raw.githubusercontent.com/yous/YousList/master/youslist.txt": "KOR-1",
|
||||||
"https://www.fanboy.co.nz/fanboy-korean.txt": "KOR-2",
|
"https://www.fanboy.co.nz/fanboy-korean.txt": "KOR-2",
|
||||||
"https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
|
"https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
|
||||||
|
"https://raw.githubusercontent.com/ABPindo/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
|
||||||
"https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt": "JPN-0",
|
"https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt": "JPN-0",
|
||||||
"https://raw.githubusercontent.com/liamja/Prebake/master/obtrusive.txt": "EU-prebake",
|
"https://raw.githubusercontent.com/liamja/Prebake/master/obtrusive.txt": "EU-prebake",
|
||||||
"https://easylist-downloads.adblockplus.org/Liste_AR.txt": "ara-0",
|
"https://easylist-downloads.adblockplus.org/Liste_AR.txt": "ara-0",
|
||||||
|
@ -343,7 +345,7 @@ var saveAssetSourceRegistry = (function() {
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var updateAssetSourceRegistry = function(json) {
|
var updateAssetSourceRegistry = function(json, silent) {
|
||||||
var newDict;
|
var newDict;
|
||||||
try {
|
try {
|
||||||
newDict = JSON.parse(json);
|
newDict = JSON.parse(json);
|
||||||
|
@ -351,8 +353,9 @@ var updateAssetSourceRegistry = function(json) {
|
||||||
}
|
}
|
||||||
if ( newDict instanceof Object === false ) { return; }
|
if ( newDict instanceof Object === false ) { return; }
|
||||||
|
|
||||||
getAssetSourceRegistry(function(oldDict) {
|
var oldDict = assetSourceRegistry,
|
||||||
var assetKey;
|
assetKey;
|
||||||
|
|
||||||
// Remove obsolete entries (only those which were built-in).
|
// Remove obsolete entries (only those which were built-in).
|
||||||
for ( assetKey in oldDict ) {
|
for ( assetKey in oldDict ) {
|
||||||
if (
|
if (
|
||||||
|
@ -364,7 +367,7 @@ var updateAssetSourceRegistry = function(json) {
|
||||||
}
|
}
|
||||||
// Add/update existing entries. Notify of new asset sources.
|
// Add/update existing entries. Notify of new asset sources.
|
||||||
for ( assetKey in newDict ) {
|
for ( assetKey in newDict ) {
|
||||||
if ( oldDict[assetKey] === undefined ) {
|
if ( oldDict[assetKey] === undefined && !silent ) {
|
||||||
fireNotification(
|
fireNotification(
|
||||||
'builtin-asset-source-added',
|
'builtin-asset-source-added',
|
||||||
{ assetKey: assetKey, entry: newDict[assetKey] }
|
{ assetKey: assetKey, entry: newDict[assetKey] }
|
||||||
|
@ -373,7 +376,6 @@ var updateAssetSourceRegistry = function(json) {
|
||||||
registerAssetSource(assetKey, newDict[assetKey]);
|
registerAssetSource(assetKey, newDict[assetKey]);
|
||||||
}
|
}
|
||||||
saveAssetSourceRegistry();
|
saveAssetSourceRegistry();
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var getAssetSourceRegistry = function(callback) {
|
var getAssetSourceRegistry = function(callback) {
|
||||||
|
@ -406,7 +408,7 @@ var getAssetSourceRegistry = function(callback) {
|
||||||
getTextFileFromURL(
|
getTextFileFromURL(
|
||||||
µBlock.assetsBootstrapLocation || 'assets/assets.json',
|
µBlock.assetsBootstrapLocation || 'assets/assets.json',
|
||||||
function() {
|
function() {
|
||||||
updateAssetSourceRegistry(this.responseText);
|
updateAssetSourceRegistry(this.responseText, true);
|
||||||
registryReady();
|
registryReady();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -899,7 +901,7 @@ api.metadata = function(callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
getAssetCacheRegistry(function() {
|
getAssetCacheRegistry(function() {
|
||||||
cacheRegistryReady = assetCacheRegistry;
|
cacheRegistryReady = true;
|
||||||
if ( assetRegistryReady ) { onReady(); }
|
if ( assetRegistryReady ) { onReady(); }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -754,27 +754,25 @@ var backupUserData = function(callback) {
|
||||||
timeStamp: Date.now(),
|
timeStamp: Date.now(),
|
||||||
version: vAPI.app.version,
|
version: vAPI.app.version,
|
||||||
userSettings: µb.userSettings,
|
userSettings: µb.userSettings,
|
||||||
selectedFilterLists: [],
|
selectedFilterLists: µb.selectedFilterLists,
|
||||||
hiddenSettingsString: µb.stringFromHiddenSettings(),
|
hiddenSettingsString: µb.stringFromHiddenSettings(),
|
||||||
netWhitelist: µb.stringFromWhitelist(µb.netWhitelist),
|
netWhitelist: µb.stringFromWhitelist(µb.netWhitelist),
|
||||||
dynamicFilteringString: µb.permanentFirewall.toString(),
|
dynamicFilteringString: µb.permanentFirewall.toString(),
|
||||||
urlFilteringString: µb.permanentURLFiltering.toString(),
|
urlFilteringString: µb.permanentURLFiltering.toString(),
|
||||||
hostnameSwitchesString: µb.hnSwitches.toString(),
|
hostnameSwitchesString: µb.hnSwitches.toString(),
|
||||||
userFilters: ''
|
userFilters: '',
|
||||||
};
|
|
||||||
|
|
||||||
var onSelectedListsReady = function(selectedFilterLists) {
|
|
||||||
userData.selectedFilterLists = selectedFilterLists;
|
|
||||||
|
|
||||||
// TODO(seamless migration):
|
// TODO(seamless migration):
|
||||||
// The following is strictly for convenience, to be minimally
|
// The following is strictly for convenience, to be minimally
|
||||||
// forward-compatible. This will definitely be removed in the
|
// forward-compatible. This will definitely be removed in the
|
||||||
// short term, as I do not expect the need to install an older
|
// short term, as I do not expect the need to install an older
|
||||||
// version of uBO to ever be needed beyond the short term.
|
// version of uBO to ever be needed beyond the short term.
|
||||||
// >>>>>>>>
|
// >>>>>>>>
|
||||||
userData.filterLists = µb.oldDataFromNewListKeys(selectedFilterLists);
|
filterLists: µb.oldDataFromNewListKeys(µb.selectedFilterLists)
|
||||||
// <<<<<<<<
|
// <<<<<<<<
|
||||||
|
};
|
||||||
|
|
||||||
|
var onUserFiltersReady = function(details) {
|
||||||
|
userData.userFilters = details.content;
|
||||||
var filename = vAPI.i18n('aboutBackupFilename')
|
var filename = vAPI.i18n('aboutBackupFilename')
|
||||||
.replace('{{datetime}}', µb.dateNowToSensibleString())
|
.replace('{{datetime}}', µb.dateNowToSensibleString())
|
||||||
.replace(/ +/g, '_');
|
.replace(/ +/g, '_');
|
||||||
|
@ -789,11 +787,6 @@ var backupUserData = function(callback) {
|
||||||
getLocalData(callback);
|
getLocalData(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onUserFiltersReady = function(details) {
|
|
||||||
userData.userFilters = details.content;
|
|
||||||
µb.loadSelectedFilterLists(onSelectedListsReady);
|
|
||||||
};
|
|
||||||
|
|
||||||
µb.assets.get(µb.userFiltersPath, onUserFiltersReady);
|
µb.assets.get(µb.userFiltersPath, onUserFiltersReady);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ var fromFetch = function(to, fetched) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var onAdminSettingsRestored = function() {
|
var onSelectedFilterListsLoaded = function() {
|
||||||
var fetchableProps = {
|
var fetchableProps = {
|
||||||
'compiledMagic': '',
|
'compiledMagic': '',
|
||||||
'dynamicFilteringString': 'behind-the-scene * 3p noop\nbehind-the-scene * 3p-frame noop',
|
'dynamicFilteringString': 'behind-the-scene * 3p noop\nbehind-the-scene * 3p-frame noop',
|
||||||
|
@ -266,6 +266,18 @@ var onAdminSettingsRestored = function() {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// TODO(seamless migration):
|
||||||
|
// Eventually selected filter list keys will be loaded as a fetchable
|
||||||
|
// property. Until then we need to handle backward and forward
|
||||||
|
// compatibility, this means a special asynchronous call to load selected
|
||||||
|
// filter lists.
|
||||||
|
|
||||||
|
var onAdminSettingsRestored = function() {
|
||||||
|
µb.loadSelectedFilterLists(onSelectedFilterListsLoaded);
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
µb.hiddenSettings = (function() {
|
µb.hiddenSettings = (function() {
|
||||||
var out = objectAssign({}, µb.hiddenSettingsDefault),
|
var out = objectAssign({}, µb.hiddenSettingsDefault),
|
||||||
json = vAPI.localStorage.getItem('hiddenSettings');
|
json = vAPI.localStorage.getItem('hiddenSettings');
|
||||||
|
|
|
@ -170,7 +170,12 @@
|
||||||
var µb = this;
|
var µb = this;
|
||||||
vAPI.storage.get([ 'selectedFilterLists', 'remoteBlacklists' ], function(bin) {
|
vAPI.storage.get([ 'selectedFilterLists', 'remoteBlacklists' ], function(bin) {
|
||||||
if ( !bin || !bin.selectedFilterLists && !bin.remoteBlacklists ) {
|
if ( !bin || !bin.selectedFilterLists && !bin.remoteBlacklists ) {
|
||||||
return callback();
|
// Select default filter lists if first-time launch.
|
||||||
|
µb.assets.metadata(function(availableLists) {
|
||||||
|
µb.saveSelectedFilterLists(µb.autoSelectRegionalFilterLists(availableLists));
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
var listKeys = [];
|
var listKeys = [];
|
||||||
if ( bin.selectedFilterLists ) {
|
if ( bin.selectedFilterLists ) {
|
||||||
|
@ -186,15 +191,13 @@
|
||||||
// Uncomment when all have moved to v1.11 and beyond.
|
// Uncomment when all have moved to v1.11 and beyond.
|
||||||
//vAPI.storage.remove('remoteBlacklists');
|
//vAPI.storage.remove('remoteBlacklists');
|
||||||
}
|
}
|
||||||
µb.selectedFilterLists = listKeys.slice();
|
µb.selectedFilterLists = listKeys;
|
||||||
callback(listKeys);
|
callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
µBlock.saveSelectedFilterLists = function(newKeys, append) {
|
µBlock.saveSelectedFilterLists = function(newKeys, append) {
|
||||||
var µb = this;
|
var oldKeys = this.selectedFilterLists.slice();
|
||||||
this.loadSelectedFilterLists(function(oldKeys) {
|
|
||||||
oldKeys = oldKeys || [];
|
|
||||||
if ( append ) {
|
if ( append ) {
|
||||||
newKeys = newKeys.concat(oldKeys);
|
newKeys = newKeys.concat(oldKeys);
|
||||||
}
|
}
|
||||||
|
@ -202,17 +205,16 @@
|
||||||
// Purge unused filter lists from cache.
|
// Purge unused filter lists from cache.
|
||||||
for ( var i = 0, n = oldKeys.length; i < n; i++ ) {
|
for ( var i = 0, n = oldKeys.length; i < n; i++ ) {
|
||||||
if ( newSet.has(oldKeys[i]) === false ) {
|
if ( newSet.has(oldKeys[i]) === false ) {
|
||||||
µb.removeFilterList(oldKeys[i]);
|
this.removeFilterList(oldKeys[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newKeys = µb.setToArray(newSet);
|
newKeys = this.setToArray(newSet);
|
||||||
var bin = {
|
var bin = {
|
||||||
selectedFilterLists: newKeys,
|
selectedFilterLists: newKeys,
|
||||||
remoteBlacklists: µb.oldDataFromNewListKeys(newKeys)
|
remoteBlacklists: this.oldDataFromNewListKeys(newKeys)
|
||||||
};
|
};
|
||||||
µb.selectedFilterLists = newKeys;
|
this.selectedFilterLists = newKeys;
|
||||||
vAPI.storage.set(bin);
|
vAPI.storage.set(bin);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(seamless migration):
|
// TODO(seamless migration):
|
||||||
|
@ -429,7 +431,7 @@
|
||||||
|
|
||||||
µBlock.autoSelectRegionalFilterLists = function(lists) {
|
µBlock.autoSelectRegionalFilterLists = function(lists) {
|
||||||
var lang = self.navigator.language.slice(0, 2),
|
var lang = self.navigator.language.slice(0, 2),
|
||||||
selectedListKeys = [],
|
selectedListKeys = [ this.userFiltersPath ],
|
||||||
list;
|
list;
|
||||||
for ( var key in lists ) {
|
for ( var key in lists ) {
|
||||||
if ( lists.hasOwnProperty(key) === false ) { continue; }
|
if ( lists.hasOwnProperty(key) === false ) { continue; }
|
||||||
|
@ -522,26 +524,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Selected lists.
|
// Built-in filter lists loaded.
|
||||||
var onSelectedListsLoaded = function(keys) {
|
|
||||||
var listKey;
|
|
||||||
// No user lists data means use default settings.
|
|
||||||
if ( Array.isArray(keys) ) {
|
|
||||||
var listKeySet = new Set(keys);
|
|
||||||
for ( listKey in newAvailableLists ) {
|
|
||||||
if ( newAvailableLists.hasOwnProperty(listKey) ) {
|
|
||||||
newAvailableLists[listKey].off = !listKeySet.has(listKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ( µb.firstInstall ) {
|
|
||||||
µb.saveSelectedFilterLists(µb.autoSelectRegionalFilterLists(newAvailableLists));
|
|
||||||
}
|
|
||||||
|
|
||||||
finalize();
|
|
||||||
callback(newAvailableLists);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Built-in filter lists.
|
|
||||||
var onBuiltinListsLoaded = function(entries) {
|
var onBuiltinListsLoaded = function(entries) {
|
||||||
for ( var assetKey in entries ) {
|
for ( var assetKey in entries ) {
|
||||||
if ( entries.hasOwnProperty(assetKey) === false ) { continue; }
|
if ( entries.hasOwnProperty(assetKey) === false ) { continue; }
|
||||||
|
@ -551,7 +534,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load set of currently selected filter lists.
|
// Load set of currently selected filter lists.
|
||||||
µb.loadSelectedFilterLists(onSelectedListsLoaded);
|
var listKeySet = new Set(µb.selectedFilterLists);
|
||||||
|
for ( listKey in newAvailableLists ) {
|
||||||
|
if ( newAvailableLists.hasOwnProperty(listKey) ) {
|
||||||
|
newAvailableLists[listKey].off = !listKeySet.has(listKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finalize();
|
||||||
|
callback(newAvailableLists);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Available lists previously computed.
|
// Available lists previously computed.
|
||||||
|
|
Loading…
Reference in New Issue