-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
19 lines (18 loc) · 858 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
document.addEventListener("DOMContentLoaded", () => {
const inputField = document.querySelector(".key-handler input");
const saveButton = document.querySelector(".key-handler button");
saveButton.addEventListener("click", () => {
const apiKey = inputField.value.trim();
if (apiKey && apiKey.length > 10) {
chrome.storage.local.set({ az_ai_apikey: apiKey }, () => {
const messageContainer = document.querySelector(".success-message");
messageContainer.textContent =
"API Key saved! Chat now by clicking the AI Help icon or using the Keyboard shortcut (Alt+A).";
messageContainer.style.display = "block";
inputField.value = "";
});
} else {
alert("Please enter a valid API key.");
}
});
});