diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts index 17e5215f4..7966bbe25 100644 --- a/src/webex/wxBackend.ts +++ b/src/webex/wxBackend.ts @@ -498,6 +498,7 @@ try { function headerListener( details: chrome.webRequest.WebResponseHeadersDetails, ): chrome.webRequest.BlockingResponse | undefined { + console.log("header listener"); if (chrome.runtime.lastError) { console.error(chrome.runtime.lastError); return; @@ -507,6 +508,7 @@ function headerListener( console.warn("wallet not available while handling header"); return; } + console.log("in header listener"); if (details.statusCode === 402 || details.statusCode === 202) { console.log(`got 402/202 from ${details.url}`); for (const header of details.responseHeaders || []) { @@ -572,12 +574,29 @@ function headerListener( } function setupHeaderListener(): void { + console.log("setting up header listener"); // Handlers for catching HTTP requests - chrome.webRequest.onHeadersReceived.addListener( - headerListener, - { urls: ["https://*/*", "http://*/*"] }, - ["responseHeaders", "blocking"], - ); + chrome.permissions.contains(extendedPermissions, (result: boolean) => { + if ( + chrome.webRequest.onHeadersReceived && + chrome.webRequest.onHeadersReceived.hasListener(headerListener) + ) { + chrome.webRequest.onHeadersReceived.removeListener(headerListener); + } + if (result) { + console.log("actually adding listener"); + chrome.webRequest.onHeadersReceived.addListener( + headerListener, + { urls: [""] }, + ["responseHeaders", "blocking"], + ); + } + chrome.webRequest.handlerBehaviorChanged(() => { + if (chrome.runtime.lastError) { + console.error(chrome.runtime.lastError); + } + }); + }); } /** @@ -602,4 +621,12 @@ export async function wxMain(): Promise { }); setupHeaderListener(); + + chrome.permissions.onAdded.addListener((perm) => { + if (chrome.runtime.lastError) { + console.error(chrome.runtime.lastError); + return; + } + setupHeaderListener(); + }); } diff --git a/webextension/manifest.json b/webextension/manifest.json index 7592b3509..120d008c7 100644 --- a/webextension/manifest.json +++ b/webextension/manifest.json @@ -4,8 +4,8 @@ "name": "GNU Taler Wallet (git)", "description": "Privacy preserving and transparent payments", "author": "GNU Taler Developers", - "version": "0.6.75", - "version_name": "0.6.0pre10", + "version": "0.6.77.1", + "version_name": "0.7.0.dev.1", "minimum_chrome_version": "51", "minimum_opera_version": "36",