-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcampus-hide.user.js
138 lines (119 loc) · 4.5 KB
/
campus-hide.user.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
// ==UserScript==
// @name RWTH CAMPUS: Hide unused links from sidebar
// @namespace https://github.com/Itja/campus-hide/raw/master/campus-hide.user.js
// @version 0.1
// @description There is a link to show everything that is hidden. Hides cateories: 'Adressen', 'Dokumente', 'Aufgaben', 'E-Mail', 'Papierkorb'. Hides links: 'Einstellungen', 'Abmelden', 'Hilfe', 'StOEHn', 'EvaSys', 'Fachbereiche', 'Prüfungsordnungen', 'Tagesansicht', 'Monatsansicht', 'Geburtstags', 'Urlaubs', 'Telefonnr.', 'Hochschulstatistik'
// @author Mitja Schmakeit
// @match https://www.campus.rwth-aachen.de/office/*
// @require http://code.jquery.com/jquery-2.2.4.min.js
// @grant none
// ==/UserScript==
var headlinesToHide = ['Adressen', 'Dokumente', 'Aufgaben', 'E-Mail', 'Papierkorb'];
var menuEntriesToHide = ['Einstellungen', 'Abmelden',
'Hilfe', 'StOEHn', 'EvaSys', 'Fachbereiche', 'Prüfungsordnungen',
'Tagesansicht', 'Monatsansicht', 'Geburtstags', 'Urlaubs',
'Telefonnr.', 'Hochschulstatistik'];
//for debugging purposes, we call this method instead of hiding directly
function hide(elem) {
currentHideFunc(elem);
//elem.hide();
//elem.css( "background-color", "red" );
}
function realHide(elem) {
elem.hide();
}
function realShow(elem) {
elem.show();
}
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
function getMenuEntryByName(title) {
return $('td > a.nav:contains("' + title + '")').parent().parent();
}
function hideMenuEntry(title) {
hide(getMenuEntryByName(title));
}
function addMenuEntry(elem) {
var td = $('<td colspan="3"></td>').append(elem);
var tr = $('<tr></tr>').append(td);
menuTableBody.append(tr);
}
function getNavHeadlineByTitle(title) {
return $('td.navigatorheadline:contains("' + title + '")').parent();
}
function hideNavigatorHeadline(title) {
hide(getNavHeadlineByTitle(title));
}
function replaceHeadline(newHtml) {
headlineCell.addClass('headline');
headlineCell.addClass('tmHeadline');
addGlobalStyle('.tmHeadline a { color: white; }');
headlineCell.html(newHtml);
}
function pageCalendar() {
console.log(mainTableCell);
var out = [];
var cals = {weekCalendar: 'Wochenansicht', dayCalendar: 'Tagesansicht', monthCalendar: 'Monatsansicht'};
for (var x in cals) {
if (path.match(x)) {
out.push(cals[x]);
} else {
out.push('<a href="' + x + '.asp">' + cals[x] + '</a>');
}
}
replaceHeadline(out.join(' | '));
}
function pageDisclaimer() {
$('input[type="checkbox"]').prop('checked', true);
$('input[value="Zustimmen"]').click();
}
function getContentTable(number) {
return mainTableCell.find('> table:nth-child(' + number + ')');
}
function setupPageVars() {
menuTableBody = $('body > table:nth-child(3) > tbody > tr > td:first-child > table:first-of-type > tbody');
mainTableCell = $('body > table > tbody > tr > td[bgcolor="ffffff"]');
mainHeadlineTable = mainTableCell.find('> table:first-child');
headlineCell = mainHeadlineTable.find('> tbody > tr > td:nth-child(2)');
if (headlineCell.length === 0) {
headlineCell = mainHeadlineTable.find('> tbody > tr > td:first-child');
}
path = window.location.pathname;
}
function hideEverything() {
hide($('body>table:first-child'));
menuEntriesToHide.forEach(hideMenuEntry);
headlinesToHide.forEach(hideNavigatorHeadline);
}
var mainTableCell, mainHeadlineTable, mainContentTable, headlineCell, path, menuTableBody;
var currentHideFunc = realHide;
(function() {
'use strict';
setupPageVars();
hideEverything();
var showHiddenLink = $('<a class="nav" style="font-weight: bold; border: 1px dashed white; color: white" href="#">Zeige Versteckte Elemente</a>');
showHiddenLink.click((e) => {
currentHideFunc = (elem) => {
elem.show();
elem.css('background-color', 'red');
};
hideEverything();
showHiddenLink.attr('href', '');
showHiddenLink.off('click');
showHiddenLink.text('Verstecke Elemente');
e.preventDefault();
});
addMenuEntry(showHiddenLink);
if (path.match(/Calendar\.asp/)) {
pageCalendar();
} else if (path.match(/disclaimer\.asp/)) {
pageDisclaimer();
}
})();