aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2015-08-02 07:33:31 +0800
committerkumavis <aaron@kumavis.me>2015-08-02 07:33:31 +0800
commitcc1bb92f9d842f4d8a757358bf31c5de6c32592d (patch)
tree14f304d3e144925a7d80e82810f35c774470996d /app/scripts/background.js
parent3e2e90a4fa2f38fcbe74a242450b822d579cc3c0 (diff)
downloadtangerine-wallet-browser-cc1bb92f9d842f4d8a757358bf31c5de6c32592d.tar
tangerine-wallet-browser-cc1bb92f9d842f4d8a757358bf31c5de6c32592d.tar.gz
tangerine-wallet-browser-cc1bb92f9d842f4d8a757358bf31c5de6c32592d.tar.bz2
tangerine-wallet-browser-cc1bb92f9d842f4d8a757358bf31c5de6c32592d.tar.lz
tangerine-wallet-browser-cc1bb92f9d842f4d8a757358bf31c5de6c32592d.tar.xz
tangerine-wallet-browser-cc1bb92f9d842f4d8a757358bf31c5de6c32592d.tar.zst
tangerine-wallet-browser-cc1bb92f9d842f4d8a757358bf31c5de6c32592d.zip
build overhaul + basic structure
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js44
1 files changed, 38 insertions, 6 deletions
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