-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions.js
More file actions
49 lines (41 loc) · 1.54 KB
/
options.js
File metadata and controls
49 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('settingsForm');
const apiKeyInput = document.getElementById('apiKey');
const modelInput = document.getElementById('model');
const promptInput = document.getElementById('prompt');
const debugModeInput = document.getElementById('debugMode');
const notification = document.getElementById('notification');
// Load saved settings
loadSettings();
form.addEventListener('submit', handleSave);
async function loadSettings() {
chrome.storage.sync.get(['apiKey', 'model', 'prompt', 'debugMode'], (result) => {
apiKeyInput.value = result.apiKey || '';
modelInput.value = result.model || 'google/gemini-2.5-flash';
promptInput.value = result.prompt || 'turn the image into a csv. only return a csv.';
debugModeInput.checked = result.debugMode || false;
});
}
async function handleSave(event) {
event.preventDefault();
const settings = {
apiKey: apiKeyInput.value.trim(),
model: modelInput.value.trim() || 'google/gemini-2.5-flash',
prompt: promptInput.value.trim() || 'turn the image into a csv. only return a csv.',
debugMode: debugModeInput.checked
};
if (!settings.apiKey) {
alert('API Key is required');
return;
}
chrome.storage.sync.set(settings, () => {
showNotification();
});
}
function showNotification() {
notification.style.display = 'block';
setTimeout(() => {
notification.style.display = 'none';
}, 3000);
}
});