1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

this fixes #65

This commit is contained in:
gorhill 2014-07-14 14:40:40 -04:00
parent c040d62f8f
commit 2a91aa0af6

View File

@ -51,12 +51,19 @@ var onBeforeRootDocumentRequestHandler = function(tabId, details) {
// Heuristic to determine whether we are dealing with a popup: // Heuristic to determine whether we are dealing with a popup:
// - the page store is new (it's not a reused one) // - the page store is new (it's not a reused one)
// - the referrer is not nil
// Can't be a popup, the tab was in use previously. // Can't be a popup, the tab was in use previously.
if ( pageStore.previousPageURL !== '' ) { if ( pageStore.previousPageURL !== '' ) {
return; return;
} }
var referrer = referrerFromHeaders(details.requestHeaders);
if ( referrer === '' ) {
return;
}
//console.debug('Referrer="%s"', referrer);
var reason = false; var reason = false;
if ( µb.getNetFilteringSwitch(pageStore.pageHostname) ) { if ( µb.getNetFilteringSwitch(pageStore.pageHostname) ) {
reason = µb.abpFilters.matchString( reason = µb.abpFilters.matchString(
@ -148,7 +155,19 @@ var onBeforeRequestHandler = function(details) {
/******************************************************************************/ /******************************************************************************/
chrome.webRequest.onBeforeRequest.addListener( var referrerFromHeaders = function(headers) {
var i = headers.length;
while ( i-- ) {
if ( headers[i].name.toLowerCase() === 'referer' ) {
return headers[i].value;
}
}
return '';
};
/******************************************************************************/
chrome.webRequest.onBeforeSendHeaders.addListener(
//function(details) { //function(details) {
// quickProfiler.start('onBeforeRequest'); // quickProfiler.start('onBeforeRequest');
// var r = onBeforeRequestHandler(details); // var r = onBeforeRequestHandler(details);
@ -172,7 +191,7 @@ chrome.webRequest.onBeforeRequest.addListener(
"other" "other"
] ]
}, },
[ "blocking" ] [ "blocking", "requestHeaders" ]
); );
console.log('µBlock> Beginning to intercept net requests at %s', (new Date()).toISOString()); console.log('µBlock> Beginning to intercept net requests at %s', (new Date()).toISOString());