aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/manifest.json11
-rw-r--r--app/scripts/contentscript.js33
-rw-r--r--app/scripts/lib/extension-instance.js25
-rw-r--r--app/scripts/lib/remote-store.js2
4 files changed, 53 insertions, 18 deletions
diff --git a/app/manifest.json b/app/manifest.json
index 2c5629f7a..9f49d7b52 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,13 +1,18 @@
{
- "name": "__MSG_appName__",
+ "name": "MetaMask",
"short_name": "Metamask",
- "version": "2.6.2",
+ "version": "2.7.0",
"manifest_version": 2,
- "description": "__MSG_appDescription__",
+ "description": "Ethereum Browser Extension",
"icons": {
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
+ "applications": {
+ "gecko": {
+ "id": "webextension@metamask.io"
+ }
+ },
"default_locale": "en",
"background": {
"scripts": [
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index 0ffe93e3c..1eb04059d 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -3,19 +3,37 @@ const PortStream = require('./lib/port-stream.js')
const ObjectMultiplex = require('./lib/obj-multiplex')
const extension = require('./lib/extension')
+const fs = require('fs')
+const path = require('path')
+const inpageText = fs.readFileSync(path.join(__dirname + '/inpage.js')).toString()
+
+// Eventually this streaming injection could be replaced with:
+// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction
+//
+// But for now that is only Firefox
+// If we create a FireFox-only code path using that API,
+// MetaMask will be much faster loading and performant on Firefox.
+
if (shouldInjectWeb3()) {
setupInjection()
setupStreams()
}
function setupInjection(){
- // inject in-page script
- var scriptTag = document.createElement('script')
- scriptTag.src = extension.extension.getURL('scripts/inpage.js')
- scriptTag.onload = function () { this.parentNode.removeChild(this) }
- var container = document.head || document.documentElement
- // append as first child
- container.insertBefore(scriptTag, container.children[0])
+ try {
+
+ // inject in-page script
+ var scriptTag = document.createElement('script')
+ scriptTag.src = extension.extension.getURL('scripts/inpage.js')
+ scriptTag.textContent = inpageText
+ scriptTag.onload = function () { this.parentNode.removeChild(this) }
+ var container = document.head || document.documentElement
+ // append as first child
+ container.insertBefore(scriptTag, container.children[0])
+
+ } catch (e) {
+ console.error('Metamask injection failed.', e)
+ }
}
function setupStreams(){
@@ -44,7 +62,6 @@ function setupStreams(){
pluginStream.on('close', function () {
reloadStream.write({ method: 'reset' })
})
-
}
function shouldInjectWeb3(){
diff --git a/app/scripts/lib/extension-instance.js b/app/scripts/lib/extension-instance.js
index eeab6c6d0..eb3b8a1e9 100644
--- a/app/scripts/lib/extension-instance.js
+++ b/app/scripts/lib/extension-instance.js
@@ -24,14 +24,27 @@ const apis = [
function Extension () {
const _this = this
- let global = window
-
- if (window.chrome) {
- global = window.chrome
- }
apis.forEach(function (api) {
- _this[api] = global[api]
+
+ _this[api] = null
+
+ try {
+ if (chrome[api]) {
+ _this[api] = chrome[api]
+ }
+ } catch (e) {}
+
+ try {
+ if (window[api]) {
+ _this[api] = window[api]
+ }
+ } catch (e) {}
+
+ try {
+ _this.api = browser.extension[api]
+ } catch (e) {}
+
})
}
diff --git a/app/scripts/lib/remote-store.js b/app/scripts/lib/remote-store.js
index fbfab7bad..c81d5151c 100644
--- a/app/scripts/lib/remote-store.js
+++ b/app/scripts/lib/remote-store.js
@@ -52,7 +52,7 @@ HostStore.prototype.set = function (key, value) {
HostStore.prototype.createStream = function () {
var dnode = Dnode({
- // update: this._didUpdate.bind(this),
+ update: this._didUpdate.bind(this),
})
dnode.on('remote', this._didConnect.bind(this))
return dnode