-
Notifications
You must be signed in to change notification settings - Fork 0
/
YNU-selfsrv-enhance.js
351 lines (340 loc) · 27 KB
/
YNU-selfsrv-enhance.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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
// ==UserScript==
// @name 云南大学校园网美化
// @namespace https://greasyfork.org/zh-CN/scripts/476284-云南大学校园网美化
// @homepageURL https://github.com/Steven-Zhl/4BetterBrowser/Scripts#云南大学校园网美化
// @version 1.2.1
// @license GPL-3.0
// @description 云南大学自助服务平台(校园网)美化脚本
// @author Steven-Zhl
// @icon https://selfsrv.ynu.edu.cn/favicon.ico
// @match https://selfsrv.ynu.edu.cn/*
// @exclude https://selfsrv.ynu.edu.cn/login
// @grant none
// ==/UserScript==
/**
* 根据16进制颜色值和倍率计算新的颜色值
* @param {string} hexColor - 16进制表示的颜色
* @param {number[]} multipliers - R,G,B的倍率,在[0,1]之间
* @returns {string} - 返回新的16进制颜色值,格式为#{RRGGBB}
*/
function MultiplyHexColor(hexColor, multipliers) {
// 首先将16进制颜色值转换为RGB色值
const originR = parseInt(hexColor.slice(1, 3), 16);
const originG = parseInt(hexColor.slice(3, 5), 16);
const originB = parseInt(hexColor.slice(5, 7), 16);
// 分别将RGB色值与倍率相乘,并确保结果在0到255之间
const R = Math.min(255, Math.max(0, Math.round(originR * multipliers[0])));
const G = Math.min(255, Math.max(0, Math.round(originG * multipliers[1])));
const B = Math.min(255, Math.max(0, Math.round(originB * multipliers[2])));
// 将新的RGB值转换为16进制颜色值并返回
const resultColor = `#${(R < 16 ? '0' : '') + R.toString(16)}${(G < 16 ? '0' : '') + G.toString(16)}${(B < 16 ? '0' : '') + B.toString(16)}`;
return resultColor;
}
/**
* 构建一个图片选择对话框
* @param {string} titleInfo - 对话框标题
* @param {string} localVariableName - localStorage中存储图片的变量名
*/
function QueryImage(titleInfo, localVariableName) {
var dialog = document.createElement('dialog'); dialog.style.cssText = "border-radius: 10px; padding: 10px; text-align: center;";
var title = document.createElement('h3'); title.innerText = titleInfo; title.style.cssText = "text-align: center; margin: 3px";
var typeContainer = document.createElement('div'); typeContainer.style.margin = "3px";
var buttonContainer = document.createElement('div'); buttonContainer.style.cssText = "height: 30px; margin: 3px; text-align: center";
var tip = document.createElement('p'); tip.innerText = "图片类型: "; tip.style.cssText = "display: inline-block; vertical-align: middle; margin: 3px";
var select = document.createElement('select'); select.title = "选择图片"; select.style.cssText = "display: inline-block; vertical-align: middle; margin: 3px";
select.innerHTML = '<option value="local">本地图片</option><option value="online">在线图片</option>';
var localInput = document.createElement('input'); localInput.type = 'file'; localInput.accept = "image/png, image/jpg, image/jpeg"; localInput.style.margin = "3px";
var onlineInput = document.createElement('input'); onlineInput.type = 'hidden'; onlineInput.placeholder = "请粘贴图片链接"; onlineInput.style.margin = "3px";
var yesButton = document.createElement('button'); yesButton.innerText = '确定'; yesButton.style.cssText = "display: inline-block; margin: 3px";
var clearButton = document.createElement('button'); clearButton.innerText = '恢复默认'; yesButton.style.cssText = "display: inline-block; margin: 3px";
var cancelButton = document.createElement('button'); cancelButton.innerText = '取消'; cancelButton.style.cssText = "display: inline-block; margin: 3px";
dialog.className = 'dialog';
dialog.appendChild(title);
dialog.appendChild(typeContainer);
dialog.appendChild(localInput);
dialog.appendChild(onlineInput);
dialog.appendChild(buttonContainer);
typeContainer.appendChild(tip);
typeContainer.appendChild(select);
buttonContainer.appendChild(yesButton);
buttonContainer.appendChild(cancelButton);
buttonContainer.appendChild(clearButton);
// 添加事件监听器
select.addEventListener('change', function () {
if (select.value === 'local') {
localInput.type = 'file';
onlineInput.type = 'hidden';
}
else if (select.value === 'online') {
localInput.type = 'hidden';
onlineInput.type = 'text';
}
});
yesButton.addEventListener('click', function () {
if (select.value === 'local' && localInput.files[0]) {
const reader = new FileReader();
reader.onload = function () {
const img = new Image(); // 创建一个新的Image对象
img.src = reader.result; // 设置Image对象的src为用户输入的文件链接
try {
localStorage.setItem(localVariableName, reader.result);
} catch (e) {
alert('图片文件过大,无法加载');
dialog.close();
}
};
reader.readAsDataURL(localInput.files[0]);
window.location.reload();
} else if (select.value === 'online') {
localStorage.setItem(localVariableName, onlineInput.value);
}
});
clearButton.addEventListener('click', function () {
localStorage.removeItem(localVariableName);
alert('已恢复默认');
window.location.reload();
});
cancelButton.addEventListener('click', function () { dialog.close(); });
document.body.appendChild(dialog);
dialog.showModal();
}
/**
* 构建一个颜色选择对话框
* @param {string} titleInfo - 对话框标题
* @param {string} localVariableName - localStorage中存储颜色的变量名
*/
function QueryColor(titleInfo, localVariableName) {
var dialog = document.createElement('dialog'); dialog.style.cssText = "border-radius: 10px; padding: 10px; text-align: center;";
var title = document.createElement('h3'); title.innerText = titleInfo; title.style.cssText = "text-align: center; margin: 3px";
var buttonContainer = document.createElement('div'); buttonContainer.style.cssText = "height: 30px; margin: 3px; text-align: center";
var input = document.createElement('input'); input.type = 'color'; input.style.margin = "3px";
var yesButton = document.createElement('button'); yesButton.innerText = '确定'; yesButton.style.cssText = "display: inline-block; margin: 3px";
var clearButton = document.createElement('button'); clearButton.innerText = '恢复默认'; yesButton.style.cssText = "display: inline-block; margin: 3px";
var cancelButton = document.createElement('button'); cancelButton.innerText = '取消'; cancelButton.style.cssText = "display: inline-block; margin: 3px";
dialog.className = 'dialog';
dialog.appendChild(title);
dialog.appendChild(input);
dialog.appendChild(buttonContainer);
buttonContainer.appendChild(yesButton);
buttonContainer.appendChild(cancelButton);
buttonContainer.appendChild(clearButton);
yesButton.addEventListener('click', function () {
localStorage.setItem(localVariableName, input.value);
window.location.reload();
});
clearButton.addEventListener('click', function () {
localStorage.removeItem(localVariableName);
alert('已恢复默认');
window.location.reload();
});
cancelButton.addEventListener('click', function () { dialog.close(); });
document.body.appendChild(dialog);
dialog.showModal();
}
/**
* 加载自定义主题色
* @param {string} themeColor - 16进制表示的主题色
*/
function LoadThemeColor(themeColor) { // 将颜色替换为自定义主题色
var headerColor = MultiplyHexColor(themeColor, [115 / 60, 202 / 141, 226 / 188]);
var logoColor = MultiplyHexColor(themeColor, [54 / 60, 127 / 141, 169 / 188]);
var header = document.getElementsByClassName("navbar navbar-static-top")[0];
var sidebar = document.getElementsByClassName('sidebar-menu')[0];
header.style.backgroundColor = themeColor;
header.style.backgroundImage = 'linear-gradient(to right, ' + themeColor + ', ' + headerColor + ')';
sidebar.getElementsByClassName('active')[0].firstChild.style.borderLeftColor = themeColor; // 修改sidebar的active元素的左边框颜色
document.getElementsByClassName('logo')[0].style.backgroundColor = logoColor; // 修改logo的背景颜色
document.getElementsByClassName('sidebar-toggle')[0].style.backgroundColor = themeColor; // 修改sidebar-toggle的背景颜色
document.getElementsByClassName('user-header')[0].style.backgroundColor = themeColor; // 修改user-header的背景颜色
document.getElementsByClassName('main-footer')[0].style.backgroundColor = themeColor; // 修改main-footer的背景颜色
}
/**
* 加载自定义侧边栏颜色
* @param {string} sidebarColor - 16进制表示的侧边栏颜色
*/
function LoadSidebarColor(sidebarColor) {
var sidebar = document.getElementsByClassName('sidebar-menu')[0];
document.getElementsByClassName('main-sidebar')[0].style.backgroundColor = sidebarColor;
document.querySelectorAll('.treeview-menu').forEach(function (treeviewMenu) {
treeviewMenu.style.backgroundColor = sidebarColor;
}); // 修改treeview-menu的背景颜色
sidebar.style.color = sidebarColor;
sidebar.querySelectorAll('li').forEach(function (li) {
li.style.backgroundColor = sidebarColor;
li.style.color = sidebarColor;
if (li.firstChild.firstChild) li.firstChild.style.backgroundColor = sidebarColor;
});
}
/**
* 加载自定义头像
* @param {string} avaterLink - 头像链接
*/
function LoadAvatar(avaterLink) { // 将图片链接替换为自定义头像
if (!avaterLink) { return; }
var avatar = document.getElementsByClassName('img-circle');
for (let i = 0; i < avatar.length; i++) avatar[i].src = avaterLink;
document.getElementsByClassName('user-image')[0].src = avaterLink;
}
/**
* 加载自定义背景图片
* @param {string} backgroundLink - 背景图片链接
*/
function LoadBackground(backgroundLink) {
if (!backgroundLink) { return; }
var backgroundElement = document.getElementsByClassName('content-wrapper')[0];
backgroundElement.style.background = 'url(' + backgroundLink + ')';
backgroundElement.style.backgroundSize = 'cover';
// 为了更好显示背景图片,需要让页面中的panel和panel-heading元素半透明
document.querySelectorAll('.panel').forEach(function (panel) { panel.style.opacity = '0.75'; });
document.querySelectorAll('.panel-heading').forEach(function (panel) { panel.style.opacity = '0.75'; });
}
/**
* 加载原神主题(预设)
*/
function GenshinTheme() {
LoadBackground('https://ys.mihoyo.com/main/_nuxt/img/poster.47f71d4.jpg');
LoadAvatar('https://uploadstatic.mihoyo.com/contentweb/20210105/2021010518424084444.png');
LoadThemeColor("#404040a0");
LoadSidebarColor("#404040");
var badge = document.createElement('img');
badge.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJMAAAC/CAYAAAD6i+5YAAAAG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dX+qjVb+f/CTAAHoCJWA5O4zIAAAAASUVORK5CYII=';
badge.style.cssText = "position: fixed; bottom: 80px; right: 20px; width: 60px; height: auto;"
document.body.appendChild(badge);
document.getElementsByClassName('logo-lg')[0].firstChild.innerText = "云·原神";
document.getElementsByClassName('logo-mini')[0].innerHTML = '<img src="https://webstatic.mihoyo.com/bh3/upload/officialsites/201908/ys_1565764084_7084.png" width="40px">';
var icon = document.createElement('link'); icon.rel = 'icon'; icon.type = 'image/ico'; icon.href = 'https://ys.mihoyo.com/main/favicon.ico';
document.head.appendChild(icon);
document.getElementsByClassName('text-success')[0].parentElement.innerHTML = '<i class="fa fa-circle text-success"></i>提瓦特大陆';
}
/**
* 为指定元素添加点击复制功能
*/
function ClickCopy(element) {
element.addEventListener('click', function () {
navigator.clipboard.writeText(element.innerText);
alert('已复制到剪贴板');
});
}
(function () {
// 1. 在首页和/在线信息和日志/上网明细中,同步来自无感知认证的备注,并且为表格内容增添点击复制功能
if (window.location.href == 'https://selfsrv.ynu.edu.cn/home' || window.location.href.match('https:\/\/selfsrv\.ynu\.edu\.cn\/log\/detail.*')) {
fetch('https://selfsrv.ynu.edu.cn/user/mac-auth')
.then(response => {
if (!response.ok) { throw new Error('网络请求失败'); }
return response.text();
})
.then(html => {
const temp_div = document.createElement('div');// 创建一个临时div元素来解析HTML
temp_div.innerHTML = html;
const mac_list = temp_div.querySelector('.kv-grid-table.table.table-hover.table-bordered').querySelectorAll('tr');
if (mac_list) {// 获取 mac地址-备注 的字典
var macDict = {};
var macElements = Array.from(mac_list).slice(1); // 跳过第一个元素
macElements.forEach(function (macElement) {
macDict[macElement.querySelectorAll('td')[1].innerText] =
macElement.querySelectorAll('td')[2].querySelector('.kv-editable-link').innerText;
});
if (window.location.href == 'https://selfsrv.ynu.edu.cn/home') {
// 将其添加到首页的在线信息中
var onlineTable = document.getElementsByClassName('kv-grid-table table table-bordered table-striped')[0];
var onlineTableHeader = document.getElementsByClassName('kv-table-header w1')[0];
onlineTableHeader.getElementsByTagName('tr')[0].innerHTML =
'<th>设备备注</th>' + onlineTableHeader.getElementsByTagName('tr')[0].innerHTML;
var onlineList = onlineTable.getElementsByTagName('tbody')[0];
for (let i = 0; i < onlineList.getElementsByTagName('tr').length; i++) {
var macAddr = onlineList.getElementsByTagName('tr')[i].getElementsByTagName('td')[5].innerText;
if (macAddr in macDict) {
onlineList.getElementsByTagName('tr')[i].innerHTML =
'<td>' + macDict[macAddr] + '</td>' + onlineList.getElementsByTagName('tr')[i].innerHTML;
}
else {
onlineList.getElementsByTagName('tr')[i].innerHTML =
'<td></td>' + onlineList.getElementsByTagName('tr')[i].innerHTML;
}
}
// 为每个<td>添加点击复制功能
onlineList.querySelectorAll('td').forEach(function (td) { ClickCopy(td); });
} else if (window.location.href.match('https:\/\/selfsrv\.ynu\.edu\.cn\/log\/detail.*')) {
// 将其添加到日志/上网明细中
var logTable = document.getElementsByClassName('kv-grid-table table table-hover table-bordered')[0];
var logTableHeader = document.getElementsByClassName('kv-table-header w0')[0];
logTableHeader.getElementsByTagName('tr')[0].innerHTML = '<th>设备备注</th>' + logTableHeader.getElementsByTagName('tr')[0].innerHTML;
var logList = logTable.getElementsByTagName('tbody')[0];
for (let i = 0; i < logList.getElementsByTagName('tr').length; i++) {
var macAddr = logList.getElementsByTagName('tr')[i].getElementsByTagName('td')[3].innerText;
if (macAddr in macDict) {
logList.getElementsByTagName('tr')[i].innerHTML =
'<td>' + macDict[macAddr] + '</td>' + logList.getElementsByTagName('tr')[i].innerHTML;
} else {
logList.getElementsByTagName('tr')[i].innerHTML =
'<td></td>' + logList.getElementsByTagName('tr')[i].innerHTML;
}
}
// 为每个<td>添加点击复制功能
logList.querySelectorAll('td').forEach(function (td) { ClickCopy(td); });
}
} else { console.error('未找到目标元素'); }
})
.catch(error => {
console.error('Error:', error);
});
}
var sidebar = document.getElementsByClassName('sidebar-menu')[0];
// 2. 自定义主题色
var localThemeColor = localStorage.getItem('YNU-selfsrv-enhance-theme-color') ? localStorage.getItem('YNU-selfsrv-enhance-theme-color') : "#3c8dbc"; // 获取先前已设置的主题色
var themeColorButton = document.createElement('li');// “自定义主题色”按钮
themeColorButton.className = 'treeview';
themeColorButton.innerHTML = '<a href="#" title="自定义主题色" ><i class="glyphicon glyphicon-heart"></i><span>自定义主题色</span></a>';
themeColorButton.addEventListener('click', function () { QueryColor("请选择主题色", 'YNU-selfsrv-enhance-theme-color'); });
sidebar.appendChild(themeColorButton);
LoadThemeColor(localThemeColor);
// 3. 自定义侧边栏颜色
var local_siderbarColor = localStorage.getItem('YNU-selfsrv-enhance-sidebar-color') ? localStorage.getItem('YNU-selfsrv-enhance-sidebar-color') : "#222d32"; // 获取先前已设置的侧边栏颜色
var sidebarColorButton = document.createElement('li');
sidebarColorButton.className = 'treeview';
sidebarColorButton.innerHTML = '<a href="#" title="自定义侧边栏颜色" ><i class="glyphicon glyphicon-tag"></i><span>自定义侧边栏颜色</span></a>';
sidebarColorButton.addEventListener('click', function () { QueryColor("请选择侧边栏颜色", 'YNU-selfsrv-enhance-sidebar-color'); });
sidebar.appendChild(sidebarColorButton);
LoadSidebarColor(local_siderbarColor);
// 4. 自定义头像
var localAvaterLink = localStorage.getItem('YNU-selfsrv-enhance-avatar-link'); // 获取先前已设置的头像链接
var avatarButton = document.createElement('li');// “更换头像”按钮
avatarButton.className = 'treeview';
avatarButton.innerHTML = '<a href="#" title="更换头像" ><i class="glyphicon glyphicon-user"></i><span>更换头像</span></a>';
avatarButton.style.backgroundColor = local_siderbarColor;
avatarButton.style.color = local_siderbarColor;
avatarButton.firstChild.style.backgroundColor = local_siderbarColor;
avatarButton.addEventListener('click', function () { QueryImage("选择头像图片", "YNU-selfsrv-enhance-avatar-link"); });
sidebar.appendChild(avatarButton);
if (localAvaterLink) { LoadAvatar(localAvaterLink); }
// 5. 自定义背景图片
var localBackgroundLink = localStorage.getItem('YNU-selfsrv-enhance-background-link'); // 获取先前已设置的背景图片链接
var backgroundButton = document.createElement('li');// “更换背景图片”按钮
backgroundButton.className = 'treeview';
backgroundButton.innerHTML = '<a href="#" title="更换背景图片" ><i class="glyphicon glyphicon-picture"></i><span>更换背景图片</span></a>';
backgroundButton.style.backgroundColor = local_siderbarColor;
backgroundButton.style.color = local_siderbarColor;
backgroundButton.firstChild.style.backgroundColor = local_siderbarColor;
backgroundButton.addEventListener('click', function () { QueryImage("选择背景图片", "YNU-selfsrv-enhance-background-link"); });
sidebar.appendChild(backgroundButton);
if (localBackgroundLink) { LoadBackground(localBackgroundLink); }
// 6. 原神,启动!
var genshinButton = document.createElement('li');
genshinButton.className = 'treeview';
genshinButton.innerHTML = '<a href="#" title="原神,启动!" ><i class="glyphicon glyphicon-fire"></i><span>原神,启动!</span></a>';
genshinButton.style.backgroundColor = local_siderbarColor;
genshinButton.style.color = local_siderbarColor;
genshinButton.firstChild.style.backgroundColor = local_siderbarColor;
genshinButton.addEventListener('click', function () {
if (!localStorage.getItem('YNU-selfsrv-enhance-genshin-mode')) {
localStorage.setItem('YNU-selfsrv-enhance-genshin-mode', 'true');
alert('原神,启动!');
} else {
localStorage.removeItem('YNU-selfsrv-enhance-genshin-mode');
alert('原神,关闭!');
}
window.location.reload();
});
sidebar.appendChild(genshinButton);
if (localStorage.getItem('YNU-selfsrv-enhance-genshin-mode')) { GenshinTheme(); }
})();