This commit is contained in:
gorhill 2015-01-16 12:15:12 -05:00
parent 6e27db557f
commit 554129648d
4 changed files with 32 additions and 20 deletions

View File

@ -49,6 +49,9 @@ body[dir="rtl"] #content {
#content table tr.allowed { #content table tr.allowed {
background-color: rgba(0, 160, 0, 0.1) 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 { #content table tr.maindoc {
background-color: #eee; background-color: #eee;
} }

View File

@ -98,6 +98,9 @@ var renderLogEntry = function(entry) {
tr.classList.add('blocked'); tr.classList.add('blocked');
} else if ( entry.result.charAt(1) === 'a' ) { } else if ( entry.result.charAt(1) === 'a' ) {
tr.classList.add('allowed'); tr.classList.add('allowed');
if ( entry.result.charAt(0) === 'm' ) {
tr.classList.add('mirrored');
}
} }
if ( entry.type === 'main_frame' ) { if ( entry.type === 'main_frame' ) {
tr.classList.add('maindoc'); tr.classList.add('maindoc');

View File

@ -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() { PageStore.prototype.updateBadge = function() {
var netFiltering = this.getNetFilteringSwitch(); var netFiltering = this.getNetFilteringSwitch();
var badge = ''; var badge = '';

View File

@ -104,11 +104,10 @@ var onBeforeRequest = function(details) {
var result = pageStore.filterRequest(requestContext); var result = pageStore.filterRequest(requestContext);
// Log result // Possible outcomes: blocked, allowed-passthru, allowed-mirror
pageStore.logBuffer.writeOne(requestContext, result);
// Not blocked // Not blocked
if ( pageStore.boolFromResult(result) === false ) { if ( µb.isAllowResult(result) ) {
//console.debug('onBeforeRequest()> ALLOW "%s" (%o) because "%s"', details.url, details, result); //console.debug('onBeforeRequest()> ALLOW "%s" (%o) because "%s"', details.url, details, result);
pageStore.perLoadAllowedRequestCount++; pageStore.perLoadAllowedRequestCount++;
@ -119,34 +118,26 @@ var onBeforeRequest = function(details) {
pageStore.addFrame(frameId, requestURL); 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 // https://code.google.com/p/chromium/issues/detail?id=387198
// Not all redirects will succeed, until bug above is fixed. // Not all redirects will succeed, until bug above is fixed.
var redirectURL = µb.mirrors.toURL(requestURL, true); var redirectURL = pageStore.toMirrorURL(requestURL);
if ( redirectURL !== '' ) { if ( redirectURL !== '' ) {
pageStore.logBuffer.writeOne(requestContext, 'ma:');
//console.debug('"%s" redirected to "%s..."', requestURL.slice(0, 50), redirectURL.slice(0, 50)); //console.debug('"%s" redirected to "%s..."', requestURL.slice(0, 50), redirectURL.slice(0, 50));
return { redirectUrl: redirectURL }; return { redirectUrl: redirectURL };
} }
pageStore.logBuffer.writeOne(requestContext, result);
return; return;
} }
// Blocked // Blocked
//console.debug('onBeforeRequest()> BLOCK "%s" (%o) because "%s"', details.url, details, result); //console.debug('onBeforeRequest()> BLOCK "%s" (%o) because "%s"', details.url, details, result);
pageStore.logBuffer.writeOne(requestContext, result);
pageStore.perLoadBlockedRequestCount++; pageStore.perLoadBlockedRequestCount++;
µb.localSettings.blockedRequestCount++; µb.localSettings.blockedRequestCount++;
µb.updateBadgeAsync(tabId); µb.updateBadgeAsync(tabId);
@ -222,8 +213,7 @@ var onBeforeSendHeaders = function(details) {
var referrerHostname = µburi.hostnameFromURI(referrer); var referrerHostname = µburi.hostnameFromURI(referrer);
var pageDetails = { var pageDetails = {
pageHostname: referrerHostname, pageHostname: referrerHostname,
pageDomain: µburi.domainFromHostname(referrerHostname), pageDomain: µburi.domainFromHostname(referrerHostname)
firstParty: false
}; };
pageDetails.rootHostname = pageDetails.pageHostname; pageDetails.rootHostname = pageDetails.pageHostname;
pageDetails.rootDomain = pageDetails.pageDomain; pageDetails.rootDomain = pageDetails.pageDomain;