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 µburi = µb.URI;
var isBlockResult = µb.isBlockResult;
// Create evaluation context
details.pageHostname = vAPI.punycodeHostname(details.pageHostname);
@ -385,7 +386,7 @@ var filterRequests = function(pageStore, details) {
var inRequests = details.requests;
var outRequests = [];
var request, result;
var request;
var i = inRequests.length;
while ( i-- ) {
request = inRequests[i];
@ -395,8 +396,7 @@ var filterRequests = function(pageStore, details) {
details.requestURL = vAPI.punycodeURL(request.url);
details.requestHostname = µburi.hostnameFromURI(details.requestURL);
details.requestType = tagNameToRequestTypeMap[request.tagName];
result = pageStore.filterRequest(details);
if ( pageStore.boolFromResult(result) ) {
if ( isBlockResult(pageStore.filterRequest(details)) ) {
outRequests.push(request);
}
}
@ -422,8 +422,7 @@ var filterRequest = function(pageStore, details) {
details.requestURL = vAPI.punycodeURL(details.requestURL);
details.requestHostname = µburi.hostnameFromURI(details.requestURL);
details.requestType = tagNameToRequestTypeMap[details.tagName];
var result = pageStore.filterRequest(details);
if ( pageStore.boolFromResult(result) ) {
if ( µb.isBlockResult(pageStore.filterRequest(details)) ) {
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) {
// https://github.com/gorhill/uBlock/issues/351
// Bypass experimental features when uBlock is disabled for a site

View File

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