aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/contentscript.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2015-08-02 13:23:33 +0800
committerkumavis <aaron@kumavis.me>2015-08-02 13:23:33 +0800
commitdcfd89db1b98d6d7235c3a73993d8a495a2aabff (patch)
tree8b3faba5f0a28841513ca0dbf49785d6c8d45bd8 /app/scripts/contentscript.js
parent5a9698c77a30d909871974ef519da132f03ed0aa (diff)
downloadtangerine-wallet-browser-dcfd89db1b98d6d7235c3a73993d8a495a2aabff.tar
tangerine-wallet-browser-dcfd89db1b98d6d7235c3a73993d8a495a2aabff.tar.gz
tangerine-wallet-browser-dcfd89db1b98d6d7235c3a73993d8a495a2aabff.tar.bz2
tangerine-wallet-browser-dcfd89db1b98d6d7235c3a73993d8a495a2aabff.tar.lz
tangerine-wallet-browser-dcfd89db1b98d6d7235c3a73993d8a495a2aabff.tar.xz
tangerine-wallet-browser-dcfd89db1b98d6d7235c3a73993d8a495a2aabff.tar.zst
tangerine-wallet-browser-dcfd89db1b98d6d7235c3a73993d8a495a2aabff.zip
store unconfirmedTxs in chrome sync storage
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r--app/scripts/contentscript.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index 53ec9eef5..0493921f0 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -1,4 +1,5 @@
-const messageType = 'metamaskMessage'
+const allowedMessageTarget = 'metamask'
+const allowedMessageType = 'addUnconfirmedTx'
// inject in-page script
@@ -8,18 +9,17 @@ scriptTag.onload = function() { this.parentNode.removeChild(this) }
var container = document.head || document.documentElement
container.appendChild(scriptTag)
-// listen for messages
+// setup connection with background
var metamaskPlugin = chrome.runtime.connect({name: 'metamask'})
-// metamaskPlugin.onMessage.addListener(function(msg) {
-// console.log(msg)
-// })
+// forward messages from inpage to background
window.addEventListener('message', receiveMessage, false);
function receiveMessage(event){
var msg = event.data
// validate message type
if (typeof msg !== 'object') return
- if (msg.type !== messageType) return
+ if (msg.to !== allowedMessageTarget) return
+ if (msg.type !== allowedMessageType) return
// forward message
metamaskPlugin.postMessage(msg)
} \ No newline at end of file