-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBIT-WebVPN-删除冗余.user.js
29 lines (27 loc) · 1.31 KB
/
BIT-WebVPN-删除冗余.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
// ==UserScript==
// @name BIT-WebVPN-删除冗余
// @namespace http://tampermonkey.net/
// @version 0.2.1
// @description 删除学校名称,简化过长的名字,删除名字里重复的地址
// @license GPL-3.0-or-later
// @supportURL https://github.com/YDX-2147483647/BIT-enhanced/issues
// @author Y.D.X.
// @match https://webvpn.bit.edu.cn/
// @grant none
// ==/UserScript==
(function () {
'use strict'
// 如果修改了“我的收藏”,会重新刷新,但脚本不会重新运行,因而失效。
// 不过这种事件不常发生,所以就不考虑了……
document.querySelectorAll('.vpn-content div.vpn-content-block-panel__content > p:nth-child(1), #vpn-bastion-list .bastion-item > .bastion-item__content > .bastion-item__title').forEach(e => {
e.textContent = e.textContent.replace('北京理工大学', '').replace(/系统$/, '')
const address = e.parentNode.lastElementChild.textContent
const redundant_address = e.textContent.match(/[0-9a-zA-Z.]+/)
if (redundant_address) {
if (address.includes(redundant_address[0]) && e.textContent !== redundant_address[0]) {
e.textContent = e.textContent.replace(redundant_address[0], '')
}
}
e.textContent = e.textContent.replace(/^[_-]/, '').replace(/[_-]$/, '')
})
})()