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