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 {
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;
}

View File

@ -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');

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

View File

@ -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;