From bafc6360b8d04cc99c78ee7a13f2bc6fc0dee337 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 15 Oct 2014 13:14:25 -0400 Subject: [PATCH] this fixes #323 --- js/tab.js | 14 ++++++++++---- js/traffic.js | 37 ++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/js/tab.js b/js/tab.js index 7c1993dbc..47faf9d29 100644 --- a/js/tab.js +++ b/js/tab.js @@ -64,17 +64,23 @@ if ( !pageStore ) { return; } - if ( pageStore.getNetFilteringSwitch() !== true ) { - return; - } var requestURL = details.url; - var result = µb.netFilteringEngine.matchStringExactType(pageStore, requestURL, 'popup'); + var result = ''; + + // https://github.com/gorhill/uBlock/issues/323 + // If popup URL is whitelisted, do not block it + if ( µb.getNetFilteringSwitch(requestURL) ) { + result = µb.netFilteringEngine.matchStringExactType(pageStore, requestURL, 'popup'); + } + // https://github.com/gorhill/uBlock/issues/91 pageStore.recordResult('popup', requestURL, result); + // Not blocked if ( pageStore.boolFromResult(result) === false ) { return; } + // Blocked // It is a popup, block and remove the tab. µb.unbindTabFromPageStats(details.tabId); diff --git a/js/traffic.js b/js/traffic.js index a3fdd38ce..2811031d2 100644 --- a/js/traffic.js +++ b/js/traffic.js @@ -172,27 +172,30 @@ var onBeforeSendHeaders = function(details) { return; } + // https://github.com/gorhill/uBlock/issues/323 + if ( pageStore.getNetFilteringSwitch() === false ) { + return; + } + // TODO: I think I should test the switch of the referrer instead, not the // switch of the popup. If so, that would require being able to lookup // a page store from a URL. Have to keep in mind the same URL can appear // in multiple tabs. - var result = ''; - if ( pageStore.getNetFilteringSwitch() ) { - // https://github.com/gorhill/uBlock/issues/67 - // We need to pass the details of the page which opened this popup, - // so that the `third-party` option works. - // Create a synthetic context based on the referrer. - var µburi = µb.URI; - var referrerHostname = µburi.hostnameFromURI(referrer); - var pageDetails = { - pageHostname: referrerHostname, - pageDomain: µburi.domainFromHostname(referrerHostname), - }; - pageDetails.rootHostname = pageDetails.pageHostname; - pageDetails.rootDomain = pageDetails.pageDomain; - //console.debug('Referrer="%s"', referrer); - result = µb.netFilteringEngine.matchStringExactType(pageDetails, requestURL, 'popup'); - } + + // https://github.com/gorhill/uBlock/issues/67 + // We need to pass the details of the page which opened this popup, + // so that the `third-party` option works. + // Create a synthetic context based on the referrer. + var µburi = µb.URI; + var referrerHostname = µburi.hostnameFromURI(referrer); + var pageDetails = { + pageHostname: referrerHostname, + pageDomain: µburi.domainFromHostname(referrerHostname), + }; + pageDetails.rootHostname = pageDetails.pageHostname; + pageDetails.rootDomain = pageDetails.pageDomain; + //console.debug('Referrer="%s"', referrer); + var result = µb.netFilteringEngine.matchStringExactType(pageDetails, requestURL, 'popup'); // Not blocked? if ( result === '' || result.slice(0, 2) === '@@' ) {