-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.js
More file actions
117 lines (87 loc) · 2.81 KB
/
color.js
File metadata and controls
117 lines (87 loc) · 2.81 KB
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
console.log("charge");
//Yazil :
var r = 0,
g = 0,
b = 0;
body = document.body;
function bg () {
if (r <= 255 && g == 0 && b == 0) {
r ++;
}
if (r == 255 && b == 0 && g <= 255) {
g ++;
}
if (r == 255 && g == 255 && b <= 255) {
b ++;
}
if (b == 255 && g == 255 && r > 0) {
r --;
}
if (r == 0 && b == 255 && g > 0) {
g --;
}
if (r == 0 && g == 0 && b > 0) {
b --;
}
chrome.storage.local.get(['gamer'], function(result) {
gamer = result.gamer;
chrome.storage.local.get(['speed'], function(result) {
speedly = result.speed;
if(gamer == 'check') {
setTimeout(function() {
bg();
}, parseInt(speedly));
};
})
});
body.style.background = 'rgb('+r+','+g+','+b+')';
}
chrome.storage.local.get(['gamer'], function(result) {
gamer = result.gamer;
if(gamer == 'check') {
bg();
}else {
chrome.storage.local.get(['check'], function(result) {
stateCheck = result.check;
if(stateCheck == 'check') {
chrome.storage.local.get(['key'], function(result) {
body = document.body;
body.style.background = result.key;
});
}
});
chrome.storage.local.get(['checkStudent'], function(result) {
stateCheck2 = result.checkStudent;
console.log(stateCheck2);
if(stateCheck2 == 'check') {
chrome.storage.local.get(['studBack'], function(result) {
student = document.getElementById('menu-part');
student.style.background = result.studBack;
});
}
});
}
});
chrome.runtime.onMessage.addListener(
function(message, sender, sendResponse) {
switch(message.type) {
case "body":
body = document.body;
body.style.background = message.color;
break;
case "student":
student = document.getElementById('menu-part');
student.style.background = message.color;
break;
case "gamer":
if (message.color == 'on') {
bg();
}else {
body = document.body;
body.style.background = "#ffffff"
}
default:
console.error("Unrecognised message: ", message);
}
}
);