-
Notifications
You must be signed in to change notification settings - Fork 58
/
inpage.js
35 lines (25 loc) · 973 Bytes
/
inpage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var webExtensionWallet = "for nebulas";
console.log("webExtensionWallet is defined:" + webExtensionWallet);
var _NasExtWallet = function () {
this.getUserAddressCallback ;
this.getUserAddress = function(callback) {
//console.log("********* get account ************")
getUserAddressCallback = callback
window.postMessage({
"target": "contentscript",
"data":{},
"method": "getAccount",
}, "*");
}
// listen message from contentscript
window.addEventListener('message', function(e) {
// e.detail contains the transferred data (can
if (e.data.src ==="content" && e.data.dst === "inpage" && !!e.data.data && !!e.data.data.account) {
userAddrerss = e.data.data.account;
if(typeof getUserAddressCallback === 'function'){
getUserAddressCallback(userAddrerss)
}
}
})
}
var NasExtWallet = new _NasExtWallet()