-
Notifications
You must be signed in to change notification settings - Fork 0
/
三相之力指示器&原神玩家纯度检测 beta.js
330 lines (303 loc) · 11 KB
/
三相之力指示器&原神玩家纯度检测 beta.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
// ==UserScript==
// @name 三相之力指示器&原神玩家纯度检测 Beta
// @namespace www.cber.ltd
// @version 0.6.1
// @description B站评论区自动标注原农舟玩家,依据是动态里是否有相关内容(基于原神指示器和原三相一些小的修改)及原神玩家纯度检测
// @author xulaupuz & nightswan & SnhAenIgseAl
// @match https://www.bilibili.com/video/*
// @match https://t.bilibili.com/*
// @match https://space.bilibili.com/*
// @match https://www.bilibili.com/read/*
// @match https://www.bilibili.com/opus/*
// @icon https://static.hdslb.com/images/favicon.ico
// @connect bilibili.com
// @grant GM_xmlhttpRequest
// @license MIT
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
const unknown = new Set()
//成分,可自定义
const nor = new Set()
const cj = new Set()
const cj_yuan = new Set()
const yuanyou = new Set()
const zhouyou = new Set()
const nongyou = new Set()
const yuanzhou = new Set()
const yuannong = new Set()
const nongzhou = new Set()
const yuanqiong = new Set()
const yuanbeng = new Set()
const xian = new Set()
const sanxiang = new Set()
const misan = new Set()
const yuanpi = new Set()
//关键词,可自定义
const keyword_cj = ["互动抽奖"]
const keyword_cj_yuan = ["互动抽奖 #原神#"]
const keyword_yuan = ["原神"]
const keyword_zhou = ["明日方舟"]
const keyword_nong = ["王者荣耀"]
const keyword_beng = ["崩坏"]
const keyword_qiong = ["星穹铁道"]
const keyword_xian = ["全自动", "模块", "仙驱", "先驱"]
const keyword_yuanpi = ["猴"]
//贴上标签,可自定义
const tag_nor = "【 普通丨待定 】"
const tag_cj = "【 动态抽奖 】"
const tag_cj_yuan = "【 原神动态抽奖 】"
const tag_yuan = "【 稀有丨我超,原!】"
const tag_zhou = "【 稀有丨我超,舟!】"
const tag_nong = "【 稀有丨我超,农!】"
const tag_qiong = "【 稀有丨我超,穹!】"
const tag_yuanzhou = "【 史诗丨原 & 粥!】"
const tag_yuannong = "【 史诗丨原 & 农!】"
const tag_nongzhou = "【 史诗丨农 & 舟!】"
const tag_yuanqiong = "【 神话丨原 & 穹!】"
const tag_yuanbeng = "【 神话丨原 & 崩!】"
const tag_xian = "【 仙器丨达摩克利斯之剑 】"
const tag_sanxiang = "【 传奇丨三相之力 】"
const tag_misan = "【 传奇丨三位一体 】"
const tag_yuanpi = "【 结晶丨原批 】"
//原神玩家纯度标签
const tag_mxz_1 = "【 米学长丨认识Mihoyo 】"
const tag_mxz_2 = "【 米学长丨腾讯打压 】"
const tag_mxz_3 = "【 米学长丨黑暗降临 】"
const tag_mxz_4 = "【 米学长丨国产之光 】"
const tag_mxz_5 = "【 米学长丨Mihoyo是天 】"
//标签颜色,可自定义
const tag_nor_Inner = "<b style='color: #778899'>" + tag_nor + "</b>"
const tag_cj_Inner = "<b style='color: #4dc35e'>" + tag_cj + "</b>"
const tag_cj_yuan_Inner = "<b style='background-image: -webkit-linear-gradient(left, #00e0ee, #2d97ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'>" + tag_cj_yuan + "</b>"
const tag_yuan_Inner = "<b style='color: #2d97ff'>" + tag_yuan + "</b>"
const tag_zhou_Inner = "<b style='color: #2d97ff'>" + tag_zhou + "</b>"
const tag_nong_Inner = "<b style='color: #2d97ff'>" + tag_nong + "</b>"
const tag_yuanzhou_Inner = "<b style='color: #b32ffb'>" + tag_yuanzhou + "</b>"
const tag_yuannong_Inner = "<b style='color: #b32ffb'>" + tag_yuannong + "</b>"
const tag_nongzhou_Inner = "<b style='color: #b32ffb'>" + tag_nongzhou + "</b>"
const tag_yuanqiong_Inner = "<b style='color: #fb4619'>" + tag_yuanqiong + "</b>"
const tag_yuanbeng_Inner = "<b style='color: #fb4619'>" + tag_yuanbeng + "</b>"
const tag_xian_Inner = "<b style='background-image: -webkit-linear-gradient(left, #ff00ff, #ffa500); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'>" + tag_xian + "</b>"
const tag_sanxiang_Inner = "<b style='background-image: -webkit-linear-gradient(left, #ffa500, #ff8c00); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'>" + tag_sanxiang + "</b>"
const tag_misan_Inner = "<b style='background-image: -webkit-linear-gradient(left, #ffa500, #ff8c00); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'>" + tag_misan + "</b>"
const tag_yuanpi_Inner = "<b style='background-image: -webkit-linear-gradient(left, #2d97ff, #ff00ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'>" + tag_yuanpi + "</b>"
const tag_mxz_1_Inner = "<b style='color: #4dc35e'>" + tag_mxz_1 + "</b>"
const tag_mxz_2_Inner = "<b style='color: #2d97ff'>" + tag_mxz_2 + "</b>"
const tag_mxz_3_Inner = "<b style='color: #b32ffb'>" + tag_mxz_3 + "</b>"
const tag_mxz_4_Inner = "<b style='background-image: -webkit-linear-gradient(left, #ff8c00, #fb4619); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'>" + tag_mxz_4 + "</b>"
const tag_mxz_5_Inner = "<b style='background-image: -webkit-linear-gradient(left, #00e0ee, #ff00ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'>" + tag_mxz_5 + "</b>"
const blog = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?&host_mid='
// const is_new = true
const is_new = document.getElementsByClassName('fixed-header').length != 0 ? true : false
const get_pid = (c) => {
if (is_new) {
return c.dataset['userId']
} else {
return c.children[0]['href'].replace(/[^\d]/g, "")
}
}
const get_comment_list = () => {
if (is_new) {
let lst = new Set()
for (let c of document.getElementsByClassName('user-name')) {
lst.add(c)
}
for (let c of document.getElementsByClassName('sub-user-name')) {
lst.add(c)
}
return lst
} else {
return document.getElementsByClassName('user')
}
}
console.log(is_new)
console.log("正常加载")
let jiance = setInterval(() => {
let commentlist = get_comment_list()
if (commentlist.length != 0) {
// clearInterval(jiance)
let list = Array.from(commentlist)
list.forEach(c => {
let pid = get_pid(c)
if (yuanpi.has(pid)) return
if (xian.has(pid)) return
if (misan.has(pid)) return
if (sanxiang.has(pid)) return
if (yuanqiong.has(pid)) return
if (yuanbeng.has(pid)) return
if (yuannong.has(pid)) return
if (yuanzhou.has(pid)) return
if (yuanyou.has(pid)) return
if (nongzhou.has(pid)) return
if (zhouyou.has(pid)) return
if (nongyou.has(pid)) return
if (cj.has(pid)) return
if (nor.has(pid)) return
unknown.add(pid)
//console.log(pid)
let blogurl = blog + pid
// let xhr = new XMLHttpRequest()
GM_xmlhttpRequest({
method: "get",
url: blogurl,
data: '',
headers: {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
},
onload: function(res) {
if (res.status === 200) {
//console.log('成功')
let st = JSON.stringify(JSON.parse(res.response).data)
unknown.delete(pid)
/**
* 新版B站框架
*/
/**
* 原神相关
*/
if (hasKeyword(st, keyword_yuan)) {
//原批标签
if (hasKeyword(st, keyword_yuanpi)) {
c.innerHTML += tag_yuanpi_Inner
yuanpi.add(pid)
}
//仙蛆标签
if (hasKeyword(st, keyword_xian)) {
c.innerHTML += tag_xian_Inner
xian.add(pid)
}
//米三标签
if (hasKeyword(st, keyword_beng) && hasKeyword(st, keyword_qiong)) {
c.innerHTML += tag_misan_Inner
misan.add(pid)
yuan_weight()
return
}
//三相标签
else if (hasKeyword(st, keyword_nong) && hasKeyword(st, keyword_zhou)) {
c.innerHTML += tag_sanxiang_Inner
sanxiang.add(pid)
yuan_weight()
return
}
//原穹标签
else if (hasKeyword(st, keyword_qiong)) {
c.innerHTML += tag_yuanqiong_Inner
yuanqiong.add(pid)
yuan_weight()
return
}
//原崩标签
else if (hasKeyword(st, keyword_beng)) {
c.innerHTML += tag_yuanbeng_Inner
yuanbeng.add(pid)
yuan_weight()
return
}
//原粥标签
else if (hasKeyword(st, keyword_zhou)) {
c.innerHTML += tag_yuanzhou_Inner
yuanzhou.add(pid)
yuan_weight()
return
}
//原农标签
else if (hasKeyword(st, keyword_nong)) {
c.innerHTML += tag_yuannong_Inner
yuannong.add(pid)
yuan_weight()
return
}
//原友标签
else {
c.innerHTML += tag_yuan_Inner
yuanyou.add(pid)
yuan_weight()
return
}
}
/**
* 王者荣耀相关
*/
else if (hasKeyword(st, keyword_nong)) {
//农粥标签
if (hasKeyword(st, keyword_zhou)) {
c.innerHTML += tag_nongzhou_Inner
nongzhou.add(pid)
return
}
//农友标签
else {
c.innerHTML += tag_nong_Inner
nongyou.add(pid)
return
}
}
/**
* 明日方舟相关
*/
//粥友标签
else if (hasKeyword(st, keyword_zhou)) {
c.innerHTML += tag_zhou_Inner
zhouyou.add(pid)
return
}
//抽奖标签
else if (hasKeyword(st, keyword_cj)) {
c.innerHTML += tag_cj_Inner
cj.add(pid)
return
}
//其他成分标签
else {
c.innerHTML += tag_nor_Inner
nor.add(pid)
}
//判断是否有关键词
function hasKeyword(str, keyword) {
for (let i = 0, j = keyword.length; i < j; i++) {
if (str.includes(keyword[i])) {
return true
} else {
continue
}
}
return false
}
//判断给定字符串出现次数
function getStrCount(scrstr, armstr) {
let count = 0
for (let i = 0, j = armstr.length; i < j; i++) {
while (scrstr.indexOf(armstr[i]) != -1) {
scrstr = scrstr.replace(armstr[i], "")
count++
}
}
return count
}
//原神玩家纯度检测
function yuan_weight() {
let count = getStrCount(st, keyword_yuan)
if (count >= 0 && count <= 5) c.innerHTML += tag_mxz_1_Inner
else if (count > 5 && count <= 10) c.innerHTML += tag_mxz_2_Inner
else if (count > 10 && count <= 20) c.innerHTML += tag_mxz_3_Inner
else if (count > 20 && count <= 30) c.innerHTML += tag_mxz_4_Inner
else c.innerHTML += tag_mxz_5_Inner
//原神抽奖标签
if (hasKeyword(st, keyword_cj_yuan)) {
c.innerHTML += tag_cj_yuan_Inner
cj_yuan.add(pid)
}
}
} else {
console.log('失败')
console.log(res)
}
},
});
});
}
}, 4000)
})();