aboutsummaryrefslogtreecommitdiff
path: root/content_scripts/notify.ts
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-05-08 10:27:26 +0200
committerChristian Grothoff <christian@grothoff.org>2016-05-08 10:27:26 +0200
commit2c90c1e9037455415f3a56fcfdb1e02283d4ee2c (patch)
treecdf22461eff3106df555bb4e9ac3ad2f633505c4 /content_scripts/notify.ts
parent12a12d883aae49a9dcedc8b487121b9926cff0fa (diff)
parentdc83b85e85110eb7ed2e96ecdbcbb90b5a5620aa (diff)
Merge branch 'master' of git+ssh://taler.net/var/git/wallet-webex
Diffstat (limited to 'content_scripts/notify.ts')
-rw-r--r--content_scripts/notify.ts35
1 files changed, 21 insertions, 14 deletions
diff --git a/content_scripts/notify.ts b/content_scripts/notify.ts
index 06ea2e92e..8e70b44c4 100644
--- a/content_scripts/notify.ts
+++ b/content_scripts/notify.ts
@@ -33,10 +33,6 @@ namespace TalerNotify {
console.log("Taler injected", chrome.runtime.id);
- // FIXME: only do this for test wallets?
- // This is no security risk, since the extension ID for published
- // extension is publicly known.
-
function subst(url: string, H_contract) {
url = url.replace("${H_contract}", H_contract);
url = url.replace("${$}", "$");
@@ -45,17 +41,28 @@ namespace TalerNotify {
const handlers = [];
- // Hack to know when the extension is unloaded
- let port = chrome.runtime.connect();
-
- port.onDisconnect.addListener(() => {
- console.log("chrome runtime disconnected, removing handlers");
- for (let handler of handlers) {
- document.removeEventListener(handler.type, handler.listener);
- }
- });
+ function init() {
+ chrome.runtime.sendMessage({type: "ping"}, () => {
+ if (chrome.runtime.lastError) {
+ console.log("extension not yet ready");
+ window.setTimeout(init, 200);
+ return;
+ }
+ console.log("got pong");
+ registerHandlers();
+ // Hack to know when the extension is unloaded
+ let port = chrome.runtime.connect();
+
+ port.onDisconnect.addListener(() => {
+ console.log("chrome runtime disconnected, removing handlers");
+ for (let handler of handlers) {
+ document.removeEventListener(handler.type, handler.listener);
+ }
+ });
+ });
+ }
- registerHandlers();
+ init();
function registerHandlers() {
const $ = (x) => document.getElementById(x);