diff --git a/Safari iOS/Resources/popup.js b/Safari iOS/Resources/popup.js index 1831e89b..3e84ff07 100644 --- a/Safari iOS/Resources/popup.js +++ b/Safari iOS/Resources/popup.js @@ -1,9 +1,9 @@ // Copyright © 2023 Tokenary. All rights reserved. const button = document.getElementById('tokenary-button'); +const message = browser.extension.getBackgroundPage().sharedData; button.addEventListener('click', () => { - const message = browser.extension.getBackgroundPage().sharedData; const query = encodeURIComponent(JSON.stringify(message)) + '";'; browser.tabs.executeScript({ code: 'window.location.href = "https://tokenary.io/extension?query=' + query @@ -14,5 +14,32 @@ button.addEventListener('click', () => { }, 200); }); -// TODO: set title depending on a request -button.innerText = "proceed in tokenary"; +var title = "proceed\nin tokenary"; +switch (message.name) { + case "signPersonalMessage": + case "signMessage": + case "signTypedMessage": + title = "sign message\nin the app"; + break; + case "signTransaction": + case "signAndSendTransactions": + case "signAllTransactions": + case "signAndSendTransaction": + title = "approve transaction\nin the app"; + break; + case "requestAccounts": + case "signIn": + case "connect": + title = "connect"; + break; + case "switchAccount": + const latestConfigurations = message.body.latestConfigurations; + if (Array.isArray(latestConfigurations) && latestConfigurations.length) { + title = "switch\naccount"; + } else { + title = "connect\ntokenary"; + } + break; +} + +button.innerText = title;