mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-03 17:49:39 +02:00
this fixes 1d448b85b2 (commitcomment-14944764)
This commit is contained in:
parent
dfdd5a10f3
commit
945a8a999a
@ -516,6 +516,22 @@ vAPI.tabs.onPopupUpdated = (function() {
|
||||
// remember whether a popup or popunder was matched.
|
||||
var context = {};
|
||||
|
||||
// https://github.com/gorhill/uBlock/commit/1d448b85b2931412508aa01bf899e0b6f0033626#commitcomment-14944764
|
||||
// See if two URLs are different, disregarding scheme -- because the scheme
|
||||
// can be unilaterally changed by the browser.
|
||||
var areDifferentURLs = function(a, b) {
|
||||
var pos = a.indexOf('://');
|
||||
if ( pos === -1 ) {
|
||||
return false;
|
||||
}
|
||||
a = a.slice(pos);
|
||||
pos = b.indexOf('://');
|
||||
if ( pos === -1 ) {
|
||||
return false;
|
||||
}
|
||||
return b.slice(pos) !== a;
|
||||
};
|
||||
|
||||
var popupMatch = function(openerURL, targetURL, clickedURL, popupType) {
|
||||
var openerHostname = µb.URI.hostnameFromURI(openerURL);
|
||||
var openerDomain = µb.URI.domainFromHostname(openerHostname);
|
||||
@ -529,12 +545,19 @@ vAPI.tabs.onPopupUpdated = (function() {
|
||||
context.requestHostname = µb.URI.hostnameFromURI(targetURL);
|
||||
context.requestType = 'popup';
|
||||
|
||||
// https://github.com/gorhill/uBlock/commit/1d448b85b2931412508aa01bf899e0b6f0033626#commitcomment-14944764
|
||||
// Ignore bad target URL. On Firefox, an `about:blank` tab may be
|
||||
// opened for a new tab before it is filled in with the real target URL.
|
||||
if ( context.requestHostname === '' ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Dynamic filtering makes sense only when we have a valid hostname.
|
||||
if ( openerHostname !== '' ) {
|
||||
// Check user switch first
|
||||
if (
|
||||
popupType !== 'popunder' &&
|
||||
targetURL !== clickedURL &&
|
||||
areDifferentURLs(targetURL, clickedURL) &&
|
||||
µb.hnSwitches.evaluateZ('no-popups', openerHostname)
|
||||
) {
|
||||
return 'ub:no-popups: ' + µb.hnSwitches.z + ' true';
|
||||
@ -609,7 +632,7 @@ vAPI.tabs.onPopupUpdated = (function() {
|
||||
// Popunder test. Ignore if the target URL was opened by clicking on
|
||||
// a link, or else this could prevent opening a legitimate site for
|
||||
// which there is a very broad popunder filter.
|
||||
if ( result === '' && targetURL !== µb.mouseURL ) {
|
||||
if ( result === '' && areDifferentURLs(targetURL, µb.mouseURL) ) {
|
||||
var tmp = openerTabId; openerTabId = targetTabId; targetTabId = tmp;
|
||||
popupType = 'popunder';
|
||||
result = popupMatch(targetURL, openerURL, µb.mouseURL, popupType);
|
||||
|
Loading…
Reference in New Issue
Block a user