aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-04-27 04:10:26 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-04-27 04:10:26 +0200
commit5825e7b476eb4df8590c9f0646109b2fb64ab6a3 (patch)
treef63b2e4622a258bf1575e536ce5ad75c9078f36b
parent0a1b775b480f417bc1250c68094f99d603f42794 (diff)
downloadwallet-core-5825e7b476eb4df8590c9f0646109b2fb64ab6a3.tar.xz
fix #4474
-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);