aboutsummaryrefslogtreecommitdiff
path: root/src/options
diff options
context:
space:
mode:
Diffstat (limited to 'src/options')
-rw-r--r--src/options/options.html35
-rw-r--r--src/options/options.ts27
2 files changed, 62 insertions, 0 deletions
diff --git a/src/options/options.html b/src/options/options.html
new file mode 100644
index 0000000..bf70f4c
--- /dev/null
+++ b/src/options/options.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>AI Compose Settings</title>
+ <style>
+ body {
+ font-family: sans-serif;
+ padding: 10px;
+ }
+ label {
+ display: block;
+ margin: 10px 0 4px;
+ }
+ input {
+ width: 100%;
+ padding: 6px;
+ }
+ button {
+ margin-top: 10px;
+ padding: 6px 12px;
+ }
+ </style>
+ </head>
+ <body>
+ <h2>Settings</h2>
+ <label>Proxy Endpoint <input id="endpoint" type="url" /></label>
+ <label>Auth Token <input id="token" type="text" /></label>
+ <button id="save">Save</button>
+ <p id="msg"></p>
+
+ <script src="../browser-polyfill.js"></script>
+ <script src="options.js"></script>
+ </body>
+</html>
diff --git a/src/options/options.ts b/src/options/options.ts
new file mode 100644
index 0000000..8574ab8
--- /dev/null
+++ b/src/options/options.ts
@@ -0,0 +1,27 @@
+type Settings = {
+ proxyEndpoint?: string;
+ proxyToken?: string;
+};
+
+const endpointInput: HTMLInputElement = document.getElementById("endpoint") as HTMLInputElement;
+const tokenInput: HTMLInputElement = document.getElementById("token") as HTMLInputElement;
+const saveBtn: HTMLButtonElement = document.getElementById("save") as HTMLButtonElement;
+const msg: HTMLElement = document.getElementById("msg") as HTMLElement;
+
+async function loadSettings(): Promise<void> {
+ const settings: Settings = await browser.storage.local.get(["proxyEndpoint", "proxyToken"]);
+ endpointInput.value = settings.proxyEndpoint ?? "";
+ tokenInput.value = settings.proxyToken ?? "";
+}
+
+async function saveSettings(): Promise<void> {
+ await browser.storage.local.set({
+ proxyEndpoint: endpointInput.value.trim(),
+ proxyToken: tokenInput.value.trim(),
+ });
+ msg.textContent = "Saved!";
+ setTimeout(() => (msg.textContent = ""), 2000);
+}
+
+saveBtn.addEventListener("click", saveSettings);
+loadSettings();