use ContextualIdentityService to populate popup
This commit is contained in:
Родитель
5b753dc146
Коммит
059b4bcaf9
|
@ -1,2 +1,3 @@
|
|||
node_modules
|
||||
README.html
|
||||
*.xpi
|
||||
|
|
5
index.js
5
index.js
|
@ -1,10 +1,11 @@
|
|||
const webExtension = require('sdk/webextension');
|
||||
const {ContextualIdentityService} = require('resource://gre/modules/ContextualIdentityService.jsm');
|
||||
|
||||
function handleWebExtensionMessage(message, sender, sendReply) {
|
||||
console.log(message);
|
||||
if (message === 'message-from-webextension') {
|
||||
if (message === 'get-identities') {
|
||||
sendReply({
|
||||
content: 'reply-from-sdk'
|
||||
content: {identities: ContextualIdentityService.getIdentities()}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
browser.runtime.sendMessage('message-from-webextension').then(reply=> {
|
||||
browser.runtime.sendMessage('get-identities').then(reply=> {
|
||||
if (reply) {
|
||||
reply.content.identities.forEach(identity=> {
|
||||
document.querySelector('.identities-list').innerHTML += `<li><a href="#">${identity.icon}</a></li>`;
|
||||
});
|
||||
console.log('response from sdk addon: ', reply.content);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,11 +5,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>Containers!</h1>
|
||||
<ul>
|
||||
<li><a href="#">Personal</a></li>
|
||||
<li><a href="#">Work</a></li>
|
||||
<li><a href="#">Banking</a></li>
|
||||
<li><a href="#">Shopping</a></li>
|
||||
<ul class="identities-list">
|
||||
</ul>
|
||||
<h3><a href="#">Edit Containers</a></h3>
|
||||
<script src="js/popup.js"></script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче