-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
334 lines (292 loc) · 14.7 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
function chrome_() {
try {
chrome !== undefined && browser !== undefined;
return browser;
} catch (e) {
console.log(e.message);
return chrome;
}
}
chrome_().storage.local.set(
{ VTOP_URI: window.location.origin },
function () {}
);
document.addEventListener("DOMContentLoaded", change_navbar);
function change_navbar() {
try {
var coursePage = document.createElement("div");
coursePage.className = "btn-group dropend";
coursePage.style = style =
"margin-top: 12px; background-color: red; padding: 3px";
coursePage.innerHTML = `
<button
type="button"
class="btn btn-outline-primary p-1 border-0 text-dark SideBarMenuBtn"
data-bs-toggle="dropdown"
data-bs-auto-close="outside"
aria-expanded="false"
>
<i style="background-color: red"
class="fa fa-star"></i>
</button>
<div
class="dropdown-menu border-0 py-0 shadow-lg dropdownMenuBoxWidth text-nowrap SideBarMenuDropDown"
>
<a onclick='document.querySelector("#sidePanel > div > div > div:nth-child(6) > div > a:nth-child(16)").click()'
data-url="examinations/StudentDA" class="dropdown-item menuFontStyle systemBtnMenu " href="javascript:void(0);"> <i class="fa fa-dot-circle-o iconSpace "></i> Digital Assignment Upload</a>
<a onclick='document.querySelector("#sidePanel > div > div > div:nth-child(6) > div > a:nth-child(13)").click()'
data-url="academics/common/StudentCoursePage" class="dropdown-item menuFontStyle systemBtnMenu " href="javascript:void(0);"> <i class="fa fa-dot-circle-o iconSpace "></i> Course Page</a>
<a onclick= 'document.querySelector("#sidePanel > div > div > div:nth-child(6) > div > a:nth-child(5)").click()'
data-url="academics/common/StudentClassMessage" class="dropdown-item menuFontStyle systemBtnMenu " href="javascript:void(0);"> <i class="fa fa-dot-circle-o iconSpace "></i> Class Messages</a>
<a onclick='document.querySelector("#sidePanel > div > div > div:nth-child(6) > div > a:nth-child(12)").click()'
data-url="academics/common/StudentAttendance" class="dropdown-item menuFontStyle systemBtnMenu " href="javascript:void(0);"> <i class="fa fa-dot-circle-o iconSpace "></i> Class Attendance</a>
<a onclick='document.querySelector("#sidePanel > div > div > div:nth-child(5) > div > a:nth-child(2)").click()'
data-url="proctor/viewProctorDetails" class="dropdown-item menuFontStyle systemBtnMenu " href="javascript:void(0);"> <i class="fa fa-dot-circle-o iconSpace "></i> Proctor Details</a>
<a onclick='document.querySelector("#sidePanel > div > div > div:nth-child(6) > div > a:nth-child(9)").click()'
data-url="academics/common/StudentTimeTable" class="dropdown-item menuFontStyle systemBtnMenu " href="javascript:void(0);"> <i class="fa fa-dot-circle-o iconSpace "></i> Time Table</a>
<a onclick='document.querySelector("#sidePanel > div > div > div:nth-child(8) > div > a:nth-child(3)").click()'
data-url="examinations/StudentMarkView" class="dropdown-item menuFontStyle systemBtnMenu " href="javascript:void(0);"> <i class="fa fa-dot-circle-o iconSpace "></i> Marks</a>
</div>
`;
var dropdown = document.getElementsByClassName("btn-group-vertical");
dropdown[0].insertBefore(coursePage, dropdown[0].children[0]);
} catch (err) {}
}
function find_right_due(table_inner) {
return new Promise((resolve) => {
const dueDates = [];
for (let i = 0; i < table_inner.children.length; i++) {
var check = table_inner.children[i].children[6].children[0].innerHTML;
if (check === "") {
var dwnld = table_inner.children[i].children[5].children.length;
dueDates.push({
due: table_inner.children[i].children[4].children[0].innerHTML,
download:
dwnld > 0
? table_inner.children[i].children[5].children[0].children[0]
: document.createElement("div"),
});
}
}
if (dueDates.length > 0) {
dueDates.sort((a, b) => {
return new Date(a.due).getTime() < new Date(b.due).getTime();
});
resolve(dueDates[0]);
}
resolve({
due: "Nothing Left. Cheers!",
download: document.createElement("div"),
});
});
}
async function assignments() {
try {
var regNo = document.getElementById("authorizedIDX").value;
var table = document.getElementsByClassName("customTable")[0].children[0];
var now_ = new Date().getTime();
var dis = document.getElementsByClassName("icon-button");
var scripts = document.getElementsByTagName("noscript");
var csrf = scripts[0].nextElementSibling.textContent.split('"')[3];
for (let i = 0; i < dis.length; i++) {
dis[i].disabled = true;
}
for (let i = 1; i < table.children.length; i++) {
var classid = table.children[i].children[1].innerHTML;
if (table.children[i].children[3].children.length != 1) {
await fetch(
`${window.location.origin}/vtop/examinations/processDigitalAssignment`,
{
method: "POST",
headers: {
"Content-Type":
"application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest",
},
body: `authorizedID=${regNo}&x=${new Date().toGMTString()}&classId=${classid}&_csrf=${csrf}`,
}
)
.then((res) => res.text())
.then(async (data) => {
var parser = new DOMParser();
var doc = parser.parseFromString(data, "text/html");
var table_inner =
doc.getElementsByClassName("customTable")[1].children[1];
var due_date = await find_right_due(table_inner).then(
(data) => data
);
var due = new Date(due_date.due.replace(/-/g, " ")).getTime();
var color =
(due - now_) / (3600 * 24 * 1000) <= 2 ? "red" : "green";
table.children[
i
].children[3].innerHTML += `<span style="display:inline; float:right; color:${color};">${due_date.due}</span>`;
table.children[i].children[3].children[0].appendChild(
due_date.download
);
})
.catch((err) => console.log(err));
}
}
for (let i = 0; i < dis.length; i++) {
dis[i].disabled = false;
}
} catch (err) {
console.log(err);
}
}
function sendingResponse() {
return new Promise((resolve) => {
resolve(document.documentElement);
});
}
// Message passing between background and content
// This removes the need for clicking in body to see due dates as it checks URL requests to find whether user has visited DA page.
var loaded = false;
chrome_().runtime.onMessage.addListener(function (
request,
sender,
sendResponse
) {
if (request.urlVisited && !loaded) {
loaded = true;
chrome_().storage.local.get(["pause"], function (data) {
if (!data.pause) {
assignments();
}
});
chrome_().storage.local.get(["token"], function (data) {
var head = document.getElementsByClassName("box-header with-border")[0];
if (!data.token) {
var text = document.createElement("p");
text.innerHTML =
"Sign in to Google via Extension to sync your assign with your Google Calendar.";
head.appendChild(text);
} else {
var btn = document.createElement("button");
btn.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 141.7 141.7" width="24" height="24"><path fill="#fff" d="M95.8,45.9H45.9V95.8H95.8Z"/><path fill="#34a853" d="M95.8,95.8H45.9v22.5H95.8Z"/><path fill="#4285f4" d="M95.8,23.4H30.9a7.55462,7.55462,0,0,0-7.5,7.5V95.8H45.9V45.9H95.8Z"/><path fill="#188038" d="M23.4,95.8v15a7.55462,7.55462,0,0,0,7.5,7.5h15V95.8Z"/><path fill="#fbbc04" d="M118.3,45.9H95.8V95.8h22.5Z"/><path fill="#1967d2" d="M118.3,45.9v-15a7.55462,7.55462,0,0,0-7.5-7.5h-15V45.9Z"/><path fill="#ea4335" d="M95.8,118.3l22.5-22.5H95.8Z"/><polygon fill="#2a83f8" points="77.916 66.381 75.53 63.003 84.021 56.868 87.243 56.868 87.243 85.747 82.626 85.747 82.626 62.772 77.916 66.381"/><path fill="#2a83f8" d="M67.29834,70.55785A7.88946,7.88946,0,0,0,70.78,64.12535c0-4.49-4-8.12-8.94-8.12a8.77525,8.77525,0,0,0-8.74548,6.45379l3.96252,1.58258a4.41779,4.41779,0,0,1,4.473-3.51635,4.138,4.138,0,1,1,.06256,8.24426v.00513h-.0559l-.00666.00061-.00964-.00061H59.15v3.87677h2.70642L61.88,72.65a4.70514,4.70514,0,1,1,0,9.37,5.35782,5.35782,0,0,1-3.96588-1.69354,4.59717,4.59717,0,0,1-.80408-1.2442l-.69757-1.69946L52.23005,79c.62,4.33,4.69,7.68,9.61,7.68,5.36,0,9.7-3.96,9.7-8.83A8.63346,8.63346,0,0,0,67.29834,70.55785Z"/></svg><span>Sync assignments with Google Calendar</span>`;
btn.style = `display: flex;align-items: center;gap: 1rem;font-family: inherit;justify-content: space-around;color: #535353;font-size: 13px;font-weight: 500;margin: 8px auto;cursor: pointer;background-color: white;border-radius: 32px;transition: all 0.2s ease-in-out;padding: 6px 10px;border: 1px solid rgba(0, 0, 0, 0.25);`;
head.appendChild(btn);
btn.addEventListener("click", function () {
var DOM = document.body.outerHTML;
chrome_().runtime.sendMessage(
{
message: "sync",
DOM,
},
function () {
console.log("Syncing");
}
);
});
}
});
}
return true;
});
document.addEventListener("DOMContentLoaded", styling);
/* Styling RaOg*/
function styling() {
var strr = document.createElement("div");
var background = document.getElementById("b3wrapper");
var mainpagebg = document.getElementById("b5wrapper");
var mainpagebr = document.getElementById("b5-pagewrapper");
background.setAttribute("style", " background-color: #28282B"); //bg colour for all pages
mainpagebg.setAttribute("style", " background-color: #28282B"); //bg colour for main page
mainpagebr.setAttribute("style", " z-index: 10"); //border radius for main page
mainpagebg.insertBefore(strr, mainpagebg.childNodes[0]); //RAOG background for mainpage
strr.setAttribute(
"style",
"height: 100%; width: 100%; position: absolute; top: 0; left: 0; background-color: #28282B;"
);
strr.innerHTML = `
<img src="https://i.postimg.cc/fyQdz4SH/21346-min.png" id = "bugfix" alt="RAOGYUH" width="100%" height="100%">
`;
var header = document.getElementBy;
var leftNav = document.getElementById("sidePanel");
leftNav.style = "background-color: rgb(0 0 0);"; //left nav bg colour
var navBar = document.getElementsByClassName("headerBackgroundColor");
navBar[0].style = "background: rgb(0 0 0)!important;"; //nav bar bg colour
var icons = document.querySelectorAll(".fa"); //nav bar icons colour
icons.forEach((fa) => fa.setAttribute("style", "color: #eaeaea;"));
let homeCard = document.querySelectorAll(".card");
homeCard[0].style.backgroundColor = "rgb(0 ,0 ,0, 0.1)"; //selects all cards in VTOP (lower div)
homeCard[1].style.backgroundColor = "rgb(0 ,0 ,0, 0.1)"; //upper div
homeCard[0].style.border = "2px solid rgb(211, 46, 46)";
homeCard[0].style.borderRadius = "30px";
homeCard[0].style.boxShadow = "0 0 10px 0 rgb(211, 46, 46)";
var homeCardText = document.querySelectorAll(".list-group-item");
homeCardText.forEach((listgroupitem) =>
listgroupitem.setAttribute(
"style",
"background-color: rgb(250, 250, 247, 0.0)!important;"
)
);
var homeCardText = document.querySelectorAll(".fg-black");
homeCardText.forEach((blacktxt) =>
blacktxt.setAttribute("style", "color: white!important;")
);
var dropDown = document.querySelectorAll(".dropdown-menu"); //changes for dropdown menus
dropDown.forEach((dropdown) =>
dropdown.setAttribute(
"style",
"background: rgb(29,29,29); background: linear-gradient(66deg, rgba(29,29,29,1) 0%, rgba(41,41,62,1) 47%, rgba(6,6,20,1) 100%); border-radius: 20px; box-shadow: 0 0 10px 0 rgb(211, 46, 46); border:1px solid rgb(211, 46, 46)!important;"
)
);
var allBoxes = document.querySelectorAll(".box"); //change colour of all boxes in vtop to dark grey
allBoxes.forEach((ab) => (ab.style.backgroundColor = "rgb(28 15 15)"));
var btns = document.querySelectorAll(".btn-sm"); //Change colour of spotlight buttons to red
btns.forEach((btn) => (btn.style.backgroundColor = "rgb(211, 46, 46)"));
document
.getElementsByClassName("h3")[0]
.setAttribute("style", "color: white!important"); //Change colour of Spotlight text to white
document.querySelectorAll(".offcanvas-body")[8].style.backgroundColor =
"rgb(255 70 70)";
var swiper = document.querySelectorAll(".offcanvas-header"); //changes for dropdown menus
swiper.forEach((dropdown) =>
dropdown.setAttribute("style", "background: black;")
);
var imgReplace = document.getElementsByClassName("img-circle"); // Sravan Senthil Nathan Avatar
imgReplace[0].src = "https://i.postimg.cc/3WPn7f7Y/senthil.jpg";
imgReplace[1].src = "https://i.postimg.cc/bvzpjmvQ/senthil.jpg";
imgReplace[2].src = "https://i.postimg.cc/bvzpjmvQ/senthil.jpg";
var gifReplace = document.getElementsByClassName("img-fluid"); // gif booty
gifReplace[0].src =
"https://media.tenor.com/images/fbf050f38146a5e56111b1bdf2845841/tenor.gif";
var aText = document.querySelectorAll(".dropdown-item");
aText.forEach((txt) =>
txt.setAttribute("style", "color: rgb(211, 46, 46); font-weight: bold;")
);
var aHead = document.querySelectorAll(".menuHeaderColor");
aHead.forEach((txt) =>
txt.setAttribute(
"style",
"background-color: #070b0f; font-weight: bold; color: white; border-radius:30px"
)
);
var rmHighlight = document.querySelectorAll(".list-group-item-action"); //remove white hover for spotlight card
rmHighlight.forEach((txt) =>
txt.setAttribute("style", "background-color: black;")
);
var signOut = document.getElementsByClassName("btn-success");
signOut[0].style.backgroundColor = "rgb(211, 46, 46)";
signOut[0].style.borderColor = "rgb(211, 46, 46)";
document.getElementsByTagName("body")[0].style.backgroundColor = "black"; //body background colour to black
document
.querySelectorAll(".navbar-toggler-icon")[0]
.setAttribute("style", "filter: invert(1);");
}
document.addEventListener("DOMContentLoaded", bugOne);
function bugOne() {
var strr = document.createElement("div");
var background = document.getElementById("b3wrapper");
background.insertBefore(strr, background.childNodes[0]); //RAOG Background for all pages
strr.setAttribute(
"style",
"height: 100%; width: 100%; position: absolute; top: 0; left: 0; background-color: #28282B;"
);
strr.innerHTML = `
<img src="https://i.postimg.cc/fyQdz4SH/21346-min.png" alt="RAOGYUH" width="100%" height="100%">
`;
}