-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
48 lines (40 loc) · 1.54 KB
/
popup.js
File metadata and controls
48 lines (40 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
const keyEl = document.getElementById('key');
const promptEl = document.getElementById('prompt');
const okEl = document.getElementById('ok');
const errEl = document.getElementById('err');
// Default prompt based on clear communication principles
const DEFAULT_PROMPT = `Rewrite this email to be clear, concise, and professional while preserving the sender's voice and intent.
Guidelines:
- Use active voice and direct language
- Remove unnecessary words and corporate jargon
- Keep sentences short and scannable
- Maintain the original tone (casual stays casual, formal stays formal)
- Preserve all key facts and action items
- Do not add new information or change meaning
- Return ONLY the rewritten email body, no meta-commentary`;
(async function init() {
const { modelApiKey, systemPrompt } = await chrome.storage.local.get(['modelApiKey', 'systemPrompt']);
if (modelApiKey) keyEl.value = modelApiKey;
promptEl.value = systemPrompt || DEFAULT_PROMPT;
})();
function showOk() {
errEl.style.display = 'none';
okEl.style.display = 'block';
setTimeout(() => window.close(), 450);
}
function showErr(msg) {
okEl.style.display = 'none';
errEl.textContent = msg;
errEl.style.display = 'block';
}
document.getElementById('save').onclick = async () => {
const key = keyEl.value.trim();
if (!key) return showErr('Paste an API key first.');
const prompt = promptEl.value.trim();
if (!prompt) return showErr('System prompt cannot be empty.');
await chrome.storage.local.set({
modelApiKey: key,
systemPrompt: prompt
});
showOk();
};