Set tooltip to cname alias in popup panel

The toolip of a canonical name entry (blue)
in the popup panel will provide the alias
hostname related to the canonical hostname
in order to help with rule-making decisions.
This commit is contained in:
Raymond Hill 2020-02-06 10:18:15 -05:00
parent 651955b97c
commit 4509483c7e
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
3 changed files with 14 additions and 16 deletions

View file

@ -189,7 +189,7 @@ const µb = µBlock;
const getHostnameDict = function(hostnameToCountMap, out) {
const hnDict = Object.create(null);
const cnSet = [];
const cnMap = [];
for ( const [ hostname, hnCounts ] of hostnameToCountMap ) {
if ( hnDict[hostname] !== undefined ) { continue; }
const domain = vAPI.domainFromHostname(hostname) || hostname;
@ -206,7 +206,7 @@ const getHostnameDict = function(hostnameToCountMap, out) {
};
const cname = vAPI.net.canonicalNameFromHostname(domain);
if ( cname !== undefined ) {
cnSet.push(cname);
cnMap.push([ cname, domain ]);
}
}
const domainEntry = hnDict[domain];
@ -224,11 +224,11 @@ const getHostnameDict = function(hostnameToCountMap, out) {
};
const cname = vAPI.net.canonicalNameFromHostname(hostname);
if ( cname !== undefined ) {
cnSet.push(cname);
cnMap.push([ cname, hostname ]);
}
}
out.hostnameDict = hnDict;
out.cnameSet = cnSet;
out.cnameMap = cnMap;
};
const getFirewallRules = function(srcHostname, desHostnames) {

View file

@ -87,11 +87,7 @@ const cachePopupData = function(data) {
return popupData;
}
popupData = data;
if ( Array.isArray(popupData.cnameSet) ) {
popupData.cnameSet = new Set(popupData.cnameSet);
} else if ( popupData.cnameSet === undefined ) {
popupData.cnameSet = new Set();
}
popupData.cnameMap = new Map(popupData.cnameMap);
scopeToSrcHostnameMap['.'] = popupData.pageHostname || '';
const hostnameDict = popupData.hostnameDict;
if ( typeof hostnameDict !== 'object' ) {
@ -304,13 +300,16 @@ const buildAllFirewallRows = function() {
classList.toggle('isRootContext', des === popupData.pageHostname);
classList.toggle('isDomain', isDomain);
classList.toggle('isSubDomain', !isDomain);
classList.toggle('isCname', popupData.cnameSet.has(des));
classList.toggle('allowed', hnDetails.allowCount !== 0);
classList.toggle('blocked', hnDetails.blockCount !== 0);
classList.toggle('totalAllowed', hnDetails.totalAllowCount !== 0);
classList.toggle('totalBlocked', hnDetails.totalBlockCount !== 0);
classList.toggle('expandException', expandExceptions.has(hnDetails.domain));
if ( classList.toggle('isCname', popupData.cnameMap.has(des)) ) {
span.title = punycode.toUnicode(popupData.cnameMap.get(des));
}
row = row.nextElementSibling;
}

View file

@ -117,11 +117,7 @@ const cachePopupData = function(data) {
return popupData;
}
popupData = data;
if ( Array.isArray(popupData.cnameSet) ) {
popupData.cnameSet = new Set(popupData.cnameSet);
} else if ( popupData.cnameSet === undefined ) {
popupData.cnameSet = new Set();
}
popupData.cnameMap = new Map(popupData.cnameMap);
scopeToSrcHostnameMap['.'] = popupData.pageHostname || '';
const hostnameDict = popupData.hostnameDict;
if ( typeof hostnameDict !== 'object' ) {
@ -339,13 +335,16 @@ const buildAllFirewallRows = function() {
classList.toggle('isRootContext', des === popupData.pageHostname);
classList.toggle('isDomain', isDomain);
classList.toggle('isSubDomain', !isDomain);
classList.toggle('isCname', popupData.cnameSet.has(des));
classList.toggle('allowed', hnDetails.allowCount !== 0);
classList.toggle('blocked', hnDetails.blockCount !== 0);
classList.toggle('totalAllowed', hnDetails.totalAllowCount !== 0);
classList.toggle('totalBlocked', hnDetails.totalBlockCount !== 0);
classList.toggle('expandException', expandExceptions.has(hnDetails.domain));
if ( classList.toggle('isCname', popupData.cnameMap.has(des)) ) {
span.title = punycode.toUnicode(popupData.cnameMap.get(des));
}
row = row.nextElementSibling;
}