From 9f8139e09b21ec12f9b9ba4926ea80557698c559 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 4 Jan 2022 17:06:17 -0300 Subject: replace jest with mocha --- .../taler-wallet-webextension/src/api/browser.ts | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 packages/taler-wallet-webextension/src/api/browser.ts (limited to 'packages/taler-wallet-webextension/src/api') diff --git a/packages/taler-wallet-webextension/src/api/browser.ts b/packages/taler-wallet-webextension/src/api/browser.ts new file mode 100644 index 000000000..bc50853fb --- /dev/null +++ b/packages/taler-wallet-webextension/src/api/browser.ts @@ -0,0 +1,24 @@ + +export async function findTalerUriInActiveTab(): Promise { + return new Promise((resolve, reject) => { + chrome.tabs.executeScript( + { + code: ` + (() => { + let x = document.querySelector("a[href^='taler://'") || document.querySelector("a[href^='taler+http://'"); + return x ? x.href.toString() : null; + })(); + `, + allFrames: false, + }, + (result) => { + if (chrome.runtime.lastError) { + console.error(chrome.runtime.lastError); + resolve(undefined); + return; + } + resolve(result[0]); + }, + ); + }); +} -- cgit v1.2.3