Index: lib/options.js |
=================================================================== |
--- a/lib/options.js |
+++ b/lib/options.js |
@@ -21,7 +21,6 @@ |
const {getDecodedHostname} = require("url"); |
const {checkWhitelisted} = require("whitelisting"); |
-const {port} = require("messaging"); |
const info = require("info"); |
const optionsUrl = "options.html"; |
@@ -107,17 +106,26 @@ |
if (!tab) |
return; |
- function onMessage(message, sender) |
+ function onMessage(message, port) |
{ |
- if (message.type == "app.listen" && |
- sender.page && sender.page.id == tab.id) |
- { |
- port.off("app.listen", onMessage); |
- callback(new ext.Page(tab)); |
- } |
+ if (message.type != "app.listen") |
+ return; |
+ |
+ port.onMessage.removeListener(onMessage); |
+ callback(new ext.Page(tab)); |
} |
- port.on("app.listen", onMessage); |
+ function onConnect(port) |
+ { |
+ let {name, sender} = port; |
+ if (name != "ui" || !sender || sender.tab.id != tab.id) |
+ return; |
+ |
+ browser.runtime.onConnect.removeListener(onConnect); |
+ port.onMessage.addListener(onMessage); |
+ } |
+ |
+ browser.runtime.onConnect.addListener(onConnect); |
}); |
} |
} |