Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #64 from NanoAdblocker/sync-1.14.23b2
Browse files Browse the repository at this point in the history
Sync (one commit after) 1.14.23b2
  • Loading branch information
jspenguin2017 authored Dec 24, 2017
2 parents 4a0b22f + ba16041 commit 44c9cce
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 335 deletions.
4 changes: 2 additions & 2 deletions src/_locales/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"description": "English: Click: disable\/enable uBlock₀ for this site.\n\nCtrl+click: disable uBlock₀ only on this page."
},
"popupPowerSwitchInfo1": {
"message": "클릭: 이 사이트에서 uBlock₀을 끕니다.\n\nCtrl+클릭: 이 페이지에서 uBlock₀을 끕니다.",
"message": "클릭: 이 사이트에서 uBlock₀을 끕니다.\n\nCtrl+클릭: 이 페이지에서만 uBlock₀을 끕니다.",
"description": "Message to be read by screen readers"
},
"popupPowerSwitchInfo2": {
Expand Down Expand Up @@ -364,7 +364,7 @@
"description": "English: Malware domains"
},
"3pGroupAnnoyances": {
"message": "성가신",
"message": "방해되는",
"description": "The header identifying the filter lists in the category 'annoyances'"
},
"3pGroupMultipurpose": {
Expand Down
9 changes: 1 addition & 8 deletions src/js/3p-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,9 @@ var fromCloudData = function(data, append) {
checked = data.ignoreGenericCosmeticFilters === true || append && elem.checked;
elem.checked = listDetails.ignoreGenericCosmeticFilters = checked;

var listKey;
for ( i = 0, n = data.selectedLists.length; i < n; i++ ) {
listKey = data.selectedLists[i];
if ( listDetails.aliases[listKey] ) {
data.selectedLists[i] = listDetails.aliases[listKey];
}
}
var selectedSet = new Set(data.selectedLists),
listEntries = uDom('#lists .listEntry'),
listEntry, input;
listEntry, listKey, input;
for ( i = 0, n = listEntries.length; i < n; i++ ) {
listEntry = listEntries.at(i);
listKey = listEntry.attr('data-listkey');
Expand Down
231 changes: 78 additions & 153 deletions src/js/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,155 +167,76 @@ api.fetchText = function(url, onLoad, onError) {
}
};

/*******************************************************************************
TODO(seamless migration):
This block of code will be removed when I am confident all users have
moved to a version of uBO which does not require the old way of caching
assets.
api.listKeyAliases: a map of old asset keys to new asset keys.
migrate(): to seamlessly migrate the old cache manager to the new one:
- attempt to preserve and move content of cached assets to new locations;
- removes all traces of now obsolete cache manager entries in cacheStorage.
This code will typically execute only once, when the newer version of uBO
is first installed and executed.
**/

api.listKeyAliases = {
"assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat": "public_suffix_list.dat",
"assets/user/filters.txt": "user-filters",
"assets/ublock/resources.txt": "ublock-resources",
"assets/ublock/filters.txt": "ublock-filters",
"assets/ublock/privacy.txt": "ublock-privacy",
"assets/ublock/unbreak.txt": "ublock-unbreak",
"assets/ublock/badware.txt": "ublock-badware",
"assets/ublock/experimental.txt": "ublock-experimental",
"https://easylist-downloads.adblockplus.org/easylistchina.txt": "CHN-0",
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt": "CHN-1",
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt": "CHN-2",
"https://easylist-downloads.adblockplus.org/easylistgermany.txt": "DEU-0",
"https://adblock.dk/block.csv": "DNK-0",
"assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt": "easylist",
"https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt": "easylist-nocosmetic",
"assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt": "easyprivacy",
"https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt": "fanboy-annoyance",
"https://easylist-downloads.adblockplus.org/fanboy-social.txt": "fanboy-social",
"https://easylist-downloads.adblockplus.org/liste_fr.txt": "FRA-0",
"http://adblock.gardar.net/is.abp.txt": "ISL-0",
"https://easylist-downloads.adblockplus.org/easylistitaly.txt": "ITA-0",
"https://dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt": "ITA-1",
"https://easylist-downloads.adblockplus.org/advblock.txt": "RUS-0",
"https://easylist-downloads.adblockplus.org/bitblock.txt": "RUS-1",
"https://filters.adtidy.org/extension/chromium/filters/1.txt": "RUS-2",
"https://adguard.com/en/filter-rules.html?id=1": "RUS-2",
"https://easylist-downloads.adblockplus.org/easylistdutch.txt": "NLD-0",
"https://notabug.org/latvian-list/adblock-latvian/raw/master/lists/latvian-list.txt": "LVA-0",
"http://hosts-file.net/.%5Cad_servers.txt": "hphosts",
"http://adblock.ee/list.php": "EST-0",
"https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt": "disconnect-malvertising",
"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://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",
"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/yous/YousList/master/youslist.txt": "KOR-1",
"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/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/liamja/Prebake/master/obtrusive.txt": "EU-prebake",
"https://easylist-downloads.adblockplus.org/Liste_AR.txt": "ara-0",
"http://margevicius.lt/easylistlithuania.txt": "LTU-0",
"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt": "malware-0",
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains": "malware-1",
"http://malwaredomains.lehigh.edu/files/immortal_domains.txt": "malware-2",
"assets/thirdparties/pgl.yoyo.org/as/serverlist": "plowe-0",
"https://raw.githubusercontent.com/easylist/EasyListHebrew/master/EasyListHebrew.txt": "ISR-0",
"https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt": "reek-0",
"https://raw.githubusercontent.com/szpeter80/hufilter/master/hufilter.txt": "HUN-0",
"https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt": "CZE-0",
"http://someonewhocares.org/hosts/hosts": "dpollock-0",
"https://raw.githubusercontent.com/Dawsey21/Lists/master/adblock-list.txt": "spam404-0",
"http://stanev.org/abp/adblock_bg.txt": "BGR-0",
"http://winhelp2002.mvps.org/hosts.txt": "mvps-0",
"https://www.fanboy.co.nz/enhancedstats.txt": "fanboy-enhanced",
"https://www.fanboy.co.nz/fanboy-antifacebook.txt": "fanboy-thirdparty_social",
"https://easylist-downloads.adblockplus.org/easylistspanish.txt": "spa-0",
"https://www.fanboy.co.nz/fanboy-swedish.txt": "SWE-0",
"https://www.fanboy.co.nz/r/fanboy-ultimate.txt": "fanboy-ultimate",
"https://filters.adtidy.org/extension/chromium/filters/13.txt": "TUR-0",
"https://adguard.com/filter-rules.html?id=13": "TUR-0",
"https://www.fanboy.co.nz/fanboy-vietnam.txt": "VIE-0",
"https://www.void.gr/kargig/void-gr-filters.txt": "GRC-0",
"https://raw.githubusercontent.com/betterwebleon/slovenian-list/master/filters.txt": "SVN-0"
};

var migrate = function(callback) {
var entries,
moveCount = 0,
toRemove = [];

var countdown = function(change) {
moveCount -= (change || 0);
if ( moveCount !== 0 ) { return; }
vAPI.cacheStorage.remove(toRemove);
saveAssetCacheRegistry();
callback();
};
/******************************************************************************/

var onContentRead = function(oldKey, newKey, bin) {
var content = bin && bin['cached_asset_content://' + oldKey] || undefined;
if ( content ) {
assetCacheRegistry[newKey] = {
readTime: Date.now(),
writeTime: entries[oldKey]
};
if ( reIsExternalPath.test(oldKey) ) {
assetCacheRegistry[newKey].remoteURL = oldKey;
// https://github.com/gorhill/uBlock/issues/3331
// Support the seamless loading of sublists.

api.fetchFilterList = function(mainlistURL, onLoad, onError) {
var content = [],
errored = false,
pendingSublistURLs = new Set([ mainlistURL ]),
loadedSublistURLs = new Set(),
toParsedURL = api.fetchFilterList.toParsedURL,
parsedMainURL = toParsedURL(mainlistURL);

var onLocalLoadSuccess = function(details) {
if ( errored ) { return; }

var isSublist = details.url !== mainlistURL,
sublistURL;

pendingSublistURLs.delete(details.url);
loadedSublistURLs.add(details.url);
if ( isSublist ) { content.push('\n! ' + '>>>>>>>> ' + details.url); }
content.push(details.content.trim());
if ( isSublist ) { content.push('! <<<<<<<< ' + details.url); }

if ( parsedMainURL !== undefined ) {
var reInclude = /^!#include +(\S+)/gm,
match = reInclude.exec(details.content);
while ( match !== null ) {
var parsedSubURL = toParsedURL(match[1]);
if ( parsedSubURL === undefined ) {
parsedSubURL = toParsedURL(
parsedMainURL.href.replace(/[^/?]+(?:\?.*)?$/, match[1])
);
if ( parsedSubURL === undefined ) { continue; }
}
if ( parsedSubURL.origin !== parsedMainURL.origin ) { continue; }
if ( loadedSublistURLs.has(parsedSubURL.href) ) { continue; }
pendingSublistURLs.add(parsedSubURL.href);
match = reInclude.exec(details.content);
}
bin = {};
bin['cache/' + newKey] = content;
vAPI.cacheStorage.set(bin);
}
countdown(1);
};

var onEntries = function(bin) {
entries = bin && bin['cached_asset_entries'];
if ( !entries ) { return callback(); }
if ( bin && bin['assetCacheRegistry'] ) {
assetCacheRegistry = bin['assetCacheRegistry'];
}
var aliases = api.listKeyAliases;
for ( var oldKey in entries ) {
if ( oldKey.endsWith('assets/user/filters.txt') ) { continue; }
var newKey = aliases[oldKey];
if ( !newKey && /^https?:\/\//.test(oldKey) ) {
newKey = oldKey;
}
if ( newKey ) {
vAPI.cacheStorage.get(
'cached_asset_content://' + oldKey,
onContentRead.bind(null, oldKey, newKey)
);
moveCount += 1;
if ( pendingSublistURLs.size !== 0 ) {
for ( sublistURL of pendingSublistURLs ) {
api.fetchText(sublistURL, onLocalLoadSuccess, onLocalLoadError);
}
toRemove.push('cached_asset_content://' + oldKey);
return;
}
toRemove.push('cached_asset_entries', 'extensionLastVersion');
countdown();

details.url = mainlistURL;
details.content = content.join('\n').trim();
onLoad(details);
};

var onLocalLoadError = function(details) {
errored = true;
details.url = mainlistURL;
details.content = '';
onError(details);
};

vAPI.cacheStorage.get(
[ 'cached_asset_entries', 'assetCacheRegistry' ],
onEntries
);
this.fetchText(mainlistURL, onLocalLoadSuccess, onLocalLoadError);
};

api.fetchFilterList.toParsedURL = function(url) {
try {
return new URL(url);
} catch (ex) {
}
};

/*******************************************************************************
Expand Down Expand Up @@ -524,16 +445,12 @@ var getAssetCacheRegistry = function(callback) {
}
};

var migrationDone = function() {
vAPI.cacheStorage.get('assetCacheRegistry', function(bin) {
if ( bin && bin.assetCacheRegistry ) {
assetCacheRegistry = bin.assetCacheRegistry;
}
registryReady();
});
};

migrate(migrationDone);
vAPI.cacheStorage.get('assetCacheRegistry', function(bin) {
if ( bin && bin.assetCacheRegistry ) {
assetCacheRegistry = bin.assetCacheRegistry;
}
registryReady();
});
};

var saveAssetCacheRegistry = (function() {
Expand Down Expand Up @@ -807,7 +724,11 @@ api.get = function(assetKey, options, callback) {
if ( !contentURL ) {
return reportBack('', 'E_NOTFOUND');
}
api.fetchText(contentURL, onContentLoaded, onContentNotLoaded);
if ( assetDetails.content === 'filters' ) {
api.fetchFilterList(contentURL, onContentLoaded, onContentNotLoaded);
} else {
api.fetchText(contentURL, onContentLoaded, onContentNotLoaded);
}
};

var onContentLoaded = function(details) {
Expand Down Expand Up @@ -891,7 +812,11 @@ var getRemote = function(assetKey, callback) {
if ( !contentURL ) {
return reportBack('', 'E_NOTFOUND');
}
api.fetchText(contentURL, onRemoteContentLoaded, onRemoteContentError);
if ( assetDetails.content === 'filters' ) {
api.fetchFilterList(contentURL, onRemoteContentLoaded, onRemoteContentError);
} else {
api.fetchText(contentURL, onRemoteContentLoaded, onRemoteContentError);
}
};

getAssetSourceRegistry(function(registry) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ var µBlock = (function() { // jshint ignore:line
// read-only
systemSettings: {
compiledMagic: 'vrgorlgelgws',
selfieMagic: 'vrgorlgelgws'
selfieMagic: 'pxpclstriajk'
},

restoreBackupSettings: {
Expand Down
Loading

0 comments on commit 44c9cce

Please sign in to comment.