Index: lib/aardvark.js |
=================================================================== |
--- a/lib/aardvark.js |
+++ b/lib/aardvark.js |
@@ -7,16 +7,18 @@ |
let {Prefs} = require("prefs"); |
// Make sure to stop selection when we are uninstalled |
onShutdown.add(() => Aardvark.quit()); |
// To be replaced when selection starts |
function E(id) {return null;} |
+let messageCounter = 0; |
+ |
/********************************* |
* Minimal element creation code * |
*********************************/ |
function createElement(doc, tagName, attrs, children) |
{ |
let el = doc.createElement(tagName); |
if (attrs) |
@@ -585,31 +587,45 @@ let Aardvark = exports.Aardvark = |
return false; |
}, |
select: function(elem) |
{ |
if (!elem) |
return false; |
+ let messageId = ++messageCounter; |
+ let callback = (message) => |
+ { |
+ let response = message.data; |
+ if (response.messageId != messageId) |
+ return; |
+ |
+ this.browser.selectedBrowser.messageManager.removeMessageListener( |
+ "ElemHideHelper:GetNodeInfo:Response", |
+ callback |
+ ); |
+ |
+ if (!response.nodeData) |
+ return; |
+ |
+ this.window.openDialog("chrome://elemhidehelper/content/composer.xul", |
+ "_blank", "chrome,centerscreen,resizable,dialog=no", response); |
+ this.quit(); |
+ }; |
+ |
+ this.browser.selectedBrowser.messageManager.addMessageListener( |
+ "ElemHideHelper:GetNodeInfo:Response", |
+ callback |
+ ); |
this.browser.selectedBrowser.messageManager.sendAsyncMessage( |
"ElemHideHelper:GetNodeInfo", |
- null, |
+ messageId, |
{ |
- element: elem, |
- callback: (response) => |
- { |
- response = JSON.parse(response); |
- if (!response.nodeData) |
- return; |
- |
- this.window.openDialog("chrome://elemhidehelper/content/composer.xul", |
- "_blank", "chrome,centerscreen,resizable,dialog=no", response); |
- this.quit(); |
- } |
+ element: elem |
} |
); |
return false; |
}, |
blinkElement: function(elem) |
{ |
if (!elem) |