Skip to content

Commit aadf4a6

Browse files
committed
1 parent 393d0b2 commit aadf4a6

4 files changed

Lines changed: 147 additions & 149 deletions

File tree

src/js/assets.js

Lines changed: 92 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -137,72 +137,74 @@ var getTextFileFromURL = function(url, onLoad, onError) {
137137
**/
138138

139139
api.listKeyAliases = {
140-
"assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat": "public_suffix_list.dat",
141-
"assets/user/filters.txt": "user-filters",
142-
"assets/ublock/resources.txt": "ublock-resources",
143-
"assets/ublock/filters.txt": "ublock-filters",
144-
"assets/ublock/privacy.txt": "ublock-privacy",
145-
"assets/ublock/unbreak.txt": "ublock-unbreak",
146-
"assets/ublock/badware.txt": "ublock-badware",
147-
"assets/ublock/experimental.txt": "ublock-experimental",
148-
"https://easylist-downloads.adblockplus.org/easylistchina.txt": "CHN-0",
149-
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt": "CHN-1",
150-
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt": "CHN-2",
151-
"https://easylist-downloads.adblockplus.org/easylistgermany.txt": "DEU-0",
152-
"https://adblock.dk/block.csv": "DNK-0",
153-
"assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt": "easylist",
154-
"https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt": "easylist-nocosmetic",
155-
"assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt": "easyprivacy",
156-
"https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt": "fanboy-annoyance",
157-
"https://easylist-downloads.adblockplus.org/fanboy-social.txt": "fanboy-social",
158-
"https://easylist-downloads.adblockplus.org/liste_fr.txt": "FRA-0",
159-
"http://adblock.gardar.net/is.abp.txt": "ISL-0",
160-
"https://easylist-downloads.adblockplus.org/easylistitaly.txt": "ITA-0",
161-
"https://dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt": "ITA-1",
162-
"https://easylist-downloads.adblockplus.org/advblock.txt": "RUS-0",
163-
"https://easylist-downloads.adblockplus.org/bitblock.txt": "RUS-1",
164-
"https://filters.adtidy.org/extension/chromium/filters/1.txt": "RUS-2",
165-
"https://adguard.com/en/filter-rules.html?id=1": "RUS-2",
166-
"https://easylist-downloads.adblockplus.org/easylistdutch.txt": "NLD-0",
167-
"https://notabug.org/latvian-list/adblock-latvian/raw/master/lists/latvian-list.txt": "LVA-0",
168-
"http://hosts-file.net/.%5Cad_servers.txt": "hphosts",
169-
"http://adblock.ee/list.php": "EST-0",
170-
"https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt": "disconnect-malvertising",
171-
"https://s3.amazonaws.com/lists.disconnect.me/simple_malware.txt": "disconnect-malware",
172-
"https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt": "disconnect-tracking",
173-
"https://www.certyficate.it/adblock/adblock.txt": "POL-0",
174-
"https://easylist-downloads.adblockplus.org/antiadblockfilters.txt": "awrl-0",
175-
"http://adb.juvander.net/Finland_adb.txt": "FIN-0",
176-
"https://raw.githubusercontent.com/gfmaster/adblock-korea-contrib/master/filter.txt": "KOR-0",
177-
"https://raw.githubusercontent.com/yous/YousList/master/youslist.txt": "KOR-1",
178-
"https://www.fanboy.co.nz/fanboy-korean.txt": "KOR-2",
179-
"https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
180-
"https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt": "JPN-0",
181-
"https://raw.githubusercontent.com/liamja/Prebake/master/obtrusive.txt": "EU-prebake",
182-
"https://easylist-downloads.adblockplus.org/Liste_AR.txt": "ara-0",
183-
"http://margevicius.lt/easylistlithuania.txt": "LTU-0",
184-
"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt": "malware-0",
185-
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains": "malware-1",
186-
"http://malwaredomains.lehigh.edu/files/immortal_domains.txt": "malware-2",
187-
"assets/thirdparties/pgl.yoyo.org/as/serverlist": "plowe-0",
188-
"https://raw.githubusercontent.com/easylist/EasyListHebrew/master/EasyListHebrew.txt": "ISR-0",
189-
"https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt": "reek-0",
190-
"https://raw.githubusercontent.com/szpeter80/hufilter/master/hufilter.txt": "HUN-0",
191-
"https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt": "CZE-0",
192-
"http://someonewhocares.org/hosts/hosts": "dpollock-0",
193-
"https://raw.githubusercontent.com/Dawsey21/Lists/master/adblock-list.txt": "spam404-0",
194-
"http://stanev.org/abp/adblock_bg.txt": "BGR-0",
195-
"http://winhelp2002.mvps.org/hosts.txt": "mvps-0",
196-
"https://www.fanboy.co.nz/enhancedstats.txt": "fanboy-enhanced",
197-
"https://www.fanboy.co.nz/fanboy-antifacebook.txt": "fanboy-thirdparty_social",
198-
"https://easylist-downloads.adblockplus.org/easylistspanish.txt": "spa-0",
199-
"https://www.fanboy.co.nz/fanboy-swedish.txt": "SWE-0",
200-
"https://www.fanboy.co.nz/r/fanboy-ultimate.txt": "fanboy-ultimate",
201-
"https://filters.adtidy.org/extension/chromium/filters/13.txt": "TUR-0",
202-
"https://adguard.com/filter-rules.html?id=13": "TUR-0",
203-
"https://www.fanboy.co.nz/fanboy-vietnam.txt": "VIE-0",
204-
"https://www.void.gr/kargig/void-gr-filters.txt": "GRC-0",
205-
"https://raw.githubusercontent.com/betterwebleon/slovenian-list/master/filters.txt": "SVN-0"
140+
"assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat": "public_suffix_list.dat",
141+
"assets/user/filters.txt": "user-filters",
142+
"assets/ublock/resources.txt": "ublock-resources",
143+
"assets/ublock/filters.txt": "ublock-filters",
144+
"assets/ublock/privacy.txt": "ublock-privacy",
145+
"assets/ublock/unbreak.txt": "ublock-unbreak",
146+
"assets/ublock/badware.txt": "ublock-badware",
147+
"assets/ublock/experimental.txt": "ublock-experimental",
148+
"https://easylist-downloads.adblockplus.org/easylistchina.txt": "CHN-0",
149+
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt": "CHN-1",
150+
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt": "CHN-2",
151+
"https://easylist-downloads.adblockplus.org/easylistgermany.txt": "DEU-0",
152+
"https://adblock.dk/block.csv": "DNK-0",
153+
"assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt": "easylist",
154+
"https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt": "easylist-nocosmetic",
155+
"assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt": "easyprivacy",
156+
"https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt": "fanboy-annoyance",
157+
"https://easylist-downloads.adblockplus.org/fanboy-social.txt": "fanboy-social",
158+
"https://easylist-downloads.adblockplus.org/liste_fr.txt": "FRA-0",
159+
"http://adblock.gardar.net/is.abp.txt": "ISL-0",
160+
"https://easylist-downloads.adblockplus.org/easylistitaly.txt": "ITA-0",
161+
"https://dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt": "ITA-1",
162+
"https://easylist-downloads.adblockplus.org/advblock.txt": "RUS-0",
163+
"https://easylist-downloads.adblockplus.org/bitblock.txt": "RUS-1",
164+
"https://filters.adtidy.org/extension/chromium/filters/1.txt": "RUS-2",
165+
"https://adguard.com/en/filter-rules.html?id=1": "RUS-2",
166+
"https://easylist-downloads.adblockplus.org/easylistdutch.txt": "NLD-0",
167+
"https://notabug.org/latvian-list/adblock-latvian/raw/master/lists/latvian-list.txt": "LVA-0",
168+
"http://hosts-file.net/.%5Cad_servers.txt": "hphosts",
169+
"http://adblock.ee/list.php": "EST-0",
170+
"https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt": "disconnect-malvertising",
171+
"https://s3.amazonaws.com/lists.disconnect.me/simple_malware.txt": "disconnect-malware",
172+
"https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt": "disconnect-tracking",
173+
"https://www.certyficate.it/adblock/adblock.txt": "POL-0",
174+
"https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-adblock-filters/adblock.txt": "POL-0",
175+
"https://easylist-downloads.adblockplus.org/antiadblockfilters.txt": "awrl-0",
176+
"http://adb.juvander.net/Finland_adb.txt": "FIN-0",
177+
"https://raw.githubusercontent.com/gfmaster/adblock-korea-contrib/master/filter.txt": "KOR-0",
178+
"https://raw.githubusercontent.com/yous/YousList/master/youslist.txt": "KOR-1",
179+
"https://www.fanboy.co.nz/fanboy-korean.txt": "KOR-2",
180+
"https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
181+
"https://raw.githubusercontent.com/ABPindo/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
182+
"https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt": "JPN-0",
183+
"https://raw.githubusercontent.com/liamja/Prebake/master/obtrusive.txt": "EU-prebake",
184+
"https://easylist-downloads.adblockplus.org/Liste_AR.txt": "ara-0",
185+
"http://margevicius.lt/easylistlithuania.txt": "LTU-0",
186+
"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt": "malware-0",
187+
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains": "malware-1",
188+
"http://malwaredomains.lehigh.edu/files/immortal_domains.txt": "malware-2",
189+
"assets/thirdparties/pgl.yoyo.org/as/serverlist": "plowe-0",
190+
"https://raw.githubusercontent.com/easylist/EasyListHebrew/master/EasyListHebrew.txt": "ISR-0",
191+
"https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt": "reek-0",
192+
"https://raw.githubusercontent.com/szpeter80/hufilter/master/hufilter.txt": "HUN-0",
193+
"https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt": "CZE-0",
194+
"http://someonewhocares.org/hosts/hosts": "dpollock-0",
195+
"https://raw.githubusercontent.com/Dawsey21/Lists/master/adblock-list.txt": "spam404-0",
196+
"http://stanev.org/abp/adblock_bg.txt": "BGR-0",
197+
"http://winhelp2002.mvps.org/hosts.txt": "mvps-0",
198+
"https://www.fanboy.co.nz/enhancedstats.txt": "fanboy-enhanced",
199+
"https://www.fanboy.co.nz/fanboy-antifacebook.txt": "fanboy-thirdparty_social",
200+
"https://easylist-downloads.adblockplus.org/easylistspanish.txt": "spa-0",
201+
"https://www.fanboy.co.nz/fanboy-swedish.txt": "SWE-0",
202+
"https://www.fanboy.co.nz/r/fanboy-ultimate.txt": "fanboy-ultimate",
203+
"https://filters.adtidy.org/extension/chromium/filters/13.txt": "TUR-0",
204+
"https://adguard.com/filter-rules.html?id=13": "TUR-0",
205+
"https://www.fanboy.co.nz/fanboy-vietnam.txt": "VIE-0",
206+
"https://www.void.gr/kargig/void-gr-filters.txt": "GRC-0",
207+
"https://raw.githubusercontent.com/betterwebleon/slovenian-list/master/filters.txt": "SVN-0"
206208
};
207209

208210
var migrate = function(callback) {
@@ -343,37 +345,37 @@ var saveAssetSourceRegistry = (function() {
343345
};
344346
})();
345347

346-
var updateAssetSourceRegistry = function(json) {
348+
var updateAssetSourceRegistry = function(json, silent) {
347349
var newDict;
348350
try {
349351
newDict = JSON.parse(json);
350352
} catch (ex) {
351353
}
352354
if ( newDict instanceof Object === false ) { return; }
353355

354-
getAssetSourceRegistry(function(oldDict) {
355-
var assetKey;
356-
// Remove obsolete entries (only those which were built-in).
357-
for ( assetKey in oldDict ) {
358-
if (
359-
newDict[assetKey] === undefined &&
360-
oldDict[assetKey].submitter === undefined
361-
) {
362-
unregisterAssetSource(assetKey);
363-
}
356+
var oldDict = assetSourceRegistry,
357+
assetKey;
358+
359+
// Remove obsolete entries (only those which were built-in).
360+
for ( assetKey in oldDict ) {
361+
if (
362+
newDict[assetKey] === undefined &&
363+
oldDict[assetKey].submitter === undefined
364+
) {
365+
unregisterAssetSource(assetKey);
364366
}
365-
// Add/update existing entries. Notify of new asset sources.
366-
for ( assetKey in newDict ) {
367-
if ( oldDict[assetKey] === undefined ) {
368-
fireNotification(
369-
'builtin-asset-source-added',
370-
{ assetKey: assetKey, entry: newDict[assetKey] }
371-
);
372-
}
373-
registerAssetSource(assetKey, newDict[assetKey]);
367+
}
368+
// Add/update existing entries. Notify of new asset sources.
369+
for ( assetKey in newDict ) {
370+
if ( oldDict[assetKey] === undefined && !silent ) {
371+
fireNotification(
372+
'builtin-asset-source-added',
373+
{ assetKey: assetKey, entry: newDict[assetKey] }
374+
);
374375
}
375-
saveAssetSourceRegistry();
376-
});
376+
registerAssetSource(assetKey, newDict[assetKey]);
377+
}
378+
saveAssetSourceRegistry();
377379
};
378380

379381
var getAssetSourceRegistry = function(callback) {
@@ -406,7 +408,7 @@ var getAssetSourceRegistry = function(callback) {
406408
getTextFileFromURL(
407409
µBlock.assetsBootstrapLocation || 'assets/assets.json',
408410
function() {
409-
updateAssetSourceRegistry(this.responseText);
411+
updateAssetSourceRegistry(this.responseText, true);
410412
registryReady();
411413
}
412414
);
@@ -899,7 +901,7 @@ api.metadata = function(callback) {
899901
});
900902

901903
getAssetCacheRegistry(function() {
902-
cacheRegistryReady = assetCacheRegistry;
904+
cacheRegistryReady = true;
903905
if ( assetRegistryReady ) { onReady(); }
904906
});
905907
};

src/js/messaging.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -754,27 +754,25 @@ var backupUserData = function(callback) {
754754
timeStamp: Date.now(),
755755
version: vAPI.app.version,
756756
userSettings: µb.userSettings,
757-
selectedFilterLists: [],
757+
selectedFilterLists: µb.selectedFilterLists,
758758
hiddenSettingsString: µb.stringFromHiddenSettings(),
759759
netWhitelist: µb.stringFromWhitelist(µb.netWhitelist),
760760
dynamicFilteringString: µb.permanentFirewall.toString(),
761761
urlFilteringString: µb.permanentURLFiltering.toString(),
762762
hostnameSwitchesString: µb.hnSwitches.toString(),
763-
userFilters: ''
764-
};
765-
766-
var onSelectedListsReady = function(selectedFilterLists) {
767-
userData.selectedFilterLists = selectedFilterLists;
768-
763+
userFilters: '',
769764
// TODO(seamless migration):
770765
// The following is strictly for convenience, to be minimally
771766
// forward-compatible. This will definitely be removed in the
772767
// short term, as I do not expect the need to install an older
773768
// version of uBO to ever be needed beyond the short term.
774769
// >>>>>>>>
775-
userData.filterLists = µb.oldDataFromNewListKeys(selectedFilterLists);
770+
filterLists: µb.oldDataFromNewListKeys(µb.selectedFilterLists)
776771
// <<<<<<<<
772+
};
777773

774+
var onUserFiltersReady = function(details) {
775+
userData.userFilters = details.content;
778776
var filename = vAPI.i18n('aboutBackupFilename')
779777
.replace('{{datetime}}', µb.dateNowToSensibleString())
780778
.replace(/ +/g, '_');
@@ -789,11 +787,6 @@ var backupUserData = function(callback) {
789787
getLocalData(callback);
790788
};
791789

792-
var onUserFiltersReady = function(details) {
793-
userData.userFilters = details.content;
794-
µb.loadSelectedFilterLists(onSelectedListsReady);
795-
};
796-
797790
µb.assets.get(µb.userFiltersPath, onUserFiltersReady);
798791
};
799792

src/js/start.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ var fromFetch = function(to, fetched) {
241241

242242
/******************************************************************************/
243243

244-
var onAdminSettingsRestored = function() {
244+
var onSelectedFilterListsLoaded = function() {
245245
var fetchableProps = {
246246
'compiledMagic': '',
247247
'dynamicFilteringString': 'behind-the-scene * 3p noop\nbehind-the-scene * 3p-frame noop',
@@ -266,6 +266,18 @@ var onAdminSettingsRestored = function() {
266266

267267
/******************************************************************************/
268268

269+
// TODO(seamless migration):
270+
// Eventually selected filter list keys will be loaded as a fetchable
271+
// property. Until then we need to handle backward and forward
272+
// compatibility, this means a special asynchronous call to load selected
273+
// filter lists.
274+
275+
var onAdminSettingsRestored = function() {
276+
µb.loadSelectedFilterLists(onSelectedFilterListsLoaded);
277+
};
278+
279+
/******************************************************************************/
280+
269281
µb.hiddenSettings = (function() {
270282
var out = objectAssign({}, µb.hiddenSettingsDefault),
271283
json = vAPI.localStorage.getItem('hiddenSettings');

0 commit comments

Comments
 (0)