A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/app/scripts/contentscript.js

25 lines
781 B

const messageType = 'metamaskMessage'
// inject in-page script
9 years ago
var scriptTag = document.createElement('script')
scriptTag.src = chrome.extension.getURL('scripts/inpage.js')
scriptTag.onload = function() { this.parentNode.removeChild(this) }
var container = document.head || document.documentElement
container.appendChild(scriptTag)
// listen for messages
var metamaskPlugin = chrome.runtime.connect({name: 'metamask'})
// metamaskPlugin.onMessage.addListener(function(msg) {
// console.log(msg)
// })
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
// forward message
metamaskPlugin.postMessage(msg)
}