-
Notifications
You must be signed in to change notification settings - Fork 2
/
popup.js
51 lines (45 loc) · 1.78 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Save settings
document.getElementById("save-btn").addEventListener("click", function () {
const interval = document.getElementById("interval-input").value;
const showSaveButton = document.getElementById("show-save-button").checked;
const showTokens = document.getElementById("show-tokens").checked;
const autoFullMode = document.getElementById("auto-full-mode").checked; // Add this line to get the checkbox value
// Save all settings, including the progress bar size value
chrome.storage.sync.set(
{
interval,
showSaveButton,
showTokens,
autoFullMode, // Add the new setting
},
function () {
console.log("Settings saved");
// Change the text of the reload button
document.getElementById("reload-btn").textContent =
"Pending saving. Reload OpenAI tabs now?";
}
);
});
// Load current settings when popup opens
chrome.storage.sync.get(
["interval", "showSaveButton", "showTokens", "autoFullMode"], // Add "autoFullMode" to the list of settings
function (result) {
document.getElementById("interval-input").value = result.interval || 1000;
document.getElementById("show-save-button").checked =
result.showSaveButton === true;
document.getElementById("auto-full-mode").checked =
result.autoFullMode !== false; // Enforce to on as default
document.getElementById("show-tokens").checked = result.showTokens === true;
}
);
// Reload tabs
document.getElementById("reload-btn").addEventListener("click", function () {
// Change the text of the reload button
document.getElementById("reload-btn").textContent = "Reload OpenAI Tabs";
const tabs = chrome.tabs.query({ url: "https://chatgpt.com/*" });
tabs.then((tabs) => {
tabs.forEach((tab) => {
chrome.tabs.reload(tab.id);
});
});
});