Verifying simple script messaging.

This commit is contained in:
Ryan Breen
2023-01-23 23:21:17 -05:00
parent 25da1d0cab
commit 03af8e71ad
3 changed files with 21 additions and 2 deletions

View File

@@ -10,7 +10,8 @@ const storage = browser.storage.local;
browser.runtime.onInstalled.addListener(async ({ reason }) => {
// I would like to be able to skip this for development purposes
let ignoreHook = (await storage.get('ignoreInstallHook')).ignoreInstallHook;
let ignoreHook = (await storage.get({ ignoreInstallHook: false }))
.ignoreInstallHook;
if (ignoreHook === true) {
return;
}

View File

@@ -11,7 +11,13 @@
<body x-data="options" class="text-fuchsia-900 bg-fuchsia-400">
<h1 class="text-6xl font-bold">Settings</h1>
<p x-text="msg"></p>
<select x-model.number="profileIndex" name="profiles" id="profiles">
<template x-for="(profileName, index) in profileNames" :key="profileName">
<option x-text="profileName" :value="index"></option>
</template>
</select>
</body>
</html>

View File

@@ -2,6 +2,18 @@ import Alpine from 'alpinejs';
Alpine.data('options', () => ({
msg: 'Hello world!',
profileNames: ['Default'],
profileIndex: 0,
async init() {
await this.getProfileNames();
},
async getProfileNames() {
this.profileNames = await browser.runtime.sendMessage({
kind: 'getProfileNames',
});
},
}));
Alpine.start();