-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathoptions.js
More file actions
34 lines (29 loc) · 1.06 KB
/
Copy pathoptions.js
File metadata and controls
34 lines (29 loc) · 1.06 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
document.addEventListener("DOMContentLoaded", () => {
// Load saved API key if it exists
chrome.storage.sync.get(["geminiApiKey"], (result) => {
if (result.geminiApiKey) {
document.getElementById("api-key").value = result.geminiApiKey;
}
});
// Save API key when button is clicked
document.getElementById("save-button").addEventListener("click", () => {
const apiKey = document.getElementById("api-key").value.trim();
if (apiKey) {
chrome.storage.sync.set({ geminiApiKey: apiKey }, () => {
const successMessage = document.getElementById("success-message");
successMessage.style.display = "block";
// Close the tab after a short delay
setTimeout(() => {
// Try to close the window directly
window.close();
// Fallback for Chrome Extensions to close tab
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs[0]) {
chrome.tabs.remove(tabs[0].id);
}
});
}, 1000);
});
}
});
});