-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
29 lines (24 loc) · 950 Bytes
/
content.js
File metadata and controls
29 lines (24 loc) · 950 Bytes
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
(async function () {
// Load saved settings
const settings = await chrome.storage.sync.get();
if (Object.keys(settings).length === 0) return;
// Generate CSS from text-formatter
const css = getTextFormattingCSS(settings);
// Insert CSS into the page
let style = document.getElementById("clearview-style");
if (!style) {
style = document.createElement("style");
style.id = "clearview-style";
document.head.appendChild(style);
}
style.textContent = css;
// Listen for storage changes to update CSS dynamically
chrome.storage.onChanged.addListener((changes, area) => {
if (area === "sync") {
const updatedSettings = { ...settings };
for (const key in changes) updatedSettings[key] = changes[key].newValue;
const updatedCSS = getTextFormattingCSS(updatedSettings);
style.textContent = updatedCSS;
}
});
})();