-
Notifications
You must be signed in to change notification settings - Fork 3
/
popup.js
51 lines (40 loc) · 1.9 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
console.log("popup.js loaded");
let fonts
chrome.storage.local.get(['fonts'], function(result) {
console.log('Value popup currently is: ')
console.log(result.fonts);
fonts = result.fonts;
document.getElementById("h1Font").value = fonts.h1
document.getElementById("h2Font").value = fonts.h2
document.getElementById("h3Font").value = fonts.h3
document.getElementById("h4Font").value = fonts.h4
document.getElementById("pFont").value = fonts.p
document.getElementById("aFont").value = fonts.a
document.getElementById("liFont").value = fonts.li
document.getElementById("divFont").value = fonts.div
console.log('Values set!')
});
const button = document.querySelector("#btn");
button.addEventListener("click", async () => {
console.log("button clicked");
// alert("button clicked");
// document.getElementById("btn").innerHTML = "Clicked";
alert("Font changed! Reload to see the changes.");
let h1Font = document.getElementById("h1Font").value;
let h2Font = document.getElementById("h2Font").value;
let h3Font = document.getElementById("h3Font").value;
let h4Font = document.getElementById("h4Font").value;
let pFont = document.getElementById("pFont").value;
let aFont = document.getElementById("liFont").value;
let liFont = document.getElementById("liFont").value;
let divFont = document.getElementById("divFont").value;
console.log("h1Font: ");
console.log (h1Font);
chrome.runtime.sendMessage({
msg: "buttonClicked",
data: {
subject: "Button-was-clicked",
content: {fonts: {"span": divFont, "p": pFont, "em": pFont, "b": pFont, "i": pFont, "u": pFont, "a": aFont, "li": liFont, "td": pFont, "th": pFont, "input": pFont, "option": liFont, "h1": h1Font, "h2": h2Font, "h3": h3Font, "h4": h4Font, "h5": h4Font, "h6": h4Font, "div": h4Font, "default": pFont}}
}
});
});