diff options
store unconfirmedTxs in chrome sync storage
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r-- | app/scripts/contentscript.js | 12 |
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 |