mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 18:19:38 +02:00
remove overhead of PSL for "3rd-party filters" tab
This commit is contained in:
parent
f149b2e340
commit
fb1221a8a1
@ -31,12 +31,10 @@
|
||||
|
||||
<div id="busyOverlay"></div>
|
||||
|
||||
<script src="lib/publicsuffixlist.min.js"></script>
|
||||
<script src="js/vapi-common.js"></script>
|
||||
<script src="js/vapi-client.js"></script>
|
||||
<script src="js/udom.js"></script>
|
||||
<script src="js/i18n.js"></script>
|
||||
<script src="js/uritools.js"></script>
|
||||
<script src="js/dashboard-common.js"></script>
|
||||
<script src="js/3p-filters.js"></script>
|
||||
|
||||
|
@ -36,8 +36,7 @@ var cacheWasPurged = false;
|
||||
var needUpdate = false;
|
||||
var hasCachedContent = false;
|
||||
|
||||
var re3rdPartyExternalAsset = /^https?:\/\/[a-z0-9]+/;
|
||||
var re3rdPartyRepoAsset = /^assets\/thirdparties\/([^\/]+)/;
|
||||
var re3rdPartyExternalAsset = /^https?:\/\/([a-z0-9.-]+)/;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -81,24 +80,15 @@ var renderBlacklists = function() {
|
||||
};
|
||||
|
||||
// Assemble a pretty blacklist name if possible
|
||||
var htmlFromHomeURL = function(blacklistHref) {
|
||||
if ( blacklistHref.indexOf('assets/thirdparties/') !== 0 ) {
|
||||
return '';
|
||||
}
|
||||
var matches = re3rdPartyRepoAsset.exec(blacklistHref);
|
||||
if ( matches === null || matches.length !== 2 ) {
|
||||
return '';
|
||||
}
|
||||
var hostname = matches[1];
|
||||
var domain = µBlock.URI.domainFromHostname(hostname);
|
||||
if ( domain === '' ) {
|
||||
var htmlFromHomeURL = function(entry) {
|
||||
if ( !entry.homeDomain ) {
|
||||
return '';
|
||||
}
|
||||
var html = [
|
||||
' <a href="http://',
|
||||
hostname,
|
||||
entry.homeHostname,
|
||||
'" target="_blank">(',
|
||||
domain,
|
||||
entry.homeDomain,
|
||||
')</a>'
|
||||
];
|
||||
return html.join('');
|
||||
@ -128,7 +118,7 @@ var renderBlacklists = function() {
|
||||
.replace('{{checked}}', list.off ? '' : 'checked')
|
||||
.replace('{{URL}}', encodeURI(listKey))
|
||||
.replace('{{name}}', listNameFromListKey(listKey))
|
||||
.replace('{{homeURL}}', htmlFromHomeURL(listKey))
|
||||
.replace('{{homeURL}}', htmlFromHomeURL(list))
|
||||
.replace('{{used}}', !list.off && !isNaN(+list.entryUsedCount) ? renderNumber(list.entryUsedCount) : '0')
|
||||
.replace('{{total}}', !isNaN(+list.entryCount) ? renderNumber(list.entryCount) : '?');
|
||||
html.push(li);
|
||||
|
@ -449,6 +449,23 @@ var µb = µBlock;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var prepEntries = function(entries) {
|
||||
var µburi = µb.URI;
|
||||
var entry;
|
||||
for ( var k in entries ) {
|
||||
if ( entries.hasOwnProperty(k) === false ) {
|
||||
continue;
|
||||
}
|
||||
entry = entries[k];
|
||||
if ( typeof entry.homeURL === 'string' ) {
|
||||
entry.homeHostname = µburi.hostnameFromURI(entry.homeURL);
|
||||
entry.homeDomain = µburi.domainFromHostname(entry.homeHostname);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var getLists = function(callback) {
|
||||
var r = {
|
||||
available: null,
|
||||
@ -462,10 +479,12 @@ var getLists = function(callback) {
|
||||
};
|
||||
var onMetadataReady = function(entries) {
|
||||
r.cache = entries;
|
||||
prepEntries(r.cache);
|
||||
callback(r);
|
||||
};
|
||||
var onLists = function(lists) {
|
||||
r.available = lists;
|
||||
prepEntries(r.available);
|
||||
µb.assets.metadata(onMetadataReady);
|
||||
};
|
||||
µb.getAvailableLists(onLists);
|
||||
|
Loading…
Reference in New Issue
Block a user