aboutsummaryrefslogtreecommitdiff
path: root/content_scripts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-18 01:16:31 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-18 01:16:31 +0200
commit89c3c2d58d1a7102a10edfb716cbc7434d0bc117 (patch)
treee5a81fbc118a7ae95e92dea2b653d26301c57bc1 /content_scripts
parent78ea2ba5b110bc36d8625a1dd524257906788552 (diff)
make db layer more type safe
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/notify.ts21
1 files changed, 14 insertions, 7 deletions
diff --git a/content_scripts/notify.ts b/content_scripts/notify.ts
index 959c0e557..3b7b231c3 100644
--- a/content_scripts/notify.ts
+++ b/content_scripts/notify.ts
@@ -34,6 +34,13 @@ declare var cloneInto: any;
namespace TalerNotify {
const PROTOCOL_VERSION = 1;
+ let logVerbose: boolean = false;
+ try {
+ logVerbose = !!localStorage.getItem("taler-log-verbose");
+ } catch (e) {
+ // can't read from local storage
+ }
+
if (!taler) {
console.error("Taler wallet lib not included, HTTP 402 payments not" +
" supported");
@@ -98,7 +105,7 @@ namespace TalerNotify {
function init() {
chrome.runtime.sendMessage({type: "get-tab-cookie"}, (resp) => {
if (chrome.runtime.lastError) {
- console.log("extension not yet ready");
+ logVerbose && console.log("extension not yet ready");
window.setTimeout(init, 200);
return;
}
@@ -107,19 +114,19 @@ namespace TalerNotify {
let port = chrome.runtime.connect();
port.onDisconnect.addListener(() => {
- console.log("chrome runtime disconnected, removing handlers");
+ logVerbose && console.log("chrome runtime disconnected, removing handlers");
for (let handler of handlers) {
document.removeEventListener(handler.type, handler.listener);
}
});
if (resp && resp.type === "fetch") {
- console.log("it's fetch");
+ logVerbose && console.log("it's fetch");
taler.internalOfferContractFrom(resp.contractUrl);
document.documentElement.style.visibility = "hidden";
} else if (resp && resp.type === "execute") {
- console.log("it's execute");
+ logVerbose && console.log("it's execute");
document.documentElement.style.visibility = "hidden";
taler.internalExecutePayment(resp.contractHash,
resp.payUrl,
@@ -128,7 +135,7 @@ namespace TalerNotify {
});
}
- console.log("loading Taler content script");
+ logVerbose && console.log("loading Taler content script");
init();
interface HandlerFn {
@@ -238,7 +245,7 @@ namespace TalerNotify {
}
if (resp.isRepurchase) {
- console.log("doing repurchase");
+ logVerbose && console.log("doing repurchase");
console.assert(resp.existingFulfillmentUrl);
console.assert(resp.existingContractHash);
window.location.href = subst(resp.existingFulfillmentUrl,
@@ -296,7 +303,7 @@ namespace TalerNotify {
console.error("H_contract missing in taler-payment-succeeded");
return;
}
- console.log("got taler-payment-succeeded");
+ logVerbose && console.log("got taler-payment-succeeded");
const walletMsg = {
type: "payment-succeeded",
detail: {