mirror of https://github.com/gorhill/uBlock.git
Experimental fix for #44
Disregard no-popups per-site switch for a URL which matches a link clicked by the user.
This commit is contained in:
parent
6763cca756
commit
36a15e2e02
|
@ -191,8 +191,9 @@ return {
|
||||||
noopFunc: function(){},
|
noopFunc: function(){},
|
||||||
|
|
||||||
apiErrorCount: 0,
|
apiErrorCount: 0,
|
||||||
contextMenuClientX: -1,
|
mouseX: -1,
|
||||||
contextMenuClientY: -1,
|
mouseY: -1,
|
||||||
|
mouseURL: '',
|
||||||
epickerTarget: '',
|
epickerTarget: '',
|
||||||
epickerEprom: null,
|
epickerEprom: null,
|
||||||
|
|
||||||
|
|
|
@ -897,19 +897,20 @@ var uBlockCollapser = (function() {
|
||||||
if ( window !== window.top ) {
|
if ( window !== window.top ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var onContextMenu = function(ev) {
|
var onMouseClick = function(ev) {
|
||||||
messager.send({
|
messager.send({
|
||||||
what: 'contextMenuEvent',
|
what: 'mouseClick',
|
||||||
clientX: ev.clientX,
|
x: ev.clientX,
|
||||||
clientY: ev.clientY
|
y: ev.clientY,
|
||||||
|
url: ev.target && ev.target.localName === 'a' ? ev.target.href : ''
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('contextmenu', onContextMenu, true);
|
window.addEventListener('contextmenu', onMouseClick, true);
|
||||||
|
|
||||||
// https://github.com/gorhill/uMatrix/issues/144
|
// https://github.com/gorhill/uMatrix/issues/144
|
||||||
vAPI.shutdown.add(function() {
|
vAPI.shutdown.add(function() {
|
||||||
document.removeEventListener('contextmenu', onContextMenu, true);
|
document.removeEventListener('contextmenu', onMouseClick, true);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
@ -96,9 +96,10 @@ var onMessage = function(request, sender, callback) {
|
||||||
var response;
|
var response;
|
||||||
|
|
||||||
switch ( request.what ) {
|
switch ( request.what ) {
|
||||||
case 'contextMenuEvent':
|
case 'mouseClick':
|
||||||
µb.contextMenuClientX = request.clientX;
|
µb.mouseX = request.x;
|
||||||
µb.contextMenuClientY = request.clientY;
|
µb.mouseY = request.y;
|
||||||
|
µb.mouseURL = request.url;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cosmeticFiltersInjected':
|
case 'cosmeticFiltersInjected':
|
||||||
|
@ -133,7 +134,7 @@ var onMessage = function(request, sender, callback) {
|
||||||
|
|
||||||
case 'launchElementPicker':
|
case 'launchElementPicker':
|
||||||
// Launched from some auxiliary pages, clear context menu coords.
|
// Launched from some auxiliary pages, clear context menu coords.
|
||||||
µb.contextMenuClientX = µb.contextMenuClientY = -1;
|
µb.mouseX = µb.mouseY = -1;
|
||||||
µb.elementPickerExec(request.tabId, request.targetURL);
|
µb.elementPickerExec(request.tabId, request.targetURL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -633,14 +634,14 @@ var onMessage = function(request, sender, callback) {
|
||||||
callback({
|
callback({
|
||||||
frameContent: this.responseText.replace(reStrings, replacer),
|
frameContent: this.responseText.replace(reStrings, replacer),
|
||||||
target: µb.epickerTarget,
|
target: µb.epickerTarget,
|
||||||
clientX: µb.contextMenuClientX,
|
clientX: µb.mouseX,
|
||||||
clientY: µb.contextMenuClientY,
|
clientY: µb.mouseY,
|
||||||
eprom: µb.epickerEprom
|
eprom: µb.epickerEprom
|
||||||
});
|
});
|
||||||
|
|
||||||
µb.epickerTarget = '';
|
µb.epickerTarget = '';
|
||||||
µb.contextMenuClientX = -1;
|
µb.mouseX = -1;
|
||||||
µb.contextMenuClientY = -1;
|
µb.mouseY = -1;
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -500,7 +500,10 @@ vAPI.tabs.onPopup = function(details) {
|
||||||
var loggerEnabled = µb.logger.isEnabled();
|
var loggerEnabled = µb.logger.isEnabled();
|
||||||
|
|
||||||
// Check user switch first
|
// Check user switch first
|
||||||
if ( µb.hnSwitches.evaluateZ('no-popups', openerHostname) ) {
|
if (
|
||||||
|
targetURL !== µb.mouseURL &&
|
||||||
|
µb.hnSwitches.evaluateZ('no-popups', openerHostname)
|
||||||
|
) {
|
||||||
result = 'ub:no-popups: ' + µb.hnSwitches.z + ' true';
|
result = 'ub:no-popups: ' + µb.hnSwitches.z + ' true';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue