-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopt-gitblock.user.js
More file actions
164 lines (154 loc) · 6 KB
/
opt-gitblock.user.js
File metadata and controls
164 lines (154 loc) · 6 KB
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
// ==UserScript==
// @name Opt Gitblock
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Opt Gitblock JS
// @author HardJerry
// @match *://*.gitblock.cn/*
// @match *://*.aerfaying.com/*
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_listValues
// ==/UserScript==
(function () {
//================== Global Func =====================
$("body").prepend(`
<script>function dat_alert(title,name,useTime,markdown) {
$("body").after(\`
<div class="ReactModalPortal" id="DAT_AlertWindow">
<div class="ReactModal__Overlay ReactModal__Overlay--after-open modal_modal-overlay_2_Dgx" aria-modal="true">
<div class="ReactModal__Content ReactModal__Content--after-open modal_modal-content_3brCX" tabindex="-1">
<div class="box_box_tWy-0" style="flex-direction: column; flex-grow: 1;">
<div class="modal_header_1dNxf" style="height: 3.125rem;">
<div class="modal_header-item_1WbOm modal_header-item-title_1N2BE">\`+title+\`</div>
<div class="modal_header-item_1WbOm modal_header-item-close_4akWi">
<div aria-label="Close" class="close-button_close-button_t5jqt close-button_large_2cCrv"
role="button" tabindex="0" onclick="$('#DAT_AlertWindow').remove();"><img
class="close-button_close-icon_ywCI5"
src="https://cdn.gitblock.cn/static/images/cb666b99d3528f91b52f985dfb102afa.svg"></div>
</div>
</div>
<div class="body box_box_tWy-0">
<div class="item-attached-thin-modal-body_wrapper_3KdPz">
<div>
<h1 class="item-attached-thin-modal-body_name_p9cDj">\`+name+\`</h1>
<div><span>\`+useTime+\`</span></div>
</div>
</div>
<div class="markdown_body_1wo0f item-isolator-modal_declarationDescp_2g62z">
<div class="content">
\`+markdown+\`
</div>
</div>
</div>
</div>
</div>
</div>
</div>\`);
}
</script>`);
//================== Domain Redirect =====================
var url = window.location.href;
if (url.search("aerfaying.com") != -1) {
window.location.assign(window.location.href.replace("aerfaying.com", "gitblock.cn"));
}
//================== Redlist =====================
if (url.search("/Users/") != -1) {
//console.log("In user home, verify redlist");
var libraLib = {
isInList: function (id) {
$.ajax({
url: "https://www.scpo.top:1120/v2",
data: {
method: "isInList",
platform: "acamp",
format: "id",
value: id,
},
success: function (result) {
//console.log(result);
if (result["message"] == "success") {
if (result["status"] == true) {
alert("此人在红名单中,原因是:\n" + result["reason"]);
}
}
},
});
},
};
libraLib.isInList(url.split("/")[4]);
}
//================== Comment ID =====================
const COMMENT_ID_CLASS = 'dat_comment_id';
const COMMENT_CLASS = 'comment_comment_P_hgY';
GM_addStyle(`
.${COMMENT_ID_CLASS} {
display: inline;
color: #888888;
margin: 0 0.5rem;
font-size: 12px;
transition: color 0.1s ease;
};
.${COMMENT_ID_CLASS}:hover {
color: #4C97FF !important;
transition: color 0.1s ease;
};
`);
setInterval(() => {
var comments = $('.' + COMMENT_CLASS);
comments.each(function () {
var cidel = $('.' + COMMENT_ID_CLASS, this);
if (cidel.length === 0) {
var commentId = this.id;
$('> div.comment_info_2Sjc0 > div:nth-child(2)', this).append(
` <a href="` + location.pathname + `#commentId=` + commentId + `" class="` + COMMENT_ID_CLASS + `">Comment</a>`);
}
});
}, 2500);
//================== View Markdown =====================
setInterval(() => {
intervalFunc_ViewMarkdown();
}, 2500);
function intervalFunc_ViewMarkdown() {
if ($(".panel2_panelHead_1Bn6y.panel-head:contains('个人简介')").length != 0 && $("#dat_viewmd").length == 0) {
$(".panel2_panelHead_1Bn6y.panel-head:contains('个人简介')").children("h2").append(`
<a id="dat_viewmd">Markdown</a>`);
$("#dat_viewmd").click(function (e) {
var uid = url.split("/")[4];
$.ajax({
url: "/WebApi/Users/" + uid + "/Get",
type: "POST",
async: false,
success: function (result) {
var markdown = "<pre><code>" + result.user.abstract.replace(/\n/g, "</br>") + "</code></pre>";
dat_alert("Markdown 源代码", result.user.username, "#" + uid, markdown);
},
});
})
}
}
//================== 阻止滚轮 =====================
var button;
if(window.location.href.search("kada.163.com") != -1) {
button = "stage-header_stage-button-icon_3zzFK";
}else if(window.location.href.search(/(gitblock.cn)|(aerfaying.com)/) != -1) {
button = "stage-header_stage-button-icon_1SHv0";
}else if(window.location.href.search("ccw.site") != -1) {
button = "stage-header_stage-button-icon_3zzFK";
}
var scrollFunction = function(e) {
if(document.getElementsByClassName(button).length > 0) {
if(document.getElementsByClassName(button)[0].alt == "退出全屏模式"){
e = e || window.event;
e.preventDefault && e.preventDefault();
}
}
}
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll', scrollFunction, false);
}
window.addEventListener('mousewheel', scrollFunction, {
passive: false
});
})();