diff options
author | gorhill <rhill@raymondhill.net> | 2015-09-10 13:46:18 -0400 |
---|---|---|
committer | gorhill <rhill@raymondhill.net> | 2015-09-10 13:46:18 -0400 |
commit | 36a15e2e0241595131f8783c7bf6f6fa2ed8c870 (patch) | |
tree | c4a5e4025c00a09d144cf5868b8a6b07eb6d0210 | |
parent | 6763cca756fbe8b0218f7429a6d09a359479e98b (diff) | |
download | uBlock-36a15e2e0241595131f8783c7bf6f6fa2ed8c870.zip uBlock-36a15e2e0241595131f8783c7bf6f6fa2ed8c870.tar.gz uBlock-36a15e2e0241595131f8783c7bf6f6fa2ed8c870.tar.bz2 |
Experimental fix for #44
Disregard no-popups per-site switch for a URL which matches
a link clicked by the user.
-rw-r--r-- | src/js/background.js | 5 | ||||
-rw-r--r-- | src/js/contentscript-end.js | 13 | ||||
-rw-r--r-- | src/js/messaging.js | 17 | ||||
-rw-r--r-- | src/js/tab.js | 5 |
4 files changed, 23 insertions, 17 deletions
diff --git a/src/js/background.js b/src/js/background.js index a7fdaa3..8cb846d 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -191,8 +191,9 @@ return { noopFunc: function(){}, apiErrorCount: 0, - contextMenuClientX: -1, - contextMenuClientY: -1, + mouseX: -1, + mouseY: -1, + mouseURL: '', epickerTarget: '', epickerEprom: null, diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 2996839..152339a 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -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); }); })(); diff --git a/src/js/messaging.js b/src/js/messaging.js index 47886d5..07a2bc6 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -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; diff --git a/src/js/tab.js b/src/js/tab.js index 6625bff..d7ce863 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -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'; } |