mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #403 from MetaMask/fastinject
Improve web3 injection times
This commit is contained in:
commit
e885c3ba09
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- Fix formatting of ETH balance
|
- Fix formatting of ETH balance
|
||||||
- Fix formatting of account details.
|
- Fix formatting of account details.
|
||||||
|
- Use web3 minified dist for faster inject times
|
||||||
- Fix issue where dropdowns were not in front of icons.
|
- Fix issue where dropdowns were not in front of icons.
|
||||||
|
|
||||||
## 2.5.0 2016-06-29
|
## 2.5.0 2016-06-29
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
|
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('./lib/port-stream.js')
|
||||||
const ObjectMultiplex = require('./lib/obj-multiplex')
|
const ObjectMultiplex = require('./lib/obj-multiplex')
|
||||||
// const urlUtil = require('url')
|
|
||||||
|
|
||||||
if (shouldInjectWeb3()) {
|
if (shouldInjectWeb3()) {
|
||||||
setupInjection()
|
setupInjection()
|
||||||
|
setTimeout(setupStreams, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupInjection(){
|
function setupInjection(){
|
||||||
|
|
||||||
// inject in-page script
|
// inject in-page script
|
||||||
var scriptTag = document.createElement('script')
|
var scriptTag = document.createElement('script')
|
||||||
scriptTag.src = chrome.extension.getURL('scripts/inpage.js')
|
scriptTag.src = chrome.extension.getURL('scripts/inpage.js')
|
||||||
@ -16,6 +15,9 @@ function setupInjection(){
|
|||||||
var container = document.head || document.documentElement
|
var container = document.head || document.documentElement
|
||||||
// append as first child
|
// append as first child
|
||||||
container.insertBefore(scriptTag, container.children[0])
|
container.insertBefore(scriptTag, container.children[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupStreams(){
|
||||||
|
|
||||||
// setup communication to page and plugin
|
// setup communication to page and plugin
|
||||||
var pageStream = new LocalMessageDuplexStream({
|
var pageStream = new LocalMessageDuplexStream({
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
|
/*global Web3*/
|
||||||
cleanContextForImports()
|
cleanContextForImports()
|
||||||
const Web3 = require('web3')
|
require('web3/dist/web3.min.js')
|
||||||
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
|
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
|
||||||
const setupDappAutoReload = require('./lib/auto-reload.js')
|
const setupDappAutoReload = require('./lib/auto-reload.js')
|
||||||
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
|
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
|
||||||
restoreContextAfterImports()
|
restoreContextAfterImports()
|
||||||
|
|
||||||
// remove from window
|
|
||||||
delete window.Web3
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// setup plugin communication
|
// setup plugin communication
|
||||||
|
Loading…
x
Reference in New Issue
Block a user