Created
March 14, 2017 09:30
-
-
Save luisivan/e1fcad0b831289aae543fcdd4046e6f6 to your computer and use it in GitHub Desktop.
Injecting our MetaMask fork into an Electron dapp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const injectMetaMask = async () => { | |
const contentScriptReq = await fetch('metamask://app/scripts/contentscript.js') | |
const blob = await contentScriptReq.blob() | |
const s = document.createElement('script') | |
s.type = 'text/javascript' | |
s.src = URL.createObjectURL(blob) | |
document.getElementsByTagName('head')[0].appendChild(s) | |
return true | |
} | |
const loadMetaMask = async () => { | |
await injectMetaMask() | |
console.log('MetaMask: Injected') | |
await metaMaskIframeLoaded() | |
window._setupMetaMaskPageStream(document.getElementById('metaMaskIframe')) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment