1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 11:22:38 +01:00

code review

This commit is contained in:
gorhill 2015-03-16 07:46:11 -04:00
parent bb1e131ae7
commit 88b517e6fa
2 changed files with 17 additions and 7 deletions

View File

@ -354,15 +354,22 @@ var renderPrivacyExposure = function() {
desHostnameDone[des] = true; desHostnameDone[des] = true;
} }
// Domain of the page must always be included
if ( allDomains.hasOwnProperty(popupData.pageDomain) === false ) {
console.log(popupData.pageDomain);
allHostnameRows.push(popupData.pageDomain);
allDomains[popupData.pageDomain] = false;
allDomainCount += 1;
}
// The root page domain must always be counted as connected: that's from // The root page domain must always be counted as connected: that's from
// where the root document was fetched. // where the root document was fetched.
// https://github.com/gorhill/uBlock/issues/759 // https://github.com/gorhill/uBlock/issues/759
// The root page domain must be counted if and only if it was actually // The root page domain must be counted if and only if it was actually
// obtained through a network request. // obtained through a network request.
if ( allDomainCount !== 0 && allDomains[popupData.pageDomain] !== true ) { //if ( allDomainCount !== 0 && allDomains[popupData.pageDomain] === false ) {
allDomains[popupData.pageDomain] = true; // touchedDomainCount += 1;
touchedDomainCount += 1; //}
}
var summary = domainsHitStr.replace('{{count}}', touchedDomainCount.toLocaleString()) var summary = domainsHitStr.replace('{{count}}', touchedDomainCount.toLocaleString())
.replace('{{total}}', allDomainCount.toLocaleString()); .replace('{{total}}', allDomainCount.toLocaleString());

View File

@ -78,21 +78,24 @@ var onBeforeRequest = function(details) {
// Lookup the page store associated with this tab id. // Lookup the page store associated with this tab id.
pageStore = µb.pageStoreFromTabId(tabId); pageStore = µb.pageStoreFromTabId(tabId);
if ( !pageStore ) { if ( !pageStore ) {
if ( mostRecentRootDocURL === '' ) {
return;
}
// https://github.com/gorhill/uBlock/issues/1025 // https://github.com/gorhill/uBlock/issues/1025
// Google Hangout popup opens without a root frame. So for now we will // Google Hangout popup opens without a root frame. So for now we will
// just discard that best-guess root frame if it is too far in the // just discard that best-guess root frame if it is too far in the
// future, at which point it ceases to be a "best guess". // future, at which point it ceases to be a "best guess".
if ( (Date.now() - mostRecentRootDocURLTimestamp) >= 500 ) { if ( (Date.now() - mostRecentRootDocURLTimestamp) >= 500 ) {
mostRecentRootDocURL = ''; mostRecentRootDocURL = '';
return;
} }
// https://github.com/gorhill/uBlock/issues/1001 // https://github.com/gorhill/uBlock/issues/1001
// Not a behind-the-scene request, yet no page store found for the // Not a behind-the-scene request, yet no page store found for the
// tab id: we will thus bind the last-seen root document to the // tab id: we will thus bind the last-seen root document to the
// unbound tab. It's a guess, but better than ending up filtering // unbound tab. It's a guess, but better than ending up filtering
// nothing at all. // nothing at all.
if ( mostRecentRootDocURL !== '' ) { vAPI.tabs.onNavigation({ tabId: tabId, frameId: 0, url: mostRecentRootDocURL });
pageStore = µb.bindTabToPageStats(tabId, mostRecentRootDocURL, 'beforeRequest'); pageStore = µb.pageStoreFromTabId(tabId);
}
if ( !pageStore ) { if ( !pageStore ) {
return; return;
} }