Index: include.postload.js |
diff --git a/include.postload.js b/include.postload.js |
index 99b55dcce8ef6f45777fbb64be86a0a6e03804ae..2aacf80e1737d6e928b2d347f28bd431e0fcb381 100644 |
--- a/include.postload.js |
+++ b/include.postload.js |
@@ -19,10 +19,10 @@ |
var clickHide_activated = false; |
var clickHide_filters = null; |
var currentElement = null; |
-var clickHideFilters = null; |
var highlightedElementsSelector = null; |
var clickHideFiltersDialog = null; |
var lastRightClickEvent = null; |
+var lastRightClickEventRandom = null; |
function escapeChar(chr) |
{ |
@@ -325,12 +325,12 @@ function clickHide_showDialog(left, top, filters) |
{ |
if (clickHideFiltersDialog) |
clickHideFiltersDialog.style.setProperty("opacity", "0.7"); |
- } |
+ }; |
clickHideFiltersDialog.onmouseover = function() |
{ |
if (clickHideFiltersDialog) |
clickHideFiltersDialog.style.setProperty("opacity", "1.0"); |
- } |
+ }; |
document.body.appendChild(clickHideFiltersDialog); |
} |
@@ -390,12 +390,13 @@ function clickHide_deactivate(keepOverlays) |
if (!keepOverlays) |
{ |
+ lastRightClickEvent = null; |
+ |
if (currentElement) { |
currentElement.removeEventListener("contextmenu", clickHide_elementClickHandler, true); |
unhighlightElements(); |
unhighlightElement(currentElement); |
currentElement = null; |
- clickHideFilters = null; |
} |
unhighlightElements(); |
@@ -474,8 +475,8 @@ function clickHide_mouseClick(e) |
if (currentElement.classList.contains("__adblockplus__overlay")) |
elt = currentElement.prisoner; |
- clickHideFilters = new Array(); |
- selectorList = new Array(); |
+ var clickHideFilters = new Array(); |
+ var selectorList = new Array(); |
var addSelector = function(selector) |
{ |
@@ -526,8 +527,17 @@ function clickHide_mouseClick(e) |
addSelector(escapeCSS(elt.localName) + '[style=' + quote(style) + ']'); |
} |
- // Show popup |
- clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); |
+ // Show popup, or if inside frame tell the parent to do it |
+ if (window.self == window.top) |
+ clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); |
+ else |
+ ext.backgroundPage.sendMessage( |
+ { |
+ type: "clickHide-showDialog", |
+ screenX: e.screenX, |
+ screenY: e.screenY, |
+ clickHideFilters: clickHideFilters |
+ }); |
// Highlight the elements specified by selector in yellow |
if (selectorList.length > 0) |
@@ -579,8 +589,18 @@ if ("ext" in window && document instanceof HTMLDocument) |
// To make things easier, we actually save the DOM event. |
// We have to do this because the contextMenu API only provides a URL, not the actual |
// DOM element. |
- document.addEventListener('contextmenu', function(e) { |
+ document.addEventListener('contextmenu', function(e) |
+ { |
lastRightClickEvent = e; |
+ // We also need to ensure any old lastRightClickEvent variables in other |
+ // frames are cleared. So we store a random number, send a message to all |
+ // frames that they should clear lastRightClickEvent unless the number matches |
+ lastRightClickEventRandom = Math.random(); |
+ ext.backgroundPage.sendMessage( |
+ { |
+ type: "clickHide-clear-lastRightClickEvent", |
+ random: lastRightClickEventRandom |
+ }); |
}, true); |
document.addEventListener("click", function(event) |
@@ -683,7 +703,7 @@ if ("ext" in window && document instanceof HTMLDocument) |
} |
break; |
case "clickhide-close": |
- if (clickHideFiltersDialog && msg.remove) |
+ if (currentElement && msg.remove) |
{ |
// Explicitly get rid of currentElement |
var element = currentElement.prisoner || currentElement; |
@@ -692,6 +712,17 @@ if ("ext" in window && document instanceof HTMLDocument) |
} |
clickHide_deactivate(); |
break; |
+ case "clickHide-showDialog": |
+ if (window.self == window.top) |
+ clickHide_showDialog(msg.screenX + window.pageXOffset, |
+ msg.screenY + window.pageYOffset, |
+ msg.clickHideFilters); |
+ break; |
+ case "clickHide-clear-lastRightClickEvent": |
+ if (msg.random != lastRightClickEventRandom) |
+ lastRightClickEvent = null; |
+ lastRightClickEventRandom = null; |
+ break; |
} |
}); |