diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/api/browser.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/api/browser.ts | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/packages/taler-wallet-webextension/src/api/browser.ts b/packages/taler-wallet-webextension/src/api/browser.ts deleted file mode 100644 index b69a49680..000000000 --- a/packages/taler-wallet-webextension/src/api/browser.ts +++ /dev/null @@ -1,54 +0,0 @@ -function searchForTalerLinks(): string | undefined { - let found; - found = document.querySelector("a[href^='taler://'") - if (found) return found.toString() - found = document.querySelector("a[href^='taler+http://'") - if (found) return found.toString() - return undefined -} - -async function getCurrentTab() { - let queryOptions = { active: true, currentWindow: true }; - let [tab] = await chrome.tabs.query(queryOptions); - return tab; -} - - - -export async function findTalerUriInActiveTab(): Promise<string | undefined> { - if (chrome.runtime.getManifest().manifest_version === 3) { - // manifest v3 - const tab = await getCurrentTab(); - const res = await chrome.scripting.executeScript({ - target: { - tabId: tab.id!, - allFrames: true, - } as any, - func: searchForTalerLinks, - args: [] - }) - return res[0].result - } - return new Promise((resolve, reject) => { - //manifest v2 - 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]); - }, - ); - }); -} |