-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpopup.js
36 lines (30 loc) · 1.3 KB
/
popup.js
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
const apiKeyInput = document.getElementById('apiKeyInput');
const signatureDelimiterInput = document.getElementById('signatureDelimiter');
const editApiKeyButton = document.getElementById('editApiKeyButton');
const saveButton = document.getElementById('saveButton');
saveButton.addEventListener("click", () => {
const apiKey = apiKeyInput.value;
const signatureDelimiter = signatureDelimiterInput.value;
chrome.storage.sync.set({ apiKey, signatureDelimiter }, () => {
alert("API key and signature delimiter saved.");
apiKeyInput.readOnly = true;
apiKeyInput.type = 'password';
});
});
document.getElementById("reviewButton").addEventListener("click", () => {
const selectedStyles = Array.from(document.querySelectorAll('input[name="style"]:checked')).map(input => input.value);
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
chrome.tabs.sendMessage(tabs[0].id, { action: "reviewEmail", styles: selectedStyles });
});
});
chrome.storage.sync.get(["apiKey", "signatureDelimiter"], result => {
apiKeyInput.value = result.apiKey || '';
if (result.signatureDelimiter) {
signatureDelimiterInput.value = result.signatureDelimiter;
}
});
editApiKeyButton.addEventListener('click', () => {
apiKeyInput.readOnly = false;
apiKeyInput.type = 'text';
apiKeyInput.focus();
});