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 2017-10-13 09:33:02 -04:00
parent 01fe37c390
commit 7713597e3e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -140,7 +140,13 @@ housekeep itself.
var PopupCandidate = function(targetTabId, openerTabId) { var PopupCandidate = function(targetTabId, openerTabId) {
this.targetTabId = targetTabId; this.targetTabId = targetTabId;
this.openerTabId = openerTabId; this.opener = {
tabId: openerTabId,
popunder: false,
trustedURL: openerTabId === µb.mouseEventRegister.tabId ?
µb.mouseEventRegister.url :
''
};
this.selfDestructionTimer = null; this.selfDestructionTimer = null;
this.launchSelfDestruction(); this.launchSelfDestruction();
}; };
@ -160,13 +166,20 @@ housekeep itself.
}; };
var popupCandidateTest = function(targetTabId) { var popupCandidateTest = function(targetTabId) {
var candidates = popupCandidates, entry; var candidates = popupCandidates,
entry;
for ( var tabId in candidates ) { for ( var tabId in candidates ) {
entry = candidates[tabId]; entry = candidates[tabId];
if ( targetTabId !== tabId && targetTabId !== entry.openerTabId ) { if ( targetTabId !== tabId && targetTabId !== entry.opener.tabId ) {
continue; continue;
} }
if ( vAPI.tabs.onPopupUpdated(tabId, entry.openerTabId) === true ) { // https://github.com/gorhill/uBlock/issues/3129
// If the trigger is a change in the opener's URL, mark the entry
// as candidate for popunder filtering.
if ( targetTabId === entry.opener.tabId ) {
entry.popunder = true;
}
if ( vAPI.tabs.onPopupUpdated(tabId, entry.opener) === true ) {
entry.destroy(); entry.destroy();
} else { } else {
entry.launchSelfDestruction(); entry.launchSelfDestruction();
@ -706,8 +719,9 @@ vAPI.tabs.onPopupUpdated = (function() {
); );
}; };
return function(targetTabId, openerTabId) { return function(targetTabId, openerDetails) {
// Opener details. // Opener details.
var openerTabId = openerDetails.tabId;
var tabContext = µb.tabContextManager.lookup(openerTabId); var tabContext = µb.tabContextManager.lookup(openerTabId);
if ( tabContext === null ) { return; } if ( tabContext === null ) { return; }
var openerURL = tabContext.rawURL; var openerURL = tabContext.rawURL;
@ -744,15 +758,12 @@ vAPI.tabs.onPopupUpdated = (function() {
result = 0; result = 0;
// https://github.com/gorhill/uBlock/issues/2919 // https://github.com/gorhill/uBlock/issues/2919
// - If the target tab matches a clicked link, assume it's legit. // - If the target tab matches a clicked link, assume it's legit.
if ( if ( areDifferentURLs(targetURL, openerDetails.trustedURL) ) {
openerTabId !== µb.mouseEventRegister.tabId ||
areDifferentURLs(targetURL, µb.mouseEventRegister.url)
) {
result = popupMatch(openerURL, targetURL, 'popup'); result = popupMatch(openerURL, targetURL, 'popup');
} }
// Popunder test. // Popunder test.
if ( result === 0 ) { if ( result === 0 && openerDetails.popunder ) {
result = popunderMatch(openerURL, targetURL); result = popunderMatch(openerURL, targetURL);
if ( result === 1 ) { if ( result === 1 ) {
popupType = 'popunder'; popupType = 'popunder';