forked from vishwajeeta/Light-Shield
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
58 lines (46 loc) · 1.37 KB
/
content.js
File metadata and controls
58 lines (46 loc) · 1.37 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
(function () {
if (window.top !== window.self) return;
const OVERLAY_ID = "soft-dim-overlay";
function createOverlay(opacity, color) {
removeOverlay();
const overlay = document.createElement("div");
overlay.id = OVERLAY_ID;
overlay.style.position = "fixed";
overlay.style.top = "0";
overlay.style.left = "0";
overlay.style.width = "100%";
overlay.style.height = "100%";
overlay.style.backgroundColor = color;
overlay.style.opacity = opacity;
overlay.style.pointerEvents = "none";
overlay.style.zIndex = "2147483647";
overlay.style.transition = "opacity 0.2s ease";
document.documentElement.appendChild(overlay);
}
function removeOverlay() {
const existing = document.getElementById(OVERLAY_ID);
if (existing) existing.remove();
}
function applySettings(settings) {
if (!settings.enabled) {
removeOverlay();
return;
}
createOverlay(settings.opacity || 0.3, settings.color || "black");
}
// Load saved settings on page load
chrome.storage.sync.get(
{
enabled: false,
opacity: 0.3,
color: "black"
},
applySettings
);
// Listen for popup updates
chrome.runtime.onMessage.addListener((message) => {
if (message.action === "update") {
applySettings(message.settings);
}
});
})();