From 6f155d55f8bb0f61a858ceee25745c6f6b0e1d3e Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 25 Mar 2015 10:12:56 -0400 Subject: [PATCH] this fixes #1040, #870 --- src/css/popup.css | 31 ++++++++++++++++++++++++------- src/js/messaging.js | 1 + src/js/popup.js | 29 +++++++++++++---------------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/css/popup.css b/src/css/popup.css index 625085d95..eeff8e3de 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -4,9 +4,9 @@ body { float: left; font: 13px sans-serif; margin: 0; + overflow: hidden; padding: 0; white-space: nowrap; - overflow: hidden; } h2 { background-color: #eee; @@ -210,6 +210,7 @@ body.dirty #refresh:hover { #firewallContainer > div > span:nth-of-type(1) { border-right: 1px solid white; padding-right: 2px; + position: relative; text-overflow: ellipsis; width: 70%; } @@ -245,14 +246,30 @@ body.dirty #refresh:hover { #firewallContainer.minimized > div.isDomain > span:nth-of-type(4) { display: inline-block; } -#firewallContainer > div.allowed > span:nth-of-type(1) { - background-color: rgba(0, 160, 0, 0.1); +#firewallContainer > div.allowed > span:nth-of-type(1):before, +#firewallContainer > div.blocked > span:nth-of-type(1):before, +#firewallContainer.minimized > div.isDomain.totalAllowed > span:nth-of-type(1):before, +#firewallContainer.minimized > div.isDomain.totalBlocked > span:nth-of-type(1):before { + box-sizing: border-box; + content: ''; + display: inline-block; + height: 100%; + left: 0; + opacity: 0.4; + position: absolute; + width: 7px; } -#firewallContainer > div.blocked > span:nth-of-type(1) { - background-color: rgba(192, 0, 0, 0.1); +#firewallContainer > div.allowed > span:nth-of-type(1):before, +#firewallContainer.minimized > div.isDomain.totalAllowed > span:nth-of-type(1):before { + background-color: rgb(0, 160, 0); } -#firewallContainer > div.allowed.blocked > span:nth-of-type(1) { - background-color: rgba(192, 160, 0, 0.1); +#firewallContainer > div.blocked > span:nth-of-type(1):before, +#firewallContainer.minimized > div.isDomain.totalBlocked > span:nth-of-type(1):before { + background-color: rgb(192, 0, 0); + } +#firewallContainer > div.allowed.blocked > span:nth-of-type(1):before, +#firewallContainer.minimized > div.isDomain.totalAllowed.totalBlocked > span:nth-of-type(1):before { + background-color: rgb(192, 160, 0); } #firewallContainer > div > span.aRule { background-color: rgba(0, 160, 0, 0.3); diff --git a/src/js/messaging.js b/src/js/messaging.js index 7637d546d..4bbece661 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -217,6 +217,7 @@ var getStats = function(tabId, tabTitle) { }; var pageStore = µb.pageStoreFromTabId(tabId); if ( pageStore ) { + r.rawURL = pageStore.rawURL; r.pageURL = pageStore.pageURL; r.pageDomain = pageStore.pageDomain; r.pageHostname = pageStore.pageHostname; diff --git a/src/js/popup.js b/src/js/popup.js index 87409dff2..5dc7aa042 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -83,6 +83,7 @@ var rowsToRecycle = uDom(); var cachedPopupHash = ''; var statsStr = vAPI.i18n('popupBlockedStats'); var domainsHitStr = vAPI.i18n('popupHitDomainCount'); +var reNetworkRelatedURL = /^(?:ftps?|https?|wss?):\/\//; /******************************************************************************/ @@ -183,12 +184,14 @@ var addFirewallRow = function(des) { row.descendants('span:nth-of-type(1)').text(punycode.toUnicode(des)); var hnDetails = popupData.hostnameDict[des] || {}; - var isDomain = des === hnDetails.domain; - row.toggleClass('isDomain', isDomain); - row.toggleClass('isSubDomain', !isDomain); - row.toggleClass('allowed', hnDetails.allowCount !== 0); - row.toggleClass('blocked', hnDetails.blockCount !== 0); + row.toggleClass('isDomain', isDomain) + .toggleClass('isSubDomain', !isDomain) + .toggleClass('allowed', hnDetails.allowCount !== 0) + .toggleClass('blocked', hnDetails.blockCount !== 0) + .toggleClass('totalAllowed', hnDetails.totalAllowCount !== 0) + .toggleClass('totalBlocked', hnDetails.totalBlockCount !== 0); + row.appendTo('#firewallContainer'); return row; @@ -362,22 +365,16 @@ var renderPrivacyExposure = function() { desHostnameDone[des] = true; } - // Domain of the page must always be included - if ( allDomains.hasOwnProperty(popupData.pageDomain) === false ) { + // Domain of the page must always be included (if there is one) + if ( + allDomains.hasOwnProperty(popupData.pageDomain) === false && + reNetworkRelatedURL.test(popupData.rawURL) + ) { allHostnameRows.push(popupData.pageDomain); allDomains[popupData.pageDomain] = false; allDomainCount += 1; } - // The root page domain must always be counted as connected: that's from - // where the root document was fetched. - // https://github.com/gorhill/uBlock/issues/759 - // The root page domain must be counted if and only if it was actually - // obtained through a network request. - //if ( allDomainCount !== 0 && allDomains[popupData.pageDomain] === false ) { - // touchedDomainCount += 1; - //} - var summary = domainsHitStr.replace('{{count}}', touchedDomainCount.toLocaleString()) .replace('{{total}}', allDomainCount.toLocaleString()); uDom('#popupHitDomainCount').text(summary);