1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-18 08:52:26 +02:00
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 ) { if ( !pageStore ) {
return; return;
} }
if ( pageStore.getNetFilteringSwitch() !== true ) {
return;
}
var requestURL = details.url; 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 // https://github.com/gorhill/uBlock/issues/91
pageStore.recordResult('popup', requestURL, result); pageStore.recordResult('popup', requestURL, result);
// Not blocked // Not blocked
if ( pageStore.boolFromResult(result) === false ) { if ( pageStore.boolFromResult(result) === false ) {
return; return;
} }
// Blocked // Blocked
// It is a popup, block and remove the tab. // It is a popup, block and remove the tab.
µb.unbindTabFromPageStats(details.tabId); µb.unbindTabFromPageStats(details.tabId);

View File

@ -172,27 +172,30 @@ var onBeforeSendHeaders = function(details) {
return; 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 // 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 // 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 // a page store from a URL. Have to keep in mind the same URL can appear
// in multiple tabs. // in multiple tabs.
var result = '';
if ( pageStore.getNetFilteringSwitch() ) { // https://github.com/gorhill/uBlock/issues/67
// https://github.com/gorhill/uBlock/issues/67 // We need to pass the details of the page which opened this popup,
// We need to pass the details of the page which opened this popup, // so that the `third-party` option works.
// so that the `third-party` option works. // Create a synthetic context based on the referrer.
// Create a synthetic context based on the referrer. var µburi = µb.URI;
var µburi = µb.URI; var referrerHostname = µburi.hostnameFromURI(referrer);
var referrerHostname = µburi.hostnameFromURI(referrer); var pageDetails = {
var pageDetails = { pageHostname: referrerHostname,
pageHostname: referrerHostname, pageDomain: µburi.domainFromHostname(referrerHostname),
pageDomain: µburi.domainFromHostname(referrerHostname), };
}; pageDetails.rootHostname = pageDetails.pageHostname;
pageDetails.rootHostname = pageDetails.pageHostname; pageDetails.rootDomain = pageDetails.pageDomain;
pageDetails.rootDomain = pageDetails.pageDomain; //console.debug('Referrer="%s"', referrer);
//console.debug('Referrer="%s"', referrer); var result = µb.netFilteringEngine.matchStringExactType(pageDetails, requestURL, 'popup');
result = µb.netFilteringEngine.matchStringExactType(pageDetails, requestURL, 'popup');
}
// Not blocked? // Not blocked?
if ( result === '' || result.slice(0, 2) === '@@' ) { if ( result === '' || result.slice(0, 2) === '@@' ) {