1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 08:37:11 +02:00

this fixes #30, waiting for translations before release

This commit is contained in:
gorhill 2014-07-15 20:32:33 -04:00
parent 77895a6a57
commit 4bb07f1a5b
8 changed files with 7641 additions and 121 deletions

View File

@ -17,10 +17,17 @@ ul {
list-style-type: none;
}
ul > li {
margin: 0.5em 0 3px 0;
padding: 0;
font-size: 15px;
list-style-type: none;
}
ul > li > ul > li {
font-size: 14px;
margin: 0 0 0 1em;
}
.dim {
color: #444;
color: #888;
}
.userUbiquitousHosts {
font-size: smaller;
@ -33,17 +40,15 @@ ul > li {
<body>
<p id="listsOfBlockedHostsPrompt"></p>
<ul id="blacklistTemplate" style="display:none">
<li class="blacklistDetails"><input type="checkbox">&thinsp;<a href="" type="text/plain"></a>:
<span class="dim"></span>
</ul>
<ul id="blacklists" style="margin:0.5em 0 0 0;padding-left:1em;list-style-type:none">
<ul id="options" style="margin:0.5em 0 0 0;padding-left:1em;list-style-type:none">
<li><button id="blacklistsApply" disabled="true" data-i18n="3pApplyChanges"></button>
<li style="margin-top:0.75em"><input type="checkbox" id="parseAllABPHideFilters"><label data-i18n="3pParseAllABPHideFiltersPrompt1"></label>
<span class="dim" id="3pParseAllABPHideFiltersPrompt2"></span>
<button class="whatisthis"></button>
<div class="whatisthis-expandable para" data-i18n="3pParseAllABPHideFiltersInfo"></div>
<li style="margin-top:0.75em"><button id="blacklistsApply" disabled="true" data-i18n="3pApplyChanges"></button>
<li style="margin-top:0.75em"><p id="listsOfBlockedHostsPrompt"></p>
</ul>
<ul id="lists" style="margin:0.5em 0 0 0;padding-left:1em;list-style-type:none">
</ul>
<script src="js/udom.js"></script>

View File

@ -72,8 +72,8 @@
"description":"English: Show the number of blocked requests on the icon"
},
"3pListsOfBlockedHostsPrompt":{
"message":"{{ubiquitousBlacklistCount}} network filters from:",
"description":"English: {{ubiquitousBlacklistCount}} network filters from:"
"message":"{{netFilterCount}} network filters {{cosmeticFilterCount}} cosmetic filters from:",
"description":"English: {{netFilterCount}} network filters {{cosmeticFilterCount}} cosmetic filters from:"
},
"3pListsOfBlockedHostsPerListStats":{
"message":"{{used}} used out of {{total}}",
@ -99,6 +99,30 @@
"message":"Apply changes",
"description":"English: Apply changes"
},
"3pGroupAds":{
"message":"Ads",
"description":"English: Ads"
},
"3pGroupPrivacy":{
"message":"Privacy",
"description":"English: Privacy"
},
"3pGroupMalware":{
"message":"Malware",
"description":"English: Malware"
},
"3pGroupSocial":{
"message":"Social",
"description":"English: Social"
},
"3pGroupMultipurpose":{
"message":"Multipurpose",
"description":"English: Multipurpose"
},
"3pGroupRegions":{
"message":"Regions, languages",
"description":"English: Regions, languages"
},
"1pFormatHint":{
"message":"One filter per line. A filter can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with &lsquo;!&rsquo; will be ignored.",
"description":"English: One filter per line. A filter can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with &lsquo;!&rsquo; will be ignored."

File diff suppressed because it is too large Load Diff

View File

@ -1,160 +1,206 @@
{
"easylist-downloads.adblockplus.org/easylist.txt": {
"title": "EasyList",
"group": "ads"
},
"easylist-downloads.adblockplus.org/easyprivacy.txt": {
"title": "EasyPrivacy",
"group": "privacy"
},
"mirror1.malwaredomains.com/files/immortal_domains.txt": {
"title": "Long-lived malware domains"
"title": "Malware domains (long-lived)",
"group": "malware"
},
"mirror1.malwaredomains.com/files/justdomains": {
"title": "Malware domains"
"title": "Malware domains",
"group": "malware"
},
"pgl.yoyo.org/as/serverlist": {
"title": "Peter Lowes Ad server list"
"title": "Peter Lowes Ad server list",
"group": "ads"
},
"www.malwaredomainlist.com/hostslist/hosts.txt": {
"title": "Malware Domain List"
"title": "Malware Domain List",
"group": "malware"
},
"hosts-file.net/ad-servers": {
"off": true,
"title": "hpHostss Ad and tracking servers"
},
"someonewhocares.org/hosts/hosts": {
"off": true,
"title": "Dan Pollocks hosts file"
},
"winhelp2002.mvps.org/hosts.txt": {
"off": true,
"title": "MVPS HOSTS"
},
"spam404bl.com/spam404scamlist.txt": {
"off": true,
"title": "Spam404"
},
"easylist-downloads.adblockplus.org/easylist.txt": {
"title": "EasyList"
"title": "hpHostss Ad and tracking servers",
"group": "multipurpose"
},
"easylist-downloads.adblockplus.org/easylist_noelemhide.txt": {
"off": true,
"title": "EasyList without element hiding rules"
},
"easylist-downloads.adblockplus.org/easyprivacy.txt": {
"title": "EasyPrivacy"
},
"easylist-downloads.adblockplus.org/fanboy-annoyance.txt": {
"off": true,
"title": "Fanboys Annoyance List"
"title": "EasyList without element hiding rules",
"group": "ads"
},
"www.fanboy.co.nz/enhancedstats.txt": {
"off": true,
"title": "Fanboys Enhanced Tracking List"
"title": "Fanboys Enhanced Tracking List",
"group": "privacy"
},
"easylist-downloads.adblockplus.org/fanboy-annoyance.txt": {
"off": true,
"title": "Fanboys Annoyance List",
"group": "social"
},
"easylist-downloads.adblockplus.org/fanboy-social.txt": {
"off": true,
"title": "Fanboys Social Blocking List",
"group": "social"
},
"www.fanboy.co.nz/fanboy-antifacebook.txt": {
"off": true,
"title": "Fanboys Anti-Facebook (see warning inside list)"
"title": "Fanboys Anti-Facebook (see warning inside list)",
"group": "social"
},
"raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt": {
"off": true,
"title": "Anti-Adblock Killer | Filters for Adblockers"
"title": "Anti-Adblock Killer | Filters for Adblockers",
"group": "ads"
},
"someonewhocares.org/hosts/hosts": {
"off": true,
"title": "Dan Pollocks hosts file",
"group": "multipurpose"
},
"winhelp2002.mvps.org/hosts.txt": {
"off": true,
"title": "MVPS HOSTS",
"group": "multipurpose"
},
"spam404bl.com/spam404scamlist.txt": {
"off": true,
"title": "Spam404",
"group": "malware"
},
"easylist-downloads.adblockplus.org/easylistgermany.txt": {
"off": true,
"title": "EasyList Germany"
"title": "DEU: EasyList Germany",
"group": "regions"
},
"easylist-downloads.adblockplus.org/easylistitaly.txt": {
"off": true,
"title": "EasyList Italy"
"title": "ITA: EasyList Italy",
"group": "regions"
},
"easylist-downloads.adblockplus.org/easylistdutch.txt": {
"off": true,
"title": "EasyList Dutch"
"title": "NLD: EasyList Dutch",
"group": "regions"
},
"easylist-downloads.adblockplus.org/liste_fr.txt": {
"off": true,
"title": "EasyList Liste FR"
"title": "FRA: EasyList Liste FR",
"group": "regions"
},
"easylist-downloads.adblockplus.org/advblock.txt": {
"off": true,
"title": "RU AdList (Дополнительная региональная подписка)"
"title": "RUS: RU AdList (Дополнительная региональная подписка)",
"group": "regions"
},
"easylist-downloads.adblockplus.org/bitblock.txt": {
"off": true,
"title": "RU BitBlock List (Дополнительная подписка фильтров)"
"title": "RUS: BitBlock List (Дополнительная подписка фильтров)",
"group": "regions"
},
"easylist-downloads.adblockplus.org/easylistchina.txt": {
"off": true,
"title": "EasyList China (中文)"
"title": "CHN: EasyList China (中文)",
"group": "regions"
},
"cjxlist1.googlecode.com/svn/cjxlist.txt": {
"off": true,
"title": "cjxlist (main focus on Chinese sites)"
"title": "CHN: China: cjxlist (main focus on Chinese sites)",
"group": "regions"
},
"adblock-chinalist.googlecode.com/svn/trunk/adblock.txt": {
"off": true,
"title": "EasyList China (obsolete: to be removed)"
"title": "CHN: EasyList China (obsolete: to be removed)",
"group": "regions"
},
"adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt": {
"off": true,
"title": "ABP Japanese filters (の日本用フィルタ)"
"title": "JPN: ABP Japanese filters (の日本用フィルタ)",
"group": "regions"
},
"margevicius.lt/AdBlockPlusLithuania.txt": {
"off": true,
"title": "Adblock Plus Lithuania"
"title": "LTU: Adblock Plus Lithuania",
"group": "regions"
},
"stanev.org/abp/adblock_bg.txt": {
"off": true,
"title": "Bulgarian Adblock list"
"title": "BGR: Bulgarian Adblock list",
"group": "regions"
},
"indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt": {
"off": true,
"title": "ABPindo"
"title": "IDN: ABPindo",
"group": "regions"
},
"liste-ar-adblock.googlecode.com/hg/Liste_AR.txt": {
"off": true,
"title": "Liste AR"
"title": "ara: Liste AR",
"group": "regions"
},
"raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt": {
"off": true,
"title": "EasyList Czech and Slovak"
"title": "CZE, SVK: EasyList Czech and Slovak",
"group": "regions"
},
"raw.githubusercontent.com/adblockpolska/Adblock_PL_List/master/adblock_polska.txt": {
"off": true,
"title": "Adblock Polska"
"title": "POL: Adblock Polska",
"group": "regions"
},
"raw.githubusercontent.com/AdBlockPlusIsrael/EasyListHebrew/master/EasyListHebrew.txt": {
"off": true,
"title": "EasyList Hebrew"
"title": "ISR: EasyList Hebrew",
"group": "regions"
},
"download.wiltteri.net/wiltteri.txt": {
"off": true,
"title": "Wiltteri"
"title": "FIN: Wiltteri",
"group": "regions"
},
"home.fredfiber.no/langsholt/adblock.txt": {
"off": true,
"title": "Norsk adblockliste (norsk)"
"title": "NOR: Norsk adblockliste",
"group": "regions"
},
"www.fanboy.co.nz/fanboy-swedish.txt": {
"off": true,
"title": "Fanboy's Swedish"
"title": "SWE: Fanboy's Swedish",
"group": "regions"
},
"adblock.gardar.net/is.abp.txt": {
"off": true,
"title": "Icelandic ABP List (islenska)"
"title": "ISL: Icelandic ABP List",
"group": "regions"
},
"adblock.schack.dk/block.txt": {
"off": true,
"title": "Schacks Adblock Plus liste (dansk)"
"title": "DNK: Schacks Adblock Plus liste",
"group": "regions"
},
"www.void.gr/kargig/void-gr-filters.txt": {
"off": true,
"title": "Greek AdBlock Filter"
"title": "GRC: Greek AdBlock Filter",
"group": "regions"
},
"abp.mozilla-hispano.org/nauscopio/filtros.txt": {
"off": true,
"title": "Filtros Nauscopicos"
"title": "ESP: Filtros Nauscopicos",
"group": "regions"
},
"www.hufilter.hu/hufilter.txt": {
"off": true,
"title": "hufilter (magyar)"
"title": "HUN: hufilter (magyar)",
"group": "regions"
},
"dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt": {
"off": true,
"title": "ABP X Files"
"title": "ITA: ABP X Files",
"group": "regions"
}
}

View File

@ -20,6 +20,7 @@ THIRDPARTY_REMOTEURLS=(
'https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt'
'https://easylist-downloads.adblockplus.org/easyprivacy.txt'
'https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt'
'https://easylist-downloads.adblockplus.org/fanboy-social.txt'
'https://www.fanboy.co.nz/enhancedstats.txt'
'https://www.fanboy.co.nz/fanboy-antifacebook.txt'
'https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt'
@ -65,6 +66,7 @@ THIRDPARTY_LOCALURLS=(
'thirdparties/easylist-downloads.adblockplus.org/easylist_noelemhide.txt'
'thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt'
'thirdparties/easylist-downloads.adblockplus.org/fanboy-annoyance.txt'
'thirdparties/easylist-downloads.adblockplus.org/fanboy-social.txt'
'thirdparties/www.fanboy.co.nz/enhancedstats.txt'
'thirdparties/www.fanboy.co.nz/fanboy-antifacebook.txt'
'thirdparties/raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt'

View File

@ -57,16 +57,7 @@ var getµb = function() {
/******************************************************************************/
var renderNumber = function(value) {
// TODO: localization
if ( +value > 1000 ) {
value = value.toString();
var i = value.length - 3;
while ( i > 0 ) {
value = value.slice(0, i) + ',' + value.slice(i);
i -= 3;
}
}
return value;
return value.toLocaleString();
};
/******************************************************************************/
@ -75,17 +66,18 @@ var renderNumber = function(value) {
var renderBlacklists = function() {
// empty list first
uDom('#blacklists .blacklistDetails').remove();
uDom('#lists .listDetails').remove();
var µb = getµb();
uDom('#listsOfBlockedHostsPrompt').text(
chrome.i18n.getMessage('3pListsOfBlockedHostsPrompt')
.replace('{{ubiquitousBlacklistCount}}', renderNumber(µb.abpFilters.getFilterCount()))
.replace('{{netFilterCount}}', renderNumber(µb.abpFilters.getFilterCount()))
.replace('{{cosmeticFilterCount}}', renderNumber(µb.abpHideFilters.getFilterCount()))
);
// Assemble a pretty blacklist name if possible
var prettifyListName = function(blacklistTitle, blacklistHref) {
var htmlFromListName = function(blacklistTitle, blacklistHref) {
if ( blacklistHref === µb.userFiltersPath ) {
return userListName;
}
@ -116,29 +108,88 @@ var renderBlacklists = function() {
};
var listStatsTemplate = chrome.i18n.getMessage('3pListsOfBlockedHostsPerListStats');
var blacklists = µb.remoteBlacklists;
var ul = uDom('#blacklists');
var keys = Object.keys(blacklists);
var i = keys.length;
var blacklist, blacklistHref;
var liTemplate = uDom('#blacklistTemplate .blacklistDetails').first();
var li, text;
while ( i-- ) {
blacklistHref = keys[i];
blacklist = blacklists[blacklistHref];
li = liTemplate.clone();
li.find('input').prop('checked', !blacklist.off);
li.find('a')
.attr('href', encodeURI(blacklistHref))
.html(prettifyListName(blacklist.title, blacklistHref));
text = listStatsTemplate
.replace('{{used}}', !blacklist.off && !isNaN(+blacklist.entryUsedCount) ? renderNumber(blacklist.entryUsedCount) : '0')
.replace('{{total}}', !isNaN(+blacklist.entryCount) ? renderNumber(blacklist.entryCount) : '?')
;
li.find('span').text(text);
ul.prepend(li);
var htmlFromBranch = function(groupKey, listKeys, lists) {
listKeys.sort(function(a, b) {
return lists[a].title.localeCompare(lists[b].title);
});
var html = [
'<li>',
chrome.i18n.getMessage('3pGroup' + groupKey.charAt(0).toUpperCase() + groupKey.slice(1)),
'<ul>'
];
var listEntryTemplate = [
'<li class="listDetails">',
'<input type="checkbox" {{checked}}>',
'&thinsp;',
'<a href="{{URL}}" type="text/plain">',
'{{name}}',
'</a>',
': ',
'<span class="dim">',
listStatsTemplate,
'</span>'
].join('');
var listKey, list, listEntry;
for ( var i = 0; i < listKeys.length; i++ ) {
listKey = listKeys[i];
list = lists[listKey];
listEntry = listEntryTemplate
.replace('{{checked}}', list.off ? '' : 'checked')
.replace('{{URL}}', encodeURI(listKey))
.replace('{{name}}', htmlFromListName(list.title, listKey))
.replace('{{used}}', !list.off && !isNaN(+list.entryUsedCount) ? renderNumber(list.entryUsedCount) : '0')
.replace('{{total}}', !isNaN(+list.entryCount) ? renderNumber(list.entryCount) : '?')
html.push(listEntry);
}
html.push('</ul>');
return html.join('');
};
var groupsFromLists = function(lists) {
var groups = {};
var listKeys = Object.keys(lists);
var i = listKeys.length;
var listKey, list, groupKey;
while ( i-- ) {
listKey = listKeys[i];
list = lists[listKey];
groupKey = list.group || 'nogroup';
if ( groups[groupKey] === undefined ) {
groups[groupKey] = [];
}
groups[groupKey].push(listKey);
}
return groups;
};
var html = [];
var groups = groupsFromLists(µb.remoteBlacklists);
var groupKey;
var groupKeys = [
'default',
'ads',
'privacy',
'malware',
'social',
'multipurpose',
'regions'
];
for ( var i = 0; i < groupKeys.length; i++ ) {
groupKey = groupKeys[i];
html.push(htmlFromBranch(groupKey, groups[groupKey], µb.remoteBlacklists));
delete groups[groupKey];
}
uDom('#parseAllABPHideFilters').attr('checked', µb.userSettings.parseAllABPHideFilters === true);
// For all groups not covered above (if any left)
groupKeys = Object.keys(groups);
for ( var i = 0; i < groupKeys.length; i++ ) {
groupKey = groupKeys[i];
html.push(htmlFromBranch(groupKey, groups[groupKey], µb.remoteBlacklists));
delete groups[groupKey];
}
uDom('#lists').html(html.join(''));
uDom('#parseAllABPHideFilters').prop('checked', µb.userSettings.parseAllABPHideFilters === true);
uDom('#ubiquitousParseAllABPHideFiltersPrompt2').text(
chrome.i18n.getMessage("listsParseAllABPHideFiltersPrompt2")
.replace('{{abpHideFilterCount}}', renderNumber(µb.abpHideFilters.getFilterCount()))
@ -154,7 +205,7 @@ var renderBlacklists = function() {
var getSelectedBlacklistsHash = function() {
var hash = '';
var inputs = uDom('#blacklists .blacklistDetails > input');
var inputs = uDom('#lists .listDetails > input');
var i = inputs.length();
while ( i-- ) {
hash += inputs.subset(i).prop('checked').toString();
@ -195,7 +246,7 @@ var blacklistsApplyHandler = function() {
}
// Reload blacklists
var switches = [];
var lis = uDom('#blacklists .blacklistDetails');
var lis = uDom('#lists .listDetails');
var i = lis.length();
var path;
while ( i-- ) {
@ -209,7 +260,7 @@ var blacklistsApplyHandler = function() {
what: 'reloadAllFilters',
switches: switches
});
uDom('#blacklistsApply').attr('disabled', true );
uDom('#blacklistsApply').prop('disabled', true );
};
/******************************************************************************/
@ -227,8 +278,8 @@ var abpHideFiltersCheckboxChanged = function() {
uDom.onLoad(function() {
// Handle user interaction
uDom('#blacklists').on('change', '.blacklistDetails', selectedBlacklistsChanged);
uDom('#blacklists').on('click', '.blacklistDetails > a:first-child', onListLinkClicked);
uDom('#lists').on('change', '.listDetails', selectedBlacklistsChanged);
uDom('#lists').on('click', '.listDetails > a:first-child', onListLinkClicked);
uDom('#blacklistsApply').on('click', blacklistsApplyHandler);
uDom('#parseAllABPHideFilters').on('change', abpHideFiltersCheckboxChanged);

View File

@ -263,18 +263,7 @@ FilterParser.prototype.extractPlain = function() {
var FilterContainer = function() {
this.filterParser = new FilterParser();
this.acceptedCount = 0;
this.processedCount = 0;
this.genericFilters = {};
this.hostnameFilters = {};
this.entityFilters = {};
this.hideUnfiltered = [];
this.hideLowGenerics = {};
this.hideHighGenerics = [];
this.donthideUnfiltered = [];
this.donthideLowGenerics = {};
this.donthideHighGenerics = [];
this.rejected = [];
this.reset();
};
/******************************************************************************/
@ -295,11 +284,14 @@ FilterContainer.prototype.reset = function() {
this.donthideLowGenerics = {};
this.donthideHighGenerics = [];
this.rejected = [];
this.duplicates = {};
this.duplicateCount = 0;
};
/******************************************************************************/
FilterContainer.prototype.add = function(s) {
s = s.trim();
var parsed = this.filterParser.parse(s);
if ( parsed.invalid ) {
return false;
@ -307,6 +299,12 @@ FilterContainer.prototype.add = function(s) {
this.processedCount += 1;
if ( this.duplicates[s] ) {
this.duplicateCount++;
return false;
}
this.duplicates[s] = true;
//if ( s === 'mail.google.com##.nH.adC > .nH > .nH > .u5 > .azN' ) {
// debugger;
//}
@ -399,6 +397,9 @@ FilterContainer.prototype.freeze = function() {
this.filterParser.reset();
console.debug('Number of duplicate cosmetic filters skipped:', this.duplicateCount);
this.duplicates = {};
//console.log('µBlock> adp-hide-filters.js: %d filters accepted', this.acceptedCount);
//console.log('µBlock> adp-hide-filters.js: %d filters processed', this.processedCount);
//console.log('µBlock> adp-hide-filters.js: coverage is %s%', (this.acceptedCount * 100 / this.processedCount).toFixed(1));

View File

@ -50,11 +50,14 @@ return {
// list of remote blacklist locations
remoteBlacklists: {
// User
'assets/user/filters.txt': {},
'assets/user/filters.txt': {
group: 'default'
},
// uBlock
'assets/ublock/filters.txt': {
title: "µBlock filters"
title: 'µBlock filters',
group: 'default'
},
// 3rd-party lists fetched dynamically