diff options
build overhaul + basic structure
Diffstat (limited to 'app')
-rw-r--r-- | app/.DS_Store | bin | 6148 -> 6148 bytes | |||
-rw-r--r-- | app/manifest.json | 8 | ||||
-rw-r--r-- | app/popup.html | 25 | ||||
-rw-r--r-- | app/scripts/background.js | 44 | ||||
-rw-r--r-- | app/scripts/contentscript.js | 15 | ||||
-rw-r--r-- | app/scripts/inpage.js | 15 | ||||
-rw-r--r-- | app/scripts/lib/metamask-provider.js (renamed from app/scripts/metamask-provider.js) | 0 | ||||
-rw-r--r-- | app/scripts/popup.js | 3 | ||||
-rw-r--r-- | app/scripts/web3.js | 14 |
9 files changed, 71 insertions, 53 deletions
diff --git a/app/.DS_Store b/app/.DS_Store Binary files differindex 9f45b9329..817a0eb72 100644 --- a/app/.DS_Store +++ b/app/.DS_Store diff --git a/app/manifest.json b/app/manifest.json index bc7518691..3a5456cce 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,6 +1,6 @@ { "name": "__MSG_appName__", - "version": "0.0.17", + "version": "0.0.49", "manifest_version": 2, "description": "__MSG_appDescription__", "icons": { @@ -19,8 +19,7 @@ "19": "images/icon-19.png", "38": "images/icon-38.png" }, - "default_title": "metamask", - "default_popup": "popup.html" + "default_title": "metamask" }, "content_scripts": [ { @@ -35,6 +34,9 @@ "all_frames": false } ], + "permissions": [ + "storage" + ], "web_accessible_resources": [ "scripts/web3.js" ] diff --git a/app/popup.html b/app/popup.html deleted file mode 100644 index bc8b6411b..000000000 --- a/app/popup.html +++ /dev/null @@ -1,25 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <!-- build:css styles/vendor.css --> - <!-- bower:css --> - <!-- endbower --> - <!-- endbuild --> - <!-- build:css styles/main.css --> - <link href="styles/main.css" rel="stylesheet"> - <!-- endbuild --> - </head> - <body> - <h1>'Allo, 'Allo!</h1> - - <!-- build:js scripts/vendor.js --> - <!-- bower:js --> - <!-- endbower --> - <!-- endbuild --> - - <!-- build:js scripts/popup.js --> - <script src="scripts/popup.js"></script> - <!-- endbuild --> - </body> -</html> diff --git a/app/scripts/background.js b/app/scripts/background.js index 87a27d0db..1557814b4 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -1,9 +1,41 @@ -'use strict'; +const web3 = require('web3') -chrome.runtime.onInstalled.addListener(function (details) { - console.log('previousVersion', details.previousVersion); -}); +const identitiesUrl = 'https://alpha.metamask.io/identities/' +const messagingChannelName = 'metamask' -chrome.browserAction.setBadgeText({text: '2'}); -console.log('\'Allo \'Allo! Event Page for Browser Action'); +// setup badge click handler +chrome.browserAction.onClicked.addListener(function(activeTab) { + chrome.tabs.create({ url: identitiesUrl }) +}) + +// setup page<->plugin messaging +chrome.runtime.onConnect.addListener(function(port) { + console.assert(port.name == messagingChannelName) + port.onMessage.addListener(function(msg) { + console.log(msg) + port.postMessage({answer: 'Madame'}) + }) +}) + +// update badge text +chrome.browserAction.setBadgeText({text: '2'}) + +// listen to storage changes +chrome.storage.onChanged.addListener(function(changes, namespace) { + for (key in changes) { + var storageChange = changes[key] + console.log('Storage key "%s" in namespace "%s" changed. ' + + 'Old value was "%s", new value is "%s".', + key, + namespace, + storageChange.oldValue, + storageChange.newValue) + } +}) + +// Save it using the Chrome extension storage API. +chrome.storage.sync.set({'zzz': 22}, function() { + // Notify that we saved. + console.log('Settings saved') +})
\ No newline at end of file diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 23df227b4..2e50ae3a5 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -1,5 +1,16 @@ +const web3 = require('web3') + +// inject script tag var scriptTag = document.createElement('script') scriptTag.src = chrome.extension.getURL('scripts/web3.js') - scriptTag.onload = function() { debugger; this.parentNode.removeChild(this) } -;(document.head||document.documentElement).appendChild(scriptTag) +var container = document.head || document.documentElement +container.appendChild(scriptTag) + +// listen for messages +var port = chrome.runtime.connect({name: 'metamask'}) +port.postMessage({joke: 'Knock knock'}) +port.onMessage.addListener(function(msg) { + console.log(msg) + // port.postMessage({answer: 'Madame'}) +})
\ No newline at end of file diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js new file mode 100644 index 000000000..02bf226cb --- /dev/null +++ b/app/scripts/inpage.js @@ -0,0 +1,15 @@ +const web3 = require('web3') +const MetamaskProvider = require('./lib/metamask-provider.js') + +const rpcUrl = 'https://rpc.metamask.io' + + +var provider = new MetamaskProvider(forwardPayload, rpcUrl) +web3.setProvider(provider) + +// injecting web3 +window.web3 = web3 + +function forwardPayload(){ + debugger +}
\ No newline at end of file diff --git a/app/scripts/metamask-provider.js b/app/scripts/lib/metamask-provider.js index c52de82b4..c52de82b4 100644 --- a/app/scripts/metamask-provider.js +++ b/app/scripts/lib/metamask-provider.js diff --git a/app/scripts/popup.js b/app/scripts/popup.js deleted file mode 100644 index 815abcb42..000000000 --- a/app/scripts/popup.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log('\'Allo \'Allo! Popup'); diff --git a/app/scripts/web3.js b/app/scripts/web3.js deleted file mode 100644 index f0fec7b06..000000000 --- a/app/scripts/web3.js +++ /dev/null @@ -1,14 +0,0 @@ -const web3 = require('web3') -const MetamaskProvider = require('./metamask-provider.js') - - -var provider = new MetamaskProvider(forwardPayload, 'https://rpc.metamask.io') -web3.setProvider(provider) - -console.log('injecting web3....') -window.web3 = web3 - - -function forwardPayload(){ - debugger -}
\ No newline at end of file |