Repository navigation
Expand file tree
/
Copy pathpopup.js
More file actions
62 lines (54 loc) · 1.8 KB
/
Copy pathpopup.js
File metadata and controls
62 lines (54 loc) · 1.8 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
document.addEventListener("DOMContentLoaded", () => {
const enableDetection = document.getElementById("enableDetection");
const autoCensor = document.getElementById("autoCensor");
const devMode = document.getElementById("devMode");
const status = document.getElementById("status");
// Load saved settings
chrome.storage.local.get(
["enableDetection", "autoCensor", "devMode"],
(result) => {
enableDetection.checked = result.enableDetection !== false;
autoCensor.checked = result.autoCensor === true;
devMode.checked = result.devMode === true;
updateStatus();
}
);
// Update settings when changed
enableDetection.addEventListener("change", updateSettings);
autoCensor.addEventListener("change", updateSettings);
devMode.addEventListener("change", updateSettings);
function updateSettings() {
const settings = {
enableDetection: enableDetection.checked,
autoCensor: autoCensor.checked,
devMode: devMode.checked,
};
// Save settings
chrome.storage.local.set(settings);
// Send settings to content script
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs[0]) {
chrome.tabs.sendMessage(tabs[0].id, {
action: "updateSettings",
...settings,
});
}
});
updateStatus();
}
function updateStatus() {
if (enableDetection.checked) {
const modes = [];
if (autoCensor.checked) modes.push("auto-censoring");
if (devMode.checked) modes.push("dev mode");
status.textContent =
modes.length > 0
? `Detection enabled (${modes.join(", ")})`
: "Detection enabled";
status.style.color = "#4CAF50";
} else {
status.textContent = "Protection disabled";
status.style.color = "#f44336";
}
}
});