-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
35 lines (31 loc) · 1.13 KB
/
options.js
File metadata and controls
35 lines (31 loc) · 1.13 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
// options.js
document.addEventListener('DOMContentLoaded', function() {
const anthropicApiKeyInput = document.getElementById('anthropicApiKey');
const openaiApiKeyInput = document.getElementById('openaiApiKey');
const saveButton = document.getElementById('saveBtn');
const statusDiv = document.getElementById('status');
// Load saved API keys
chrome.storage.local.get(['anthropicApiKey', 'openaiApiKey'], function(result) {
if (result.anthropicApiKey) {
anthropicApiKeyInput.value = result.anthropicApiKey;
}
if (result.openaiApiKey) {
openaiApiKeyInput.value = result.openaiApiKey;
}
});
// Save API keys
saveButton.addEventListener('click', function() {
const anthropicApiKey = anthropicApiKeyInput.value.trim();
const openaiApiKey = openaiApiKeyInput.value.trim();
chrome.storage.local.set({
anthropicApiKey: anthropicApiKey,
openaiApiKey: openaiApiKey
}, function() {
statusDiv.textContent = 'API keys saved successfully!';
statusDiv.style.color = 'green';
setTimeout(() => {
statusDiv.textContent = '';
}, 3000);
});
});
});