mirror of
https://github.com/lil-org/tokenary.git
synced 2024-11-22 21:49:51 +03:00
setup popup button title
This commit is contained in:
parent
df03689a4a
commit
10d8579309
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user