mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 09:09:38 +02:00
code review
This commit is contained in:
parent
ace190a33e
commit
2bed24bb99
@ -172,7 +172,7 @@
|
|||||||
"description":""
|
"description":""
|
||||||
},
|
},
|
||||||
"popupHitDomainCountPrompt":{
|
"popupHitDomainCountPrompt":{
|
||||||
"message":"Connected to {{count}} distinct domain(s)",
|
"message":"Connected to {{count}} distinct domain(s) out of {{total}}",
|
||||||
"description":"appear in dynamic filtering pane"
|
"description":"appear in dynamic filtering pane"
|
||||||
},
|
},
|
||||||
"pickerCreate":{
|
"pickerCreate":{
|
||||||
|
@ -147,7 +147,7 @@ body.advancedUser #panes.dfEnabled #dfToggler::before {
|
|||||||
}
|
}
|
||||||
#dynamicFilteringContainer > div#privacyInfo {
|
#dynamicFilteringContainer > div#privacyInfo {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: gray;
|
color: #444;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ var dfTypes = [
|
|||||||
var popupHeight;
|
var popupHeight;
|
||||||
var reIP = /^\d+(?:\.\d+){1,3}$/;
|
var reIP = /^\d+(?:\.\d+){1,3}$/;
|
||||||
var reSrcHostnameFromResult = /^d[abn]:([^ ]+) ([^ ]+)/;
|
var reSrcHostnameFromResult = /^d[abn]:([^ ]+) ([^ ]+)/;
|
||||||
var touchedDomains = {};
|
|
||||||
var scopeToSrcHostnameMap = {
|
var scopeToSrcHostnameMap = {
|
||||||
'/': '*',
|
'/': '*',
|
||||||
'.': ''
|
'.': ''
|
||||||
@ -51,6 +50,9 @@ var threeMinus = '−−−';
|
|||||||
var sixSpace = '\u2007\u2007\u2007\u2007\u2007\u2007';
|
var sixSpace = '\u2007\u2007\u2007\u2007\u2007\u2007';
|
||||||
var dfHotspots = null;
|
var dfHotspots = null;
|
||||||
var hostnameToSortableTokenMap = {};
|
var hostnameToSortableTokenMap = {};
|
||||||
|
var allDomains = {};
|
||||||
|
var allDomainCount = 0;
|
||||||
|
var touchedDomainCount = 0;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -64,25 +66,27 @@ var cachePopupData = function(data) {
|
|||||||
popupData = {};
|
popupData = {};
|
||||||
scopeToSrcHostnameMap['.'] = '';
|
scopeToSrcHostnameMap['.'] = '';
|
||||||
hostnameToSortableTokenMap = {};
|
hostnameToSortableTokenMap = {};
|
||||||
|
|
||||||
if ( typeof data !== 'object' ) {
|
if ( typeof data !== 'object' ) {
|
||||||
return popupData;
|
return popupData;
|
||||||
}
|
}
|
||||||
popupData = data;
|
popupData = data;
|
||||||
scopeToSrcHostnameMap['.'] = popupData.pageHostname || '';
|
scopeToSrcHostnameMap['.'] = popupData.pageHostname || '';
|
||||||
var hostnameDict = popupData.hostnameDict;
|
var hostnameDict = popupData.hostnameDict;
|
||||||
if ( typeof hostnameDict === 'object' ) {
|
if ( typeof hostnameDict !== 'object' ) {
|
||||||
var domain, prefix;
|
return popupData;
|
||||||
for ( var hostname in hostnameDict ) {
|
}
|
||||||
if ( hostnameDict.hasOwnProperty(hostname) === false ) {
|
var domain, prefix;
|
||||||
continue;
|
for ( var hostname in hostnameDict ) {
|
||||||
}
|
if ( hostnameDict.hasOwnProperty(hostname) === false ) {
|
||||||
domain = hostnameDict[hostname].domain;
|
continue;
|
||||||
if ( domain === popupData.pageDomain ) {
|
|
||||||
domain = '\u0020';
|
|
||||||
}
|
|
||||||
prefix = hostname.slice(0, 0 - domain.length);
|
|
||||||
hostnameToSortableTokenMap[hostname] = domain + prefix.split('.').reverse().join('.');
|
|
||||||
}
|
}
|
||||||
|
domain = hostnameDict[hostname].domain;
|
||||||
|
if ( domain === popupData.pageDomain ) {
|
||||||
|
domain = '\u0020';
|
||||||
|
}
|
||||||
|
prefix = hostname.slice(0, 0 - domain.length);
|
||||||
|
hostnameToSortableTokenMap[hostname] = domain + prefix.split('.').reverse().join('.');
|
||||||
}
|
}
|
||||||
return popupData;
|
return popupData;
|
||||||
};
|
};
|
||||||
@ -122,8 +126,15 @@ var addDynamicFilterRow = function(des) {
|
|||||||
var hnDetails = popupData.hostnameDict[des] || {};
|
var hnDetails = popupData.hostnameDict[des] || {};
|
||||||
var isDomain = des === hnDetails.domain;
|
var isDomain = des === hnDetails.domain;
|
||||||
row.toggleClass('isDomain', isDomain);
|
row.toggleClass('isDomain', isDomain);
|
||||||
|
if ( allDomains.hasOwnProperty(hnDetails.domain) === false ) {
|
||||||
|
allDomains[hnDetails.domain] = false;
|
||||||
|
allDomainCount += 1;
|
||||||
|
}
|
||||||
if ( hnDetails.allowCount !== 0 ) {
|
if ( hnDetails.allowCount !== 0 ) {
|
||||||
touchedDomains[hnDetails.domain] = true;
|
if ( allDomains[hnDetails.domain] === false ) {
|
||||||
|
allDomains[hnDetails.domain] = true;
|
||||||
|
touchedDomainCount += 1;
|
||||||
|
}
|
||||||
row.addClass('allowed');
|
row.addClass('allowed');
|
||||||
}
|
}
|
||||||
if ( hnDetails.blockCount !== 0 ) {
|
if ( hnDetails.blockCount !== 0 ) {
|
||||||
@ -223,7 +234,10 @@ var syncAllDynamicFilters = function() {
|
|||||||
syncDynamicFilterCell(key.charAt(0), key.slice(2, key.indexOf(' ', 2)), '*', rules[key]);
|
syncDynamicFilterCell(key.charAt(0), key.slice(2, key.indexOf(' ', 2)), '*', rules[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uDom('#privacyInfo').text(vAPI.i18n('popupHitDomainCountPrompt').replace('{{count}}', Object.keys(touchedDomains).length));
|
var summary = vAPI.i18n('popupHitDomainCountPrompt')
|
||||||
|
.replace('{{count}}', touchedDomainCount)
|
||||||
|
.replace('{{total}}', allDomainCount);
|
||||||
|
uDom('#privacyInfo').text(summary);
|
||||||
|
|
||||||
if ( dfPaneBuilt !== true ) {
|
if ( dfPaneBuilt !== true ) {
|
||||||
uDom('#dynamicFilteringContainer')
|
uDom('#dynamicFilteringContainer')
|
||||||
|
Loading…
Reference in New Issue
Block a user