This repository has been archived by the owner on May 30, 2018. It is now read-only.
forked from Ding-Fan/GeekPage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeekstyle.js
65 lines (57 loc) · 1.79 KB
/
geekstyle.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
// License AGPL-3.0
// Copyright(C) 2018 duangsuse
// GeekApk.org style manager
// should use dark style from 19:00 to 6:00
function shouldApplyDarkStyle() {
if (localStorage['night'] == 'false')
return false;
var dh = new Date();
nightBegin = localStorage['nightBegin'] || 19
nightEnd = localStorage['nightEnd'] || 6
return dh.getHours() >= nightBegin && dh.getHours() <= nightEnd
}
// use dark style
function darkStyle() {
if (localStorage['noAutoStyleSwitch'] == 'true') return;
if (localStorage['isDark'] == 'true') return;
localStorage['lightColorPrimary'] = localStorage['colorPrimary']
localStorage['lightColorInf'] = localStorage['colorInf']
localStorage['lightColorHigh'] = localStorage['colorHigh']
localStorage['lightColorFab'] = localStorage['colorFab']
localStorage['colorPrimary'] = 'black'
localStorage['colorInf'] = 'white'
localStorage['colorHigh'] = 'green'
localStorage['colorFab'] = 'grey'
localStorage['isDark'] = 'true'
}
// use user setting
function lightStyle() {
for (i in ['Primary', 'Inf', 'High', 'Fab']) {
localStorage['color' + i] = localStorage['lightColor' + i]
}
localStorage['isDark'] == 'false'
}
function coloredPrimary(classname) {
items = document.getElementsByClassName(classname)
for (i in items) {
i.style.color = localStorage['colorPrimary']
}
}
function coloredInf(classname) {
items = document.getElementsByClassName(classname)
for (i in items) {
i.style.color = localStorage['colorInf']
}
}
function coloredHigh(classname) {
items = document.getElementsByClassName(classname)
for (i in items) {
i.style.color = localStorage['colorHigh']
}
}
function coloredFab(classname) {
items = document.getElementsByClassName(classname)
for (i in items) {
i.style.color = localStorage['colorFab']
}
}