mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 17:19:38 +02:00
parent
7a33472659
commit
7eeba29220
@ -117,7 +117,7 @@ var classNameFromTabId = function(tabId) {
|
||||
if ( tabId < 0 ) {
|
||||
return 'tab_bts';
|
||||
}
|
||||
if ( tabId !== '' ) {
|
||||
if ( tabId !== 0 ) {
|
||||
return 'tab_' + tabId;
|
||||
}
|
||||
return '';
|
||||
|
@ -624,7 +624,10 @@ var renderOnce = function() {
|
||||
/******************************************************************************/
|
||||
|
||||
var renderPopupLazy = function() {
|
||||
messaging.send('popupPanel', { what: 'getPopupLazyData', tabId: popupData.tabId });
|
||||
messaging.send(
|
||||
'popupPanel',
|
||||
{ what: 'getPopupLazyData', tabId: popupData.tabId }
|
||||
);
|
||||
};
|
||||
|
||||
var onPopupMessage = function(data) {
|
||||
@ -1072,7 +1075,7 @@ var onHideTooltip = function() {
|
||||
// Extract the tab id of the page this popup is for
|
||||
var matches = window.location.search.match(/[\?&]tabId=([^&]+)/);
|
||||
if ( matches && matches.length === 2 ) {
|
||||
tabId = matches[1];
|
||||
tabId = parseInt(matches[1], 10) || 0;
|
||||
}
|
||||
getPopupData(tabId);
|
||||
|
||||
|
@ -136,7 +136,7 @@ housekeep itself.
|
||||
var mostRecentRootDocURL = '';
|
||||
var mostRecentRootDocURLTimestamp = 0;
|
||||
|
||||
var popupCandidates = Object.create(null);
|
||||
var popupCandidates = new Map();
|
||||
|
||||
var PopupCandidate = function(targetTabId, openerTabId) {
|
||||
this.targetTabId = targetTabId;
|
||||
@ -155,7 +155,7 @@ housekeep itself.
|
||||
if ( this.selfDestructionTimer !== null ) {
|
||||
clearTimeout(this.selfDestructionTimer);
|
||||
}
|
||||
delete popupCandidates[this.targetTabId];
|
||||
popupCandidates.delete(this.targetTabId);
|
||||
};
|
||||
|
||||
PopupCandidate.prototype.launchSelfDestruction = function() {
|
||||
@ -166,31 +166,36 @@ housekeep itself.
|
||||
};
|
||||
|
||||
var popupCandidateTest = function(targetTabId) {
|
||||
var candidates = popupCandidates,
|
||||
entry;
|
||||
for ( var tabId in candidates ) {
|
||||
entry = candidates[tabId];
|
||||
if ( targetTabId !== tabId && targetTabId !== entry.opener.tabId ) {
|
||||
for ( var entry of popupCandidates ) {
|
||||
var tabId = entry[0];
|
||||
var candidate = entry[1];
|
||||
if (
|
||||
targetTabId !== tabId &&
|
||||
targetTabId !== candidate.opener.tabId
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
// 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.opener.popunder = true;
|
||||
if ( targetTabId === candidate.opener.tabId ) {
|
||||
candidate.opener.popunder = true;
|
||||
}
|
||||
if ( vAPI.tabs.onPopupUpdated(tabId, entry.opener) === true ) {
|
||||
entry.destroy();
|
||||
if ( vAPI.tabs.onPopupUpdated(tabId, candidate.opener) === true ) {
|
||||
candidate.destroy();
|
||||
} else {
|
||||
entry.launchSelfDestruction();
|
||||
candidate.launchSelfDestruction();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
vAPI.tabs.onPopupCreated = function(targetTabId, openerTabId) {
|
||||
var popup = popupCandidates[targetTabId];
|
||||
var popup = popupCandidates.get(targetTabId);
|
||||
if ( popup === undefined ) {
|
||||
popupCandidates[targetTabId] = new PopupCandidate(targetTabId, openerTabId);
|
||||
popupCandidates.set(
|
||||
targetTabId,
|
||||
new PopupCandidate(targetTabId, openerTabId)
|
||||
);
|
||||
}
|
||||
popupCandidateTest(targetTabId);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user