-
Notifications
You must be signed in to change notification settings - Fork 4
/
theme.js
executable file
·152 lines (146 loc) · 4.68 KB
/
theme.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// I've never written JS before. I still haven't.
// Sorry to anyone looking at this, I don't know how it works or if it's good practice.
var colorboxElements = document.querySelectorAll('.colorbox');
var colorClasses = ['colorbox0', 'colorbox1', 'colorbox2', 'colorbox3'];
colorboxElements.forEach(function(element) {
element.classList.remove('colorbox');
var randomIndex = Math.floor(Math.random() * colorClasses.length);
var randomColorClass = colorClasses[randomIndex];
element.classList.add(randomColorClass);
});
var elements = document.querySelectorAll('[src]');
var elementsWithInlineStyles = document.querySelectorAll("[style]");
// 1-4 are for UI images (randomized between the 4 colors)
// Other is for non-image UI elements
if (new Date().getMonth() == 5) {
// Pride
colorOne = 'blue';
colorTwo = 'pink';
colorTre = 'white';
colorFor = 'blue';
seasonal = true;
/* } else if (new Date().getMonth() == 10) {
// October
colorOne = 'black';
colorTwo = 'white';
colorTre = 'black';
colorFor = 'white';
colorOtr = 'background-color: #ffffff;border: 2px solid #c6c6c6;';
seasonal = true; */
} else if (new Date().getMonth() == 11) {
// Christmas
colorOne = 'red';
colorTwo = 'green';
colorTre = 'red';
colorFor = 'green';
seasonal = true;
} else {
var randomColor = Math.floor(Math.random() * 7) + 1;
switch (randomColor) {
case 1:
colorOne = 'green';
colorTwo = 'green';
colorTre = 'green';
colorFor = 'green';
colorOtr = 'background-color: #2ec429;border: 2px solid #1e8b00;';
seasonal = true;
break;
case 2:
colorOne = 'pink';
colorTwo = 'pink';
colorTre = 'pink';
colorFor = 'pink';
colorOtr = 'background-color: #feb0fc;border: 2px solid #e488b1;';
seasonal = true;
break;
case 3:
colorOne = 'white';
colorTwo = 'white';
colorTre = 'white';
colorFor = 'white';
colorOtr = 'background-color: #ffffff;border: 2px solid #c6c6c6;';
seasonal = true;
break;
case 4:
colorOne = 'black';
colorTwo = 'black';
colorTre = 'black';
colorFor = 'black';
colorOtr = 'background-color: #393939;border: 2px solid #141414;color:white;';
seasonal = true;
break;
case 5:
colorOne = 'red';
colorTwo = 'red';
colorTre = 'red';
colorFor = 'red';
colorOtr = 'background-color: #fb1830;border: 2px solid #ba0020;color:white;';
seasonal = true;
break;
case 6:
colorOne = 'blue';
colorTwo = 'blue';
colorTre = 'blue';
colorFor = 'blue';
colorOtr = 'background-color: #62caff;border: 2px solid #3a98e1;color:black;';
seasonal = true;
break;
case 7:
colorOne = 'orange';
colorTwo = 'orange';
colorTre = 'orange';
colorFor = 'orange';
colorOtr = 'background-color: #fbd39a;border: 2px solid #fb7900;color:black;';
seasonal = true;
break;
}
}
/*
colorOne = 'green';
colorTwo = 'green';
colorTre = 'green';
colorFor = 'green';
colorOtr = 'background-color: #2ec429;border: 2px solid #1e8b00;';
seasonal = true;
*/
// I WILL NOT OPTIMIZE THIS
// SHUT UP SHUT UP SHUT UP
if (seasonal == true) {
elementsWithInlineStyles.forEach(function(element) {
var inlineStyle = element.getAttribute("style");
var newInlineStyle = inlineStyle.replace(/\/\*dummystyle\*\//g, colorOtr);
element.setAttribute("style", newInlineStyle);
});
for (var i = 0; i < elements.length; i++) {
var srcElement = elements[i];
var src = srcElement.getAttribute('src');
var parentOne = srcElement.closest('.colorbox0');
var parentTwo = srcElement.closest('.colorbox1');
var parentTre = srcElement.closest('.colorbox2');
var parentFor = srcElement.closest('.colorbox3');
if (parentOne) {
if (src && src.includes('/menu/green')) {
var newSrc = src.replace('/menu/green', `/menu/${colorOne}`);
srcElement.setAttribute('src', newSrc);
}
}
if (parentTwo) {
if (src && src.includes('/menu/green')) {
var newSrc = src.replace('/menu/green', `/menu/${colorTwo}`);
srcElement.setAttribute('src', newSrc);
}
}
if (parentTre) {
if (src && src.includes('/menu/green')) {
var newSrc = src.replace('/menu/green', `/menu/${colorTre}`);
srcElement.setAttribute('src', newSrc);
}
}
if (parentFor) {
if (src && src.includes('/menu/green')) {
var newSrc = src.replace('/menu/green', `/menu/${colorFor}`);
srcElement.setAttribute('src', newSrc);
}
}
}
}