tokenary/Safari macOS/Resources/background.js

20 lines
765 B
JavaScript
Raw Normal View History

browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
2021-11-22 13:11:34 +03:00
if (request.subject === "process-inpage-message") {
2021-11-30 15:56:00 +03:00
browser.runtime.sendNativeMessage("mac.tokenary.io", request.message, function(response) {
2021-11-22 13:11:34 +03:00
sendResponse(response)
});
}
return true;
});
2021-11-25 13:00:28 +03:00
browser.browserAction.onClicked.addListener(function(tab) {
const id = new Date().getTime() + Math.floor(Math.random() * 1000);
const request = {id: id, name: "switchAccount", object: {}, address: ""};
2021-11-28 15:19:04 +03:00
// TODO: pass current network id
// TODO: pass favicon
2021-11-28 12:15:16 +03:00
// TODO: pass host here as well
2021-11-30 15:56:00 +03:00
browser.runtime.sendNativeMessage("mac.tokenary.io", request, function(response) {
2021-11-25 13:00:28 +03:00
browser.tabs.sendMessage(tab.id, response);
});
});