code review

This commit is contained in:
gorhill 2015-01-22 13:00:59 -05:00
parent 9d1332be7d
commit b51b0e5350
3 changed files with 5 additions and 15 deletions

View File

@ -375,6 +375,7 @@ var tagNameToRequestTypeMap = {
var filterRequests = function(pageStore, details) { var filterRequests = function(pageStore, details) {
var µburi = µb.URI; var µburi = µb.URI;
var isBlockResult = µb.isBlockResult;
// Create evaluation context // Create evaluation context
details.pageHostname = vAPI.punycodeHostname(details.pageHostname); details.pageHostname = vAPI.punycodeHostname(details.pageHostname);
@ -385,7 +386,7 @@ var filterRequests = function(pageStore, details) {
var inRequests = details.requests; var inRequests = details.requests;
var outRequests = []; var outRequests = [];
var request, result; var request;
var i = inRequests.length; var i = inRequests.length;
while ( i-- ) { while ( i-- ) {
request = inRequests[i]; request = inRequests[i];
@ -395,8 +396,7 @@ var filterRequests = function(pageStore, details) {
details.requestURL = vAPI.punycodeURL(request.url); details.requestURL = vAPI.punycodeURL(request.url);
details.requestHostname = µburi.hostnameFromURI(details.requestURL); details.requestHostname = µburi.hostnameFromURI(details.requestURL);
details.requestType = tagNameToRequestTypeMap[request.tagName]; details.requestType = tagNameToRequestTypeMap[request.tagName];
result = pageStore.filterRequest(details); if ( isBlockResult(pageStore.filterRequest(details)) ) {
if ( pageStore.boolFromResult(result) ) {
outRequests.push(request); outRequests.push(request);
} }
} }
@ -422,8 +422,7 @@ var filterRequest = function(pageStore, details) {
details.requestURL = vAPI.punycodeURL(details.requestURL); details.requestURL = vAPI.punycodeURL(details.requestURL);
details.requestHostname = µburi.hostnameFromURI(details.requestURL); details.requestHostname = µburi.hostnameFromURI(details.requestURL);
details.requestType = tagNameToRequestTypeMap[details.tagName]; details.requestType = tagNameToRequestTypeMap[details.tagName];
var result = pageStore.filterRequest(details); if ( µb.isBlockResult(pageStore.filterRequest(details)) ) {
if ( pageStore.boolFromResult(result) ) {
return { collapse: µb.userSettings.collapseBlocked }; return { collapse: µb.userSettings.collapseBlocked };
} }
}; };

View File

@ -680,15 +680,6 @@ var collapsibleRequestTypes = 'image sub_frame object';
/******************************************************************************/ /******************************************************************************/
// false: not blocked
// true: blocked
PageStore.prototype.boolFromResult = function(result) {
return typeof result === 'string' && result.charAt(1) === 'b';
};
/******************************************************************************/
PageStore.prototype.toMirrorURL = function(requestURL) { PageStore.prototype.toMirrorURL = function(requestURL) {
// https://github.com/gorhill/uBlock/issues/351 // https://github.com/gorhill/uBlock/issues/351
// Bypass experimental features when uBlock is disabled for a site // Bypass experimental features when uBlock is disabled for a site

View File

@ -92,7 +92,7 @@ vAPI.tabs.onPopup = function(details) {
} }
// Not blocked // Not blocked
if ( pageStore.boolFromResult(result) === false ) { if ( µb.isAllowResult(result) ) {
return; return;
} }