setup popup button title

This commit is contained in:
ivan grachev 2023-10-23 18:33:34 +03:00
parent df03689a4a
commit 10d8579309

View File

@ -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;