diff --git a/src/css/devtool-log.css b/src/css/devtool-log.css index 1d7fb3440..3011fbd19 100644 --- a/src/css/devtool-log.css +++ b/src/css/devtool-log.css @@ -49,6 +49,9 @@ body[dir="rtl"] #content { #content table tr.allowed { background-color: rgba(0, 160, 0, 0.1) } +#content table tr.allowed.mirrored { + background-color: rgba(255, 255, 0, 0.3) + } #content table tr.maindoc { background-color: #eee; } diff --git a/src/js/devtool-log.js b/src/js/devtool-log.js index bc23e9a96..5646b8ab1 100644 --- a/src/js/devtool-log.js +++ b/src/js/devtool-log.js @@ -98,6 +98,9 @@ var renderLogEntry = function(entry) { tr.classList.add('blocked'); } else if ( entry.result.charAt(1) === 'a' ) { tr.classList.add('allowed'); + if ( entry.result.charAt(0) === 'm' ) { + tr.classList.add('mirrored'); + } } if ( entry.type === 'main_frame' ) { tr.classList.add('maindoc'); diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 94e5ce83c..3b7ab5f00 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -684,6 +684,22 @@ PageStore.prototype.boolFromResult = function(result) { /******************************************************************************/ +PageStore.prototype.toMirrorURL = function(requestURL) { + // https://github.com/gorhill/uBlock/issues/351 + // Bypass experimental features when uBlock is disabled for a site + if ( µb.userSettings.experimentalEnabled === false || + this.getNetFilteringSwitch() === false || + this.skipLocalMirroring ) { + return ''; + } + + // https://code.google.com/p/chromium/issues/detail?id=387198 + // Not all redirects will succeed, until bug above is fixed. + return µb.mirrors.toURL(requestURL, true); +}; + +/******************************************************************************/ + PageStore.prototype.updateBadge = function() { var netFiltering = this.getNetFilteringSwitch(); var badge = ''; diff --git a/src/js/traffic.js b/src/js/traffic.js index 7981ca55d..0d16dd9b5 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -104,11 +104,10 @@ var onBeforeRequest = function(details) { var result = pageStore.filterRequest(requestContext); - // Log result - pageStore.logBuffer.writeOne(requestContext, result); + // Possible outcomes: blocked, allowed-passthru, allowed-mirror // Not blocked - if ( pageStore.boolFromResult(result) === false ) { + if ( µb.isAllowResult(result) ) { //console.debug('onBeforeRequest()> ALLOW "%s" (%o) because "%s"', details.url, details, result); pageStore.perLoadAllowedRequestCount++; @@ -119,34 +118,26 @@ var onBeforeRequest = function(details) { pageStore.addFrame(frameId, requestURL); } - // https://github.com/gorhill/uBlock/issues/351 - // Bypass experimental features when uBlock is disabled for a site - if ( !pageStore.getNetFilteringSwitch() ) { - return; - } - - if ( !µb.userSettings.experimentalEnabled ) { - return; - } - - if ( pageStore.skipLocalMirroring ) { - return; - } - // https://code.google.com/p/chromium/issues/detail?id=387198 // Not all redirects will succeed, until bug above is fixed. - var redirectURL = µb.mirrors.toURL(requestURL, true); + var redirectURL = pageStore.toMirrorURL(requestURL); if ( redirectURL !== '' ) { + pageStore.logBuffer.writeOne(requestContext, 'ma:'); + //console.debug('"%s" redirected to "%s..."', requestURL.slice(0, 50), redirectURL.slice(0, 50)); return { redirectUrl: redirectURL }; } + pageStore.logBuffer.writeOne(requestContext, result); + return; } // Blocked //console.debug('onBeforeRequest()> BLOCK "%s" (%o) because "%s"', details.url, details, result); + pageStore.logBuffer.writeOne(requestContext, result); + pageStore.perLoadBlockedRequestCount++; µb.localSettings.blockedRequestCount++; µb.updateBadgeAsync(tabId); @@ -222,8 +213,7 @@ var onBeforeSendHeaders = function(details) { var referrerHostname = µburi.hostnameFromURI(referrer); var pageDetails = { pageHostname: referrerHostname, - pageDomain: µburi.domainFromHostname(referrerHostname), - firstParty: false + pageDomain: µburi.domainFromHostname(referrerHostname) }; pageDetails.rootHostname = pageDetails.pageHostname; pageDetails.rootDomain = pageDetails.pageDomain;