@@ -140,7 +140,13 @@ housekeep itself.
140
140
141
141
var PopupCandidate = function ( targetTabId , openerTabId ) {
142
142
this . targetTabId = targetTabId ;
143
- this . openerTabId = openerTabId ;
143
+ this . opener = {
144
+ tabId : openerTabId ,
145
+ popunder : false ,
146
+ trustedURL : openerTabId === µb . mouseEventRegister . tabId ?
147
+ µb . mouseEventRegister . url :
148
+ ''
149
+ } ;
144
150
this . selfDestructionTimer = null ;
145
151
this . launchSelfDestruction ( ) ;
146
152
} ;
@@ -160,13 +166,20 @@ housekeep itself.
160
166
} ;
161
167
162
168
var popupCandidateTest = function ( targetTabId ) {
163
- var candidates = popupCandidates , entry ;
169
+ var candidates = popupCandidates ,
170
+ entry ;
164
171
for ( var tabId in candidates ) {
165
172
entry = candidates [ tabId ] ;
166
- if ( targetTabId !== tabId && targetTabId !== entry . openerTabId ) {
173
+ if ( targetTabId !== tabId && targetTabId !== entry . opener . tabId ) {
167
174
continue ;
168
175
}
169
- if ( vAPI . tabs . onPopupUpdated ( tabId , entry . openerTabId ) === true ) {
176
+ // https://github.com/gorhill/uBlock/issues/3129
177
+ // If the trigger is a change in the opener's URL, mark the entry
178
+ // as candidate for popunder filtering.
179
+ if ( targetTabId === entry . opener . tabId ) {
180
+ entry . popunder = true ;
181
+ }
182
+ if ( vAPI . tabs . onPopupUpdated ( tabId , entry . opener ) === true ) {
170
183
entry . destroy ( ) ;
171
184
} else {
172
185
entry . launchSelfDestruction ( ) ;
@@ -706,8 +719,9 @@ vAPI.tabs.onPopupUpdated = (function() {
706
719
) ;
707
720
} ;
708
721
709
- return function ( targetTabId , openerTabId ) {
722
+ return function ( targetTabId , openerDetails ) {
710
723
// Opener details.
724
+ var openerTabId = openerDetails . tabId ;
711
725
var tabContext = µb . tabContextManager . lookup ( openerTabId ) ;
712
726
if ( tabContext === null ) { return ; }
713
727
var openerURL = tabContext . rawURL ;
@@ -744,15 +758,12 @@ vAPI.tabs.onPopupUpdated = (function() {
744
758
result = 0 ;
745
759
// https://github.com/gorhill/uBlock/issues/2919
746
760
// - If the target tab matches a clicked link, assume it's legit.
747
- if (
748
- openerTabId !== µb . mouseEventRegister . tabId ||
749
- areDifferentURLs ( targetURL , µb . mouseEventRegister . url )
750
- ) {
761
+ if ( areDifferentURLs ( targetURL , openerDetails . trustedURL ) ) {
751
762
result = popupMatch ( openerURL , targetURL , 'popup' ) ;
752
763
}
753
764
754
765
// Popunder test.
755
- if ( result === 0 ) {
766
+ if ( result === 0 && openerDetails . popunder ) {
756
767
result = popunderMatch ( openerURL , targetURL ) ;
757
768
if ( result === 1 ) {
758
769
popupType = 'popunder' ;
0 commit comments