gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 02/04: fix redirection


From: gnunet
Subject: [taler-wallet-core] 02/04: fix redirection
Date: Fri, 01 May 2020 10:47:47 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

commit e52e1fab864ef5826c88da447109f341b6c09715
Author: Florian Dold <address@hidden>
AuthorDate: Thu Apr 30 18:01:04 2020 +0530

    fix redirection
---
 src/webex/wxBackend.ts | 102 +++----------------------------------------------
 1 file changed, 5 insertions(+), 97 deletions(-)

diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 8fbb1431..6bd87b45 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -379,6 +379,8 @@ function makeSyncWalletRedirect(
     };
     doit();
   }
+  console.log("redirecting to", innerUrl.href);
+  chrome.tabs.update(tabId, { url: innerUrl.href });
   return { redirectUrl: innerUrl.href };
 }
 
@@ -463,101 +465,6 @@ export async function wxMain(): Promise<void> {
     console.log("update available:", details);
     chrome.runtime.reload();
   });
-
-  chrome.tabs.query({}, (tabs) => {
-    console.log("got tabs", tabs);
-    for (const tab of tabs) {
-      if (!tab.url || !tab.id) {
-        continue;
-      }
-      const uri = new URL(tab.url);
-      if (uri.protocol !== "http:" && uri.protocol !== "https:") {
-        continue;
-      }
-      console.log(
-        "injecting into existing tab",
-        tab.id,
-        "with url",
-        uri.href,
-        "protocol",
-        uri.protocol,
-      );
-      injectScript(
-        tab.id,
-        { file: "/dist/contentScript-bundle.js", runAt: "document_start" },
-        uri.href,
-      );
-      const code = `
-        if (("taler" in window) || 
document.documentElement.getAttribute("data-taler-nojs")) {
-          document.dispatchEvent(new Event("taler-probe-result"));
-        }
-      `;
-      injectScript(tab.id, { code, runAt: "document_start" }, uri.href);
-    }
-  });
-
-  const tabTimers: { [n: number]: number[] } = {};
-
-  chrome.tabs.onRemoved.addListener((tabId, changeInfo) => {
-    const tt = tabTimers[tabId] || [];
-    const bgPage = chrome.extension.getBackgroundPage();
-    if (!bgPage) {
-      console.error("background page unavailable");
-      return;
-    }
-    for (const t of tt) {
-      bgPage.clearTimeout(t);
-    }
-  });
-  chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
-    if (changeInfo.status !== "complete") {
-      return;
-    }
-    const timers: number[] = [];
-
-    const run = (): void => {
-      timers.shift();
-      chrome.tabs.get(tabId, (tab) => {
-        if (chrome.runtime.lastError) {
-          return;
-        }
-        if (!tab.url || !tab.id) {
-          return;
-        }
-        const uri = new URL(tab.url);
-        if (!(uri.protocol === "http:" || uri.protocol === "https:")) {
-          return;
-        }
-        const code = `
-          if (("taler" in window) || 
document.documentElement.getAttribute("data-taler-nojs")) {
-            document.dispatchEvent(new Event("taler-probe-result"));
-          }
-        `;
-        injectScript(tab.id, { code, runAt: "document_start" }, uri.href);
-      });
-    };
-
-    const addRun = (dt: number): void => {
-      const bgPage = chrome.extension.getBackgroundPage();
-      if (!bgPage) {
-        console.error("no background page");
-        return;
-      }
-      const id = bgPage.setTimeout(run, dt);
-      timers.push(id);
-    };
-
-    addRun(0);
-    addRun(50);
-    addRun(300);
-    addRun(1000);
-    addRun(2000);
-    addRun(4000);
-    addRun(8000);
-    addRun(16000);
-    tabTimers[tabId] = timers;
-  });
-
   reinitWallet();
 
   // Handlers for messages coming directly from the content
@@ -573,6 +480,7 @@ export async function wxMain(): Promise<void> {
       const wallet = currentWallet;
       if (!wallet) {
         console.warn("wallet not available while handling header");
+        return;
       }
       if (details.statusCode === 402 || details.statusCode === 202) {
         console.log(`got 402/202 from ${details.url}`);
@@ -636,9 +544,9 @@ export async function wxMain(): Promise<void> {
           }
         }
       }
-      return {};
+      return;
     },
-    { urls: ["<all_urls>"] },
+    { urls: ["https://*/*";, "http://*/*";] },
     ["responseHeaders", "blocking"],
   );
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]