-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (39 loc) · 1.23 KB
/
script.js
File metadata and controls
42 lines (39 loc) · 1.23 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
console.log('Chrome Extension Working!!');
/* the above script will run irrespective whether the button is clicked or not
as not under the function receving the message */
chrome.runtime.onMessage.addListener(extensionRun);
let body = document.getElementsByTagName('body');
let paras = document.getElementsByTagName('p');
let tb = body, tp = paras;
function extensionRun(message, sender, sendResponse){
/* if(body[0].style['background'] != 'rbg(0, 0, 0)')
{
console.log('why??');
message.turn = 'on';
}else{
console.log(message.turn);
message.turn = 'off';
} */
if( message.turn === "on" ){
console.log('Dark!!');
for(by of body){
by.style['background'] = '#000000';
by.style['color'] = ' #ffffff';
}
for(p of paras){
p.style['background-color'] = ' #000000 ';
p.style['color'] = '#ffffff';
}
}else if(message.turn === "off")
{
console.log('Light!!');
var i;
for(i = 0; i < paras.length; i++){
paras[i].style = tp[i].style;
}
for(i = 0; i < body.length; i++){
body[i].style = tb[i].style;
}
}
console.log(by.style['background']);
}