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:
gorhill 2015-09-10 13:46:18 -04:00
parent 6763cca756
commit 36a15e2e02
4 changed files with 23 additions and 17 deletions

View file

@ -191,8 +191,9 @@ return {
noopFunc: function(){},
apiErrorCount: 0,
contextMenuClientX: -1,
contextMenuClientY: -1,
mouseX: -1,
mouseY: -1,
mouseURL: '',
epickerTarget: '',
epickerEprom: null,

View file

@ -897,19 +897,20 @@ var uBlockCollapser = (function() {
if ( window !== window.top ) {
return;
}
var onContextMenu = function(ev) {
var onMouseClick = function(ev) {
messager.send({
what: 'contextMenuEvent',
clientX: ev.clientX,
clientY: ev.clientY
what: 'mouseClick',
x: ev.clientX,
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
vAPI.shutdown.add(function() {
document.removeEventListener('contextmenu', onContextMenu, true);
document.removeEventListener('contextmenu', onMouseClick, true);
});
})();

View file

@ -96,9 +96,10 @@ var onMessage = function(request, sender, callback) {
var response;
switch ( request.what ) {
case 'contextMenuEvent':
µb.contextMenuClientX = request.clientX;
µb.contextMenuClientY = request.clientY;
case 'mouseClick':
µb.mouseX = request.x;
µb.mouseY = request.y;
µb.mouseURL = request.url;
break;
case 'cosmeticFiltersInjected':
@ -133,7 +134,7 @@ var onMessage = function(request, sender, callback) {
case 'launchElementPicker':
// 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);
break;
@ -633,14 +634,14 @@ var onMessage = function(request, sender, callback) {
callback({
frameContent: this.responseText.replace(reStrings, replacer),
target: µb.epickerTarget,
clientX: µb.contextMenuClientX,
clientY: µb.contextMenuClientY,
clientX: µb.mouseX,
clientY: µb.mouseY,
eprom: µb.epickerEprom
});
µb.epickerTarget = '';
µb.contextMenuClientX = -1;
µb.contextMenuClientY = -1;
µb.mouseX = -1;
µb.mouseY = -1;
};
xhr.send();
return;

View file

@ -500,7 +500,10 @@ vAPI.tabs.onPopup = function(details) {
var loggerEnabled = µb.logger.isEnabled();
// 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';
}