-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
151 lines (140 loc) · 6.34 KB
/
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
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
chrome.runtime.onMessage.addListener(gotMessage);
function gotMessage(message,sender,sendResponse){
//GRABBING THE IMPORTANT TAGS FROM THE WEBPAGE
const div = document.querySelectorAll('div');
const h1 = document.querySelectorAll('h1');
const p = document.querySelectorAll('p');
const a = document.querySelectorAll('a');
const span = document.querySelectorAll('span');
const img = document.querySelectorAll('img');
const li = document.querySelectorAll('li');
//ANALYZING THE BUTTON PRESSED BY USER IN EXTENSION POPUP
if(message.p==0){
div.forEach((divs) => {
divs.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
h1.forEach((h1s) => {
h1s.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
p.forEach((ps) => {
ps.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
a.forEach((as) => {;
as.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
span.forEach((spans) => {
spans.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
li.forEach((lis) => {
lis.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
img.forEach((imgs) => {
imgs.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
}
else if(message.p==1){
div.forEach((divs) => {
const computedStyle = window.getComputedStyle(divs);
const height = computedStyle.getPropertyValue("height");
const width = computedStyle.getPropertyValue("width");
const heightTextNode = document.createTextNode(` ${height}*`);
const widthTextNode = document.createTextNode(`${width}`);
divs.appendChild(heightTextNode);
divs.appendChild(widthTextNode);
divs.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
span.forEach((spans) => {
const computedStyle = window.getComputedStyle(spans);
const height = computedStyle.getPropertyValue("height");
const width = computedStyle.getPropertyValue("width");
const heightTextNode = document.createTextNode(` ${height}*`);
const widthTextNode = document.createTextNode(`${width}`);
spans.appendChild(heightTextNode);
spans.appendChild(widthTextNode);
spans.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
img.forEach((imgs) => {
const computedStyle = window.getComputedStyle(imgs);
const height = computedStyle.getPropertyValue("height");
const width = computedStyle.getPropertyValue("width");
const heightTextNode = document.createTextNode(` ${height}`);
const widthTextNode = document.createTextNode(`${width}`);
imgs.appendChild(heightTextNode);
imgs.appendChild(widthTextNode);
imgs.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
}else if(message.p==2){
div.forEach((divs) => {
const computedStyle = window.getComputedStyle(divs);
const bgColor = computedStyle.getPropertyValue("background-color");
const bgColorTextNode = document.createTextNode(`${bgColor}`);
divs.appendChild(bgColorTextNode);
divs.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
h1.forEach((h1s) => {
const computedStyle = window.getComputedStyle(h1s);
const bgColor = computedStyle.getPropertyValue("color");
const bgColorTextNode = document.createTextNode(`${bgColor}`);
h1s.appendChild(bgColorTextNode);
h1s.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
p.forEach((ps) => {
const computedStyle = window.getComputedStyle(ps);
const bgColor = computedStyle.getPropertyValue("color");
const bgColorTextNode = document.createTextNode(`${bgColor}`);
ps.appendChild(bgColorTextNode);
ps.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
a.forEach((as) => {;
const computedStyle = window.getComputedStyle(as);
const bgColor = computedStyle.getPropertyValue("color");
const bgColorTextNode = document.createTextNode(`${bgColor}`);
as.appendChild(bgColorTextNode);
as.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
span.forEach((spans) => {
const computedStyle = window.getComputedStyle(spans);
const bgColor = computedStyle.getPropertyValue("background-color");
const bgColorTextNode = document.createTextNode(`${bgColor}`);
spans.appendChild(bgColorTextNode);
spans.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
li.forEach((lis) => {
const computedStyle = window.getComputedStyle(lis);
const bgColor = computedStyle.getPropertyValue("color");
const bgColorTextNode = document.createTextNode(`${bgColor}`);
lis.appendChild(bgColorTextNode);
lis.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
img.forEach((imgs) => {
imgs.style.border = `2px solid #${Math.floor(Math.random() * 16777215).toString(16)}`;
});
}
else if(message.link=="https://devdiv-web.netlify.app/"){
window.location.href = "https://devdiv-web.netlify.app/"; //GO TO THE devDivweb URL IF THE USER HAS PRESSED HOW TO USE BUTTON IN EXTENSION'S POPUP
}
else
{
div.forEach((divs) => {
divs.style.backgroundColor = message.c1;
});
h1.forEach((h1s) => {
h1s.style.backgroundColor = message.c4;
});
p.forEach((ps) => {
ps.style.color = message.c3;
});
a.forEach((as) => {
as.style.backgroundColor = message.c2;
});
span.forEach((spans) => {
spans.style.border = message.c5;
});
li.forEach((lis) => {
lis.style.border = message.c6;
});
img.forEach((imgs) => {
imgs.style.border = message.c7;
});
}
}