This commit is contained in:
gorhill 2014-10-15 13:14:25 -04:00
parent 49df5e0ec6
commit bafc6360b8
2 changed files with 30 additions and 21 deletions

View File

@ -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);

View File

@ -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) === '@@' ) {