-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
44 lines (40 loc) · 1011 Bytes
/
content.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
const bgcolor = [
"#292525",
"#1f1f1f",
"#373737",
"#2c3642",
"#1c2b3c",
"#444444",
"#1e152f",
"#1e3029",
"#0b2637",
"hsl(210deg, 30%, 8%)",
"#182635",
"#181818",
"#191b1f"
];
const randomIdx = randomNum(bgcolor.length);
document.body.style.backgroundColor = `${bgcolor[randomIdx]}`;
document.querySelector("#contents").style.color = "#eee";
const uri = window.location.host;
if (uri === "sxwangzhiwen.github.io") {
document.querySelectorAll("a").forEach((item) => {
item.style.color = "#eee";
});
document.querySelectorAll("p> a").forEach((item) => {
item.style.color = "#ccc";
});
document.querySelectorAll("p > code").forEach((item) => {
item.style.color = "#000";
});
document.querySelectorAll("figure > pre > code > span.line")
.forEach((item) => {
item.style.color = "#000";
});
document.querySelectorAll("#navigation > ul > li > a").forEach((item) => {
item.style.color = "#49c0ee";
});
}
function randomNum(length) {
return Math.floor(Math.random() * length);
}