diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/api')
-rw-r--r-- | packages/taler-wallet-webextension/src/api/browser.ts | 24 |
1 files changed, 24 insertions, 0 deletions
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<string | undefined> { + 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]); + }, + ); + }); +} |