|
@ -20,6 +20,7 @@ |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
/* global chrome, µMatrix */ |
|
|
/* global chrome, µMatrix */ |
|
|
|
|
|
/* jshint boss: true */ |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
@ -239,6 +240,8 @@ var onBeforeRootFrameRequestHandler = function(details) { |
|
|
// https://github.com/gorhill/httpswitchboard/issues/112
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/112
|
|
|
pageStore.recordRequest('doc', requestURL, block); |
|
|
pageStore.recordRequest('doc', requestURL, block); |
|
|
|
|
|
|
|
|
|
|
|
µm.updateBadgeAsync(tabId); |
|
|
|
|
|
|
|
|
// If it's a blacklisted frame, redirect to frame.html
|
|
|
// If it's a blacklisted frame, redirect to frame.html
|
|
|
// rhill 2013-11-05: The root frame contains a link to noop.css, this
|
|
|
// rhill 2013-11-05: The root frame contains a link to noop.css, this
|
|
|
// allows to later check whether the root frame has been unblocked by the
|
|
|
// allows to later check whether the root frame has been unblocked by the
|
|
@ -313,7 +316,8 @@ var onBeforeRequestHandler = function(details) { |
|
|
// to scope on unknown scheme? Etc.
|
|
|
// to scope on unknown scheme? Etc.
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/191
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/191
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/91#issuecomment-37180275
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/91#issuecomment-37180275
|
|
|
var pageStore = µm.pageStatsFromTabId(details.tabId); |
|
|
|
|
|
|
|
|
var tabId = details.tabId; |
|
|
|
|
|
var pageStore = µm.pageStatsFromTabId(tabId); |
|
|
if ( !pageStore ) { |
|
|
if ( !pageStore ) { |
|
|
pageStore = µm.pageStatsFromTabId(µm.behindTheSceneTabId); |
|
|
pageStore = µm.pageStatsFromTabId(µm.behindTheSceneTabId); |
|
|
} |
|
|
} |
|
@ -329,6 +333,8 @@ var onBeforeRequestHandler = function(details) { |
|
|
// it is available.
|
|
|
// it is available.
|
|
|
pageStore.recordRequest(requestType, requestURL, block); |
|
|
pageStore.recordRequest(requestType, requestURL, block); |
|
|
|
|
|
|
|
|
|
|
|
µm.updateBadgeAsync(tabId); |
|
|
|
|
|
|
|
|
// whitelisted?
|
|
|
// whitelisted?
|
|
|
if ( !block ) { |
|
|
if ( !block ) { |
|
|
// console.debug('onBeforeRequestHandler()> ALLOW "%s": %o', details.url, details);
|
|
|
// console.debug('onBeforeRequestHandler()> ALLOW "%s": %o', details.url, details);
|
|
@ -394,6 +400,7 @@ var onBeforeSendHeadersHandler = function(details) { |
|
|
if ( linkAuditor ) { |
|
|
if ( linkAuditor ) { |
|
|
var block = µm.userSettings.processHyperlinkAuditing; |
|
|
var block = µm.userSettings.processHyperlinkAuditing; |
|
|
pageStore.recordRequest('other', requestURL + '{Ping-To:' + linkAuditor + '}', block); |
|
|
pageStore.recordRequest('other', requestURL + '{Ping-To:' + linkAuditor + '}', block); |
|
|
|
|
|
µm.updateBadgeAsync(tabId); |
|
|
if ( block ) { |
|
|
if ( block ) { |
|
|
µm.hyperlinkAuditingFoiledCounter += 1; |
|
|
µm.hyperlinkAuditingFoiledCounter += 1; |
|
|
return { 'cancel': true }; |
|
|
return { 'cancel': true }; |
|
@ -461,23 +468,6 @@ var hyperlinkAuditorFromHeaders = function(headers) { |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
var tabIdFromHeaders = function(µm, headers) { |
|
|
|
|
|
var header; |
|
|
|
|
|
var i = headers.length; |
|
|
|
|
|
while ( i-- ) { |
|
|
|
|
|
header = headers[i]; |
|
|
|
|
|
if ( header.name.toLowerCase() === 'referer' ) { |
|
|
|
|
|
return µm.tabIdFromPageUrl(header.value); |
|
|
|
|
|
} |
|
|
|
|
|
if ( header.name.toLowerCase() === 'ping-from' ) { |
|
|
|
|
|
return µm.tabIdFromPageUrl(header.value); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return -1; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
var foilCookieHeaders = function(µm, details) { |
|
|
var foilCookieHeaders = function(µm, details) { |
|
|
var changed = false; |
|
|
var changed = false; |
|
|
var headers = details.requestHeaders; |
|
|
var headers = details.requestHeaders; |
|
@ -647,6 +637,7 @@ var onMainDocHeadersReceived = function(details) { |
|
|
while ( destinationURL = mainFrameStack.pop() ) { |
|
|
while ( destinationURL = mainFrameStack.pop() ) { |
|
|
pageStats.recordRequest('doc', destinationURL, false); |
|
|
pageStats.recordRequest('doc', destinationURL, false); |
|
|
} |
|
|
} |
|
|
|
|
|
µm.updateBadgeAsync(tabId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Maybe modify inbound headers
|
|
|
// Maybe modify inbound headers
|
|
@ -775,6 +766,7 @@ var onErrorOccurredHandler = function(details) { |
|
|
while ( destinationURL = mainFrameStack.pop() ) { |
|
|
while ( destinationURL = mainFrameStack.pop() ) { |
|
|
pageStats.recordRequest('doc', destinationURL, false); |
|
|
pageStats.recordRequest('doc', destinationURL, false); |
|
|
} |
|
|
} |
|
|
|
|
|
µm.updateBadgeAsync(details.tabId); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|