-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
152 lines (141 loc) · 5.2 KB
/
main.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
// ==UserScript==
// @name Synergia but better
// @version 0.2
// @description Improves librus synergia because it's bad and stupid and shit
// @author adamski234#7707
// @match https://synergia.librus.pl/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
//Remove the "bezpieczny uczen" bullshit
try {
document.getElementById("icon-bezpiecznyuczen").parentNode.remove();
} catch (e) {
console.error("Error while removing `bezpieczny uczen` button");
}
//Remove the "homework" button
try {
document.getElementById("icon-zadania").parentNode.remove();
} catch (e) {
console.error("Error while removing `zadania` button");
}
//Useful variable
let topMenuBar;
try {
const mainMenu = document.getElementById("main-menu");
if (!mainMenu) {
throw new Error();
}
topMenuBar = mainMenu.getElementsByClassName("main-menu-list")[0];
if (!topMenuBar) {
throw new Error();
}
} catch (e) {
console.error("`topMenuBar` not found. Exiting");
return;
}
let uczenMenu = topMenuBar.getElementsByTagName("li")[6].getElementsByTagName("ul")[0]; //The list that shows up on hover
try {
const parent = topMenuBar.getElementsByTagName("li")[6];
if (!parent) {
throw new Error();
}
uczenMenu = parent.getElementsByTagName("ul")[0];
if (!uczenMenu) {
throw new Error();
}
} catch (e) {
console.error("`uczenMenu` not found. Exiting.");
return;
}
//Remove the grade button and add it to the uczen menu
try {
const gradeMenuToAppend = document.createElement("li");
gradeMenuToAppend.innerHTML = "<a href=\"/przegladaj_oceny/uczen\">Oceny</a>"
uczenMenu.appendChild(gradeMenuToAppend);
document.getElementById("icon-oceny").parentNode.remove();
} catch (e) {
console.error("Error while moving the `grades` button");
}
//Remove the attendance button and add it to the uczen menu
try {
const attendanceMenuToAppend = document.createElement("li");
attendanceMenuToAppend.innerHTML = "<a href=\"/przegladaj_nb/uczen\">Frekwencja</a>"
uczenMenu.appendChild(attendanceMenuToAppend);
document.getElementById("icon-nb").parentNode.remove();
} catch (e) {
console.error("Error while moving the `attendance` button");
}
let orgMenu;
try {
const parent = topMenuBar.getElementsByTagName("li")[12];
if (!parent) {
throw new Error();
}
orgMenu = parent.getElementsByTagName("ul")[0];
if (!parent) {
throw new Error();
}
} catch (e) {
console.error("`orgMenu` not found. Exiting");
return;
}
//Remove the calendar button and add it to the organization menu
try {
const calendarMenuToAppend = document.createElement("li");
calendarMenuToAppend.innerHTML = "<a href=\"/terminarz\">Terminarz</a>";
orgMenu.appendChild(calendarMenuToAppend);
document.getElementById("icon-terminarz").parentNode.remove();
} catch (e) {
console.error("Error while moving the `grades` button");
}
//Remove two unused buttons on the top bar
try {
topMenuBar.getElementsByTagName("li")[3].remove(); //Books
} catch (e) {
console.error("Couldn't remove the `books` menu. Exiting");
return;
}
try {
topMenuBar.getElementsByTagName("li")[3].remove(); //Polls
} catch (e) {
console.error("Couldn't remove the `polls` menu. Exiting");
return;
}
//Create a new top menu bar element for messages and notice board
const newMenuEntry = document.createElement("li");
newMenuEntry.innerHTML = "<a href=\"javascript:void(null)\">Informacje</a>";
newMenuEntry.innerHTML += "<ul></ul>";
topMenuBar.appendChild(newMenuEntry);
//Add messages and the notice board to the new element
const infoMenu = newMenuEntry.getElementsByTagName("ul")[0];
if (!infoMenu) {
console.error("`infoMenu` not found. I don't know what the fuck just happened, exiting");
return
}
const messageMenuToAppend = document.createElement("li");
messageMenuToAppend.innerHTML = "<a href=\"/wiadomosci\">Wiadomości</a>";
infoMenu.appendChild(messageMenuToAppend);
try {
document.getElementById("icon-wiadomosci").parentNode.remove();
} catch (e) {
console.error("Could not remove the `messages` button. Exiting");
return;
}
const noticeBoardMenuToAppend = document.createElement("li");
noticeBoardMenuToAppend.innerHTML = "<a href=\"/ogloszenia\">Ogłoszenia</a>";
infoMenu.appendChild(noticeBoardMenuToAppend);
try {
document.getElementById("icon-ogloszenia").parentNode.remove();
} catch (e) {
console.error("Could not remove the `notice board` button. Exiting");
return;
}
//Remove the logo from the top banner
try {
document.getElementById("top-banner-container").remove();
} catch (e) {
console.error("Could not remove the top banner container. Not exiting.");
}
})();