forked from iSegaro/Gemini-Translate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
32 lines (29 loc) · 1.01 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
// popup.js
// Section for restoring the original text
document.getElementById("restore").addEventListener("click", () => {
chrome.scripting.executeScript({
target: { allFrames: true },
function: () => {
document.querySelectorAll("[data-original-text]").forEach((element) => {
element.innerText = element.dataset.originalText;
delete element.dataset.originalText;
});
},
});
});
// Section for API Key management
document.addEventListener("DOMContentLoaded", () => {
// Retrieve the saved key (if it exists)
chrome.storage.sync.get("apiKey", (data) => {
if (data.apiKey) {
document.getElementById("apiKey").value = data.apiKey;
}
});
});
document.getElementById("saveApiKey").addEventListener("click", () => {
const apiKey = document.getElementById("apiKey").value.trim();
chrome.storage.sync.set({ apiKey }, () => {
console.log("API key saved:", apiKey);
// You can display a success message to the user if needed
});
});