1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 20:02:58 +01:00

web3 injection - use web3 dist for faster injection

This commit is contained in:
kumavis 2016-07-06 20:20:40 -07:00
parent 9d54f10dc5
commit 7aa120e630
2 changed files with 9 additions and 5 deletions

View File

@ -1,14 +1,13 @@
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
const PortStream = require('./lib/port-stream.js')
const ObjectMultiplex = require('./lib/obj-multiplex')
// const urlUtil = require('url')
if (shouldInjectWeb3()) {
setupInjection()
setTimeout(setupStreams, 200)
}
function setupInjection(){
// inject in-page script
var scriptTag = document.createElement('script')
scriptTag.src = chrome.extension.getURL('scripts/inpage.js')
@ -16,6 +15,13 @@ function setupInjection(){
var container = document.head || document.documentElement
// append as first child
container.insertBefore(scriptTag, container.children[0])
}
function setupStreams(){
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
const PortStream = require('./lib/port-stream.js')
const ObjectMultiplex = require('./lib/obj-multiplex')
// setup communication to page and plugin
var pageStream = new LocalMessageDuplexStream({

View File

@ -1,12 +1,10 @@
cleanContextForImports()
const Web3 = require('web3')
require('web3/dist/web3.min.js')
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
const setupDappAutoReload = require('./lib/auto-reload.js')
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
restoreContextAfterImports()
// remove from window
delete window.Web3
//
// setup plugin communication