-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathBiLiveNoVIP.user.js
1304 lines (1302 loc) · 43.5 KB
/
BiLiveNoVIP.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
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name bilibili直播净化
// @namespace https://github.com/lzghzr/GreasemonkeyJS
// @version 4.3.1
// @author lzghzr
// @description 增强直播屏蔽功能, 提高直播观看体验
// @icon data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTUiIHN0cm9rZT0iIzAwYWVlYyIgc3Ryb2tlLXdpZHRoPSIyIiBmaWxsPSJub25lIi8+PHRleHQgZm9udC1mYW1pbHk9Ik5vdG8gU2FucyBDSksgU0MiIGZvbnQtc2l6ZT0iMjIiIHg9IjUiIHk9IjIzIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMCIgZmlsbD0iIzAwYWVlYyI+5ruaPC90ZXh0Pjwvc3ZnPg==
// @supportURL https://github.com/lzghzr/GreasemonkeyJS/issues
// @match https://live.bilibili.com/*
// @match https://www.bilibili.com/blackboard/*
// @license MIT
// @require https://unpkg.com/[email protected]/dist/ajaxhook.min.js
// @require https://unpkg.com/[email protected]/crypto-js.js
// @require https://unpkg.com/[email protected]/crc32.js
// @compatible chrome 基础功能需要 88 以上支持 :not() 伪类,高级功能需要 105 及以上支持 :has() 伪类
// @compatible edge 基础功能需要 88 以上支持 :not() 伪类,高级功能需要 105 及以上支持 :has() 伪类
// @compatible firefox 基础功能需要 84 以上支持 :not() 伪类,高级功能需要 121 及以上支持 :has() 伪类
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
const W = typeof unsafeWindow === 'undefined' ? window : unsafeWindow;
class DB {
dbName;
objectStoreName;
keyPath;
db;
constructor(dbName, objectStoreName, keyPath) {
this.dbName = dbName;
this.objectStoreName = objectStoreName;
this.keyPath = keyPath;
}
open(store) {
return new Promise((resolve, reject) => {
const request = indexedDB.open(this.dbName);
request.onerror = () => {
reject(request.error);
};
request.onsuccess = () => {
this.db = request.result;
resolve(request.result);
};
request.onupgradeneeded = () => {
this.db = request.result;
if (!this.db.objectStoreNames.contains(this.objectStoreName)) {
const objectStore = this.db.createObjectStore(this.objectStoreName, { keyPath: this.keyPath });
store.forEach(vaule => {
objectStore.createIndex(vaule[0], vaule[0], { unique: vaule[1] });
});
}
};
});
}
putData(data) {
return new Promise((resolve, reject) => {
const store = this.db.transaction([this.objectStoreName], 'readwrite').objectStore(this.objectStoreName);
const request = store.put(data);
request.onerror = () => {
reject(request.error);
};
request.onsuccess = () => {
resolve();
};
});
}
getData(key) {
return new Promise((resolve, reject) => {
const store = this.db.transaction([this.objectStoreName], 'readonly').objectStore(this.objectStoreName);
const request = store.get(key);
request.onerror = () => {
reject(request.error);
};
request.onsuccess = () => {
resolve(request.result);
};
});
}
}
class Tools {
static str2Fn(str) {
const fnReg = str.match(/([^\{]*)\{(.*)\}$/s);
if (fnReg !== null) {
const [, head, body] = fnReg;
const args = head.replaceAll(/function[^\(]*|[\s()=>]/g, '').split(',');
return new Function(...args, body);
}
}
static isAllBitsSet(value) {
if (value === 0) {
return false;
}
return (value & (value + 1)) === 0;
}
static scriptName(name) {
return [
`%c${GM_info.script.name}%c ${name}`,
"font-weight: bold; color: white; background-color: #FF6699; padding: 1px 4px; border-radius: 4px;",
"font-weight: bold; color: #FF6699;"
];
}
static sleep(ms) {
return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
}
static crc32(num) {
return (CRC32.str(num.toString()) >>> 0).toString(16);
}
static md5(str) {
return CryptoJS.MD5(str).toString(CryptoJS.enc.Hex);
}
}
class NoVIP {
elmStyleCSS;
chatObserver;
danmakuObserver;
defaultConfig = {
version: 1734189210657,
menu: {
noGiftMsg: {
name: '屏蔽礼物相关',
replace: '屏蔽全部礼物及广播',
enable: false
},
noSystemMsg: {
name: '屏蔽系统消息',
replace: '屏蔽进场信息',
enable: false
},
noSuperChat: {
name: '屏蔽醒目留言',
replace: '屏蔽醒目留言',
enable: false
},
noEmoticons: {
name: '屏蔽表情聊天',
replace: '屏蔽表情动画(右下角)',
enable: false
},
noEmotDanmaku: {
name: '屏蔽表情弹幕',
replace: '屏蔽表情弹幕',
enable: false
},
noLikeBtn: {
name: '屏蔽点赞按钮',
enable: false
},
noGiftControl: {
name: '屏蔽活动控件',
enable: false
},
noGuardIcon: {
name: '屏蔽舰队标识',
enable: false
},
noWealthMedalIcon: {
name: '屏蔽荣耀勋章',
enable: false
},
noFansMedalIcon: {
name: '屏蔽粉丝勋章',
enable: false
},
noLiveTitleIcon: {
name: '屏蔽成就头衔',
enable: false
},
noRaffle: {
name: '屏蔽抽奖橱窗',
enable: false
},
noDanmakuColor: {
name: '屏蔽弹幕颜色',
enable: false
},
noGameId: {
name: '屏蔽互动游戏',
enable: false
},
noBBChat: {
name: '屏蔽刷屏聊天',
enable: false
},
noBBDanmaku: {
name: '屏蔽刷屏弹幕',
enable: false
},
noRoomSkin: {
name: '屏蔽房间皮肤',
enable: false
},
noActivityPlat: {
name: '屏蔽活动皮肤',
enable: false
},
noRoundPlay: {
name: '屏蔽视频轮播',
enable: false
},
noSleep: {
name: '屏蔽挂机检测',
enable: false
},
rankInvisible: {
name: '在线榜单隐身',
enable: false
},
invisible: {
name: '进场隐身观看',
enable: false
}
}
};
config;
replaceMenu = new Set();
rankInvisible = true;
userInfoDB;
message = [];
constructor() {
const userConfig = GM_getValue('blnvConfig', null) === null ? this.defaultConfig : JSON.parse(decodeURI(GM_getValue('blnvConfig')));
if (userConfig.version === undefined || userConfig.version < this.defaultConfig.version) {
for (const x in this.defaultConfig.menu) {
try {
this.defaultConfig.menu[x].enable = userConfig.menu[x].enable;
}
catch (error) {
console.error(...Tools.scriptName('载入配置失效'), error);
}
}
this.config = this.defaultConfig;
}
else {
this.config = userConfig;
}
for (const x in this.config.menu) {
this.replaceMenu.add(this.config.menu[x].replace);
}
}
init() {
W.getComputedStyle = new Proxy(W.getComputedStyle, {
apply: function (target, _this, args) {
if (args !== undefined && args[0] instanceof HTMLElement) {
let htmlEle = Reflect.apply(target, _this, args);
htmlEle = new Proxy(htmlEle, {
get: function (_target, propertyKey) {
if (propertyKey === 'display' && _target[propertyKey] === 'none') {
return 'block';
}
return Reflect.get(_target, propertyKey);
}
});
return htmlEle;
}
return Reflect.apply(target, _this, args);
}
});
Object.defineProperty(W, '__NEPTUNE_IS_MY_WAIFU__', {});
this.replaceFunction();
}
replaceFunction() {
const that = this;
let push = 1 << 5;
W.webpackChunklive_room = W.webpackChunklive_room || [];
W.webpackChunklive_room.push = new Proxy(W.webpackChunklive_room.push, {
apply: function (target, _this, args) {
for (const [name, fn] of Object.entries(args[0][1])) {
let fnStr = fn.toString();
if (fnStr.includes('staticClass:"block-effect-icon-root"')) {
const regexp = /(?<left>staticClass:"block-effect-icon-root"\},\[)"on"===(?<mut_t>\w+)\.blockEffectStatus\?(?<svg>(?<mut_n>\w+)\("svg".*?)\[\k<mut_n>\("path".*?blockEffectIconColor\}\}\)\]/s;
const match = fnStr.match(regexp);
if (match !== null) {
fnStr = fnStr.replace(regexp, '$<left>$<svg>\[\
$<mut_n>("circle",{attrs:{cx:"12",cy:"12",r:"10",stroke:$<mut_t>.blockEffectIconColor,"stroke-width":"1.5",fill:"none"}}),\
$<mut_t>._v(" "),\
$<mut_n>("text",{attrs:{"font-family":"Noto Sans CJK SC","font-size":"14",x:"5",y:"17",fill:$<mut_t>.blockEffectIconColor}},[$<mut_t>._v("滚")])\
]');
console.info(...Tools.scriptName('脚本 icon 已加载'));
}
else {
console.error(...Tools.scriptName('插入脚本 icon 失效'), fnStr);
}
push |= 1 << 0;
}
if (fnStr.includes('return this.chatList.children.length')) {
const regexp = /(?<left>return )this\.chatList\.children\.length/s;
const match = fnStr.match(regexp);
if (match !== null) {
fnStr = fnStr.replace(regexp, '$<left>this.chatList.querySelectorAll(".danmaku-item:not(.NoVIP_hide)").length');
console.info(...Tools.scriptName('增强聊天显示 已加载'));
}
else {
console.error(...Tools.scriptName('增强聊天显示失效'), fnStr);
}
push |= 1 << 1;
}
if (that.config.menu.noRoundPlay.enable) {
if (fnStr.includes('case"PREPARING":')) {
const regexp = /(?<left>case"PREPARING":)(?<right>[^;]+\((?<mut>\w+)\);break;)/s;
const match = fnStr.match(regexp);
if (match !== null) {
fnStr = fnStr.replace(regexp, '$<left>$<mut>.round=0;$<right>');
console.info(...Tools.scriptName('屏蔽下播轮播 已加载'));
}
else {
console.error(...Tools.scriptName('屏蔽下播轮播失效'), fnStr);
}
push |= 1 << 2;
}
}
else {
push |= 1 << 2;
}
if (that.config.menu.noSleep.enable) {
if (fnStr.includes('prototype.sleep=function(')) {
const regexp = /(?<left>prototype\.sleep=function\(\w*\){)/;
const match = fnStr.match(regexp);
if (match !== null) {
fnStr = fnStr.replace(regexp, '$<left>return;');
console.info(...Tools.scriptName('屏蔽挂机检测 已加载'));
}
else {
console.error(...Tools.scriptName('屏蔽挂机检测失效'), fnStr);
}
push |= 1 << 3;
}
}
else {
push |= 1 << 3;
}
if (that.config.menu.rankInvisible.enable) {
if (fnStr.includes('this.enterRoomTracker=new ')) {
const regexp = /(?<left>this\.enterRoomTracker=new \w+),/s;
const match = fnStr.match(regexp);
if (match !== null) {
fnStr = fnStr.replace(regexp, '$<left>,this.enterRoomTracker.report=()=>{},');
console.info(...Tools.scriptName('在线榜单隐身 已加载'));
}
else {
console.error(...Tools.scriptName('在线榜单隐身失效'), fnStr);
}
push |= 1 << 4;
}
}
else {
push |= 1 << 4;
}
if (fn.toString() !== fnStr) {
args[0][1][name] = Tools.str2Fn(fnStr);
}
if (Tools.isAllBitsSet(push)) {
W.webpackChunklive_room.push = target;
break;
}
}
return Reflect.apply(target, _this, args);
}
});
if (this.config.menu.rankInvisible.enable
|| this.config.menu.noRoundPlay.enable) {
Array.prototype.concat = new Proxy(Array.prototype.concat, {
apply: function (target, _this, args) {
if (args[0] && args[0] instanceof Object && args[0].cmd) {
const command = args[0];
if (that.config.menu.rankInvisible.enable) {
if (command.cmd.startsWith('DANMU_MSG')) {
const user = command.info[0][15].user;
if (user.uid !== 0) {
that.addUserInfo([{ uid: user.uid, name: user.base.name }]);
}
else if (that.userInfoDB !== undefined) {
args[0] = [];
that.userInfoDB.getData(command.info[0][7]).then(userInfo => {
if (userInfo !== undefined) {
command.info[2][0] = userInfo.uid;
command.info[2][1] = userInfo.name;
user.uid = userInfo.uid;
user.base.name = userInfo.name;
}
that.message.push(command);
});
}
}
else if (command?.data?.uinfo?.uid !== 0 && command?.data?.uinfo?.base?.name) {
that.addUserInfo([{ uid: command.data.uinfo.uid, name: command.data.uinfo.base.name }]);
}
if (that.message.length !== 0) {
args.push(that.message);
that.message = [];
}
}
if (that.config.menu.noRoundPlay.enable) {
if (command.cmd === 'PREPARING') {
command.round = 0;
}
}
}
return Reflect.apply(target, _this, args);
}
});
}
if (this.config.menu.rankInvisible.enable) {
JSON.stringify = new Proxy(JSON.stringify, {
apply: function (target, _this, args) {
if (args[0] && args[0] instanceof Object) {
const value = args[0];
if (that.config.menu.rankInvisible.enable && that.rankInvisible) {
if (value.uid && value.roomid && value.protover == 3) {
value.uid = 0;
}
}
}
return Reflect.apply(target, _this, args);
}
});
}
if (this.config.menu.rankInvisible.enable
|| this.config.menu.invisible.enable
|| this.config.menu.noRoomSkin.enable
|| this.config.menu.noRoundPlay.enable) {
ah.proxy({
onRequest: (XHRconfig, handler) => {
if (this.config.menu.rankInvisible.enable && this.rankInvisible) {
if (XHRconfig.url.includes('/xlive/web-room/v1/index/getDanmuInfo')) {
XHRconfig.withCredentials = false;
console.info(...Tools.scriptName('在线榜单隐身 已拦截'));
}
}
if (this.config.menu.invisible.enable) {
if (XHRconfig.url.includes('/xlive/web-room/v1/index/getInfoByUser')) {
XHRconfig.url = XHRconfig.url.replace('not_mock_enter_effect=0', 'not_mock_enter_effect=1');
console.info(...Tools.scriptName('隐藏进场信息 已拦截'));
}
}
handler.next(XHRconfig);
},
onResponse: async (XHRresponse, handler) => {
if (this.config.menu.noRoomSkin.enable) {
if (XHRresponse.config.url.includes('/xlive/app-room/v2/guardTab/topList')) {
XHRresponse.response = XHRresponse.response.replace(/"anchor_guard_achieve_level":\d+/, '"anchor_guard_achieve_level":0');
console.info(...Tools.scriptName('屏蔽大航海榜单背景图 已拦截'));
}
}
if (that.config.menu.noRoundPlay.enable || that.config.menu.rankInvisible.enable) {
if (XHRresponse.config.url.includes('/xlive/web-room/v2/index/getRoomPlayInfo')) {
const body = JSON.parse(XHRresponse.response);
if (that.config.menu.noRoundPlay.enable) {
if (body.data.live_status == 2) {
body.data.live_status = 0;
}
console.info(...Tools.scriptName('屏蔽视频轮播 已拦截'));
}
if (that.config.menu.rankInvisible.enable) {
await that.getRank(body.data.room_id, body.data.uid);
console.info(...Tools.scriptName('在线榜单隐身 已添加'));
}
XHRresponse.response = JSON.stringify(body);
}
}
if (this.config.menu.noRoundPlay.enable) {
if (XHRresponse.config.url.includes('/live/getRoundPlayVideo')) {
XHRresponse.status = 403;
console.info(...Tools.scriptName('屏蔽视频轮播 已拦截'));
}
}
handler.next(XHRresponse);
}
}, W);
const checkHookFetchAlive = async () => {
this.hookFetch();
for (let i = 0; i < 50; i++) {
await W.fetch('//blnv_test_fetch_hook_alive/').catch(() => { this.hookFetch(); });
await Tools.sleep(100);
}
};
checkHookFetchAlive();
}
}
hookFetch() {
const that = this;
W.fetch = new Proxy(W.fetch, {
apply: async function (target, _this, args) {
const resource = args[0];
let url = (resource instanceof Request) ? resource.url : resource;
if (that.config.menu.rankInvisible.enable && that.rankInvisible) {
if (url.includes('/xlive/web-room/v1/index/getDanmuInfo')) {
args[1] ? args[1].credentials = 'same-origin' : args[1] = { credentials: 'same-origin' };
console.info(...Tools.scriptName('在线榜单隐身 已拦截'));
}
}
if (that.config.menu.invisible.enable) {
if (url.includes('/xlive/web-room/v1/index/getInfoByUser')) {
url = url.replace('not_mock_enter_effect=0', 'not_mock_enter_effect=1');
args[0] = (resource instanceof Request) ? new Request(url, resource) : url;
console.info(...Tools.scriptName('隐藏进场信息 已拦截'));
}
}
if (that.config.menu.noRoomSkin.enable) {
if (url.includes('/xlive/app-room/v2/guardTab/topList')) {
const response = await Reflect.apply(target, _this, args);
const body = await response.json();
body.data.info.anchor_guard_achieve_level = 0;
const newResponse = new Response(JSON.stringify(body));
console.info(...Tools.scriptName('屏蔽大航海榜单背景图 已拦截'));
return newResponse;
}
}
if (that.config.menu.noRoundPlay.enable || that.config.menu.rankInvisible.enable) {
if (url.includes('/xlive/web-room/v2/index/getRoomPlayInfo')) {
const response = await Reflect.apply(target, _this, args);
const body = await response.json();
if (that.config.menu.noRoundPlay.enable) {
if (body.data.live_status == 2) {
body.data.live_status = 0;
}
console.info(...Tools.scriptName('屏蔽视频轮播 已拦截'));
}
if (that.config.menu.rankInvisible.enable) {
await that.getRank(body.data.room_id, body.data.uid);
console.info(...Tools.scriptName('在线榜单隐身 已添加'));
}
const newResponse = new Response(JSON.stringify(body));
return newResponse;
}
}
if (that.config.menu.noRoundPlay.enable) {
if (url.includes('/live/getRoundPlayVideo')) {
const response = await Reflect.apply(target, _this, args);
const newResponse = new Response(response.body, {
status: 403,
statusText: 'Forbidden',
headers: response.headers
});
console.info(...Tools.scriptName('屏蔽视频轮播 已拦截'));
return newResponse;
}
}
if (url.includes('//blnv_test_fetch_hook_alive/')) {
return new Response('success');
}
return Reflect.apply(target, _this, args);
}
});
}
start() {
this.elmStyleCSS = GM_addStyle('');
this.addCSS();
const chatMessage = new Map();
this.chatObserver = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(addedNode => {
if (addedNode instanceof HTMLDivElement && addedNode.classList.contains('danmaku-item')) {
const chatNode = addedNode.querySelector('.danmaku-item-right');
if (chatNode !== null) {
const chatText = chatNode.innerText;
const dateNow = Date.now();
if (chatMessage.has(chatText) && dateNow - chatMessage.get(chatText) < 10_000) {
addedNode.classList.add('NoVIP_chat_hide');
}
else {
chatMessage.set(chatText, dateNow);
}
}
}
});
});
});
const elmDivChatList = document.querySelector('#chat-items');
if (elmDivChatList !== null) {
this.chatObserver.observe(elmDivChatList, { childList: true });
}
const danmakuMessage = new Map();
this.danmakuObserver = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(addedNode => {
const danmakuNode = addedNode instanceof Text ? addedNode.parentElement : addedNode;
if (danmakuNode?.classList?.contains('danmaku-item-container')) {
this.danmakuObserver.disconnect();
this.danmakuObserver.observe(danmakuNode, { childList: true });
}
else if (danmakuNode?.classList?.contains('bili-danmaku-x-dm')) {
danmakuNode.addEventListener('animationstart', () => {
const danmakuText = danmakuNode.innerText.split(/ ?[x×]\d+$/);
const dateNow = Date.now();
if (danmakuMessage.has(danmakuText[0]) && dateNow - danmakuMessage.get(danmakuText[0]) < 10_000) {
danmakuNode.classList.add('NoVIP_danmaku_hide');
}
else if (danmakuText[1] !== undefined) {
danmakuNode.classList.add('NoVIP_danmaku_hide');
}
else {
danmakuMessage.set(danmakuText[0], dateNow);
}
});
}
});
});
});
const elmDivDanmaku = document.querySelector('#live-player');
if (elmDivDanmaku !== null) {
this.danmakuObserver.observe(elmDivDanmaku, { childList: true, subtree: true });
}
setInterval(() => {
const dateNow = Date.now();
chatMessage.forEach((value, key) => {
if (dateNow - value > 60_000) {
chatMessage.delete(key);
}
});
danmakuMessage.forEach((value, key) => {
if (dateNow - value > 60_000) {
danmakuMessage.delete(key);
}
});
}, 60_000);
const docObserver = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(addedNode => {
if (addedNode instanceof HTMLDivElement) {
if (addedNode.classList.contains('dialog-ctnr')) {
const blockEffectCtnr = addedNode.querySelector('.block-effect-ctnr');
if (blockEffectCtnr !== null) {
this.addUI(blockEffectCtnr);
}
}
}
});
});
});
docObserver.observe(document, { childList: true, subtree: true });
const blcok = localStorage.getItem('LIVE_BLCOK_EFFECT_STATE');
if (blcok !== null) {
const block = blcok.split(',').filter(item => item === '2' || item === '9');
localStorage.setItem('LIVE_BLCOK_EFFECT_STATE', block.join(','));
}
this.changeCSS();
}
noRoomSkin() {
if (this.config.menu.noRoomSkin.enable) {
W.roomBuffService.__NORoomSkin = true;
W.roomBuffService.unmount();
}
else {
W.roomBuffService.__NORoomSkin = false;
W.roomBuffService.mount(W.roomBuffService.__NORoomSkin_skin);
}
}
changeCSS() {
let height = 62;
let cssText = `
/* 统一用户名颜色 */
.chat-item .user-name {
color: var(--brand_blue) !important;
}`;
if (this.config.menu.noGuardIcon.enable) {
cssText += `
/* 聊天背景 */
.chat-item.chat-colorful-bubble {
background-color: unset !important;
border-image-source: unset !important;
border-radius: unset !important;
display: block !important;
margin: unset !important;
}
/* 聊天背景 */
.chat-item.chat-colorful-bubble div:has(div[style*="border-image-source"]),
/* 欢迎提示条 */
#welcome-area-bottom-vm,
/* 粉丝勋章内标识 */
.chat-item .fans-medal-item-ctnr .medal-guard,
/* 舰队指挥官标识 */
.chat-item .pilot-icon,
.chat-item .pilot-icon ~ br,
/* 订阅舰长 */
.chat-item.guard-buy {
display: none !important;
}
/* 兼容chrome 105以下版本 */
@supports not selector(:has(a, b)) {
.chat-item.chat-colorful-bubble div[style*="border-image-source"] {
display: none !important;
}
}`;
}
if (this.config.menu.noWealthMedalIcon.enable) {
cssText += `
/* 聊天背景, 存疑 */
.chat-item.wealth-bubble {
border-image-source: unset !important;
}
/* 聊天背景, 存疑 */
.chat-item.has-bubble {
border-image-source: unset !important;
border-image-slice: unset !important;
border-image-width: unset !important;
box-sizing: unset !important;
display: block !important;
margin: unset !important;
}
.chat-item.has-bubble .danmaku-item-left > br,
/* 欢迎提示条 */
#welcome-area-bottom-vm,
/* 弹幕 */
.bili-danmaku-x-dm > .bili-icon,
/* 聊天 */
.chat-item .wealth-medal-ctnr {
display: none !important;
}`;
}
if (this.config.menu.noGiftMsg.enable) {
height -= 32;
cssText += `
/* 底部小礼物, 调整高度 */
.chat-history-list.with-penury-gift {
height: 100% !important;
}
/* 热门流量推荐 */
.chat-item.hot-rank-msg,
/* VIP标识 */
#activity-welcome-area-vm,
.chat-item .vip-icon,
.chat-item.welcome-msg,
/* 高能标识 */
.chat-item.top3-notice,
.chat-item .rank-icon,
/* 分享直播间 */
.chat-item.important-prompt-item,
/* 礼物栏 */
.gift-control-panel > *:not(.left-part-ctnr),
#web-player__bottom-bar__container,
/* 礼物按钮 */
#web-player-controller-wrap-el .web-live-player-gift-icon-wrap,
/* 主播心愿 */
.gift-wish-card-root,
#chat-gift-bubble-vm,
#penury-gift-msg,
#gift-screen-animation-vm,
#my-dear-haruna-vm .super-gift-bubbles,
.chat-item.gift-item,
.chat-item.system-msg,
.web-player-inject-wrap .announcement-wrapper,
.bilibili-live-player-video-operable-container>div:first-child>div:last-child,
.bilibili-live-player-video-gift,
.bilibili-live-player-danmaku-gift {
display: none !important;
}`;
}
if (this.config.menu.noSystemMsg.enable) {
height -= 30;
cssText += `
.chat-history-list.with-brush-prompt {
height: 100% !important;
}
/* 目前只看到冲榜提示 */
.chat-history-panel #all-guide-cards,
/* 聊天下方滚动消息,进场、点赞之类的 */
#brush-prompt,
/* 初始系统提示 */
.chat-item.convention-msg,
/* 各种野生消息 */
.chat-item.common-danmuku-msg,
/* 各种野生消息 x2 */
.chat-item.misc-msg,
/* 各种野生消息 x3 (Toasts) */
.link-toast,
/* pk */
.chat-item.new-video-pk-item-dm {
display: none !important;
}`;
}
if (this.config.menu.noSuperChat.enable) {
cssText += `
/* 调整 SuperChat 聊天框 */
.chat-history-list {
padding-top: 5px !important;
}
.chat-item.superChat-card-detail {
margin-left: unset !important;
margin-right: unset !important;
min-height: unset !important;
}
.chat-item .card-item-middle-top {
background-color: unset !important;
background-image: unset !important;
border: unset !important;
display: inline !important;
padding: unset !important;
}
.chat-item .card-item-middle-top-right {
display: unset !important;
}
.chat-item .superChat-base {
display: unset !important;
height: unset !important;
line-height: unset !important;
vertical-align: unset !important;
width: unset !important;
}
.chat-item .superChat-base .fans-medal-item-ctnr {
margin-right: 4px !important;
}
.chat-item .name,
.chat-item .card-item-name {
display: unset !important;
font-size: unset !important;
font-weight: unset !important;
height: unset !important;
line-height: 20px !important;
margin-left: unset !important;
opacity: unset !important;
overflow: unset !important;
text-overflow: unset !important;
vertical-align: unset !important;
white-space: unset !important;
width: unset !important;
}
.chat-item .card-item-name>span {
color: var(--brand_blue) !important;
}
/* 为 SuperChat 用户名添加 : */
.chat-item.superChat-card-detail .name:after,
.chat-item.superChat-card-detail .card-item-name>span:after {
content: ' : ';
}
.chat-item .card-item-middle-bottom {
background-color: unset !important;
display: unset !important;
padding: unset !important;
}
.chat-item .input-contain {
display: unset !important;
}
.chat-item .text {
color: var(--text2) !important;
}
/* SuperChat 提示条 */
#chat-msg-bubble-vm,
/* SuperChat 保留条 */
#pay-note-panel-vm,
.chat-item .bottom-background,
/* SuperChat 聊天条 右上角电池 */
.chat-item .card-item-top-right,
/* SuperChat 按钮 */
#chat-control-panel-vm .super-chat {
display: none !important;
}`;
}
if (this.config.menu.noEmoticons.enable) {
cssText += `
#chat-control-panel-vm .emoticons-panel,
.chat-item.chat-emoticon {
display: none !important;
}`;
}
if (this.config.menu.noEmotDanmaku.enable) {
cssText += `
.bili-danmaku-x-dm > img:not(.bili-icon) {
display: none !important;
}`;
}
if (this.config.menu.noLikeBtn.enable) {
cssText += `
/* 点赞按钮 */
#chat-control-panel-vm .like-btn,
/* 点赞消息 */
.chat-item[data-type="6"],
/* 点赞数 */
#head-info-vm .icon-ctnr:has(.like-icon) {
display: none !important;
}
/* 兼容chrome 105以下版本 */
@supports not selector(:has(a, b)) {
#head-info-vm .like-icon,
#head-info-vm .like-text {
display: none !important;
}
}`;
}
if (this.config.menu.noGiftControl.enable) {
cssText += `
/* 排行榜 */
.rank-list-section .gift-rank-cntr .top3-cntr .default,
.rank-list-section .guard-rank-cntr:not(.open) .guard-empty {
height: 42px !important;
}
.rank-list-section .guard-rank-cntr:not(.open) .guard-empty {
background-size: contain !important;
background-position: center !important;
background-repeat: no-repeat !important;
}
.rank-list-section .gift-rank-cntr .top3-cntr .default-msg {
bottom: -12px !important;
}
.rank-list-section,
.rank-list-section.new .rank-list-ctnr[style*="height: 178px;"] {
height: 98px !important;
}
.rank-list-section .tab-content,
.rank-list-section .tab-content-pilot,
.rank-list-section.new .guard-rank-cntr .rank-list-cntr {
min-height: unset !important;
}
.rank-list-section .tab-content[style*="height: 9"],
.rank-list-section .tab-content-pilot[style*="height: 9"],
.rank-list-section .gift-rank-cntr .top3-cntr {
height: 64px !important;
}
.rank-list-section .guard-rank-cntr .top3-cntr > span {
height: 32px !important;
}
.rank-list-section.new .gift-rank-cntr .top3-cntr,
.rank-list-section.new .guard-rank-cntr {
height: unset !important;
}
.rank-list-section.new .gift-rank-cntr .top3-cntr {
padding-top: 5px !important;
}
.rank-list-section.new .guard-rank-cntr .top3-cntr {
top: 15px !important;
}
/* 调整聊天区 */
.chat-history-panel {
height: calc(100% - 145px) !important;
padding-bottom: 0px !important;
}
/* 有些直播间没有排行榜 */
.rank-list-section~.chat-history-panel {
height: calc(100% - 98px - 145px) !important;
}
/* 有些直播间 .chat-history-panel 没有 .new */
#aside-area-vm:has(.control-panel-ctnr-new) .chat-history-panel {
height: calc(100% - 114px) !important;
}
#aside-area-vm:has(.control-panel-ctnr-new) .rank-list-section~.chat-history-panel {
height: calc(100% - 98px - 114px) !important;
}
.player-full-win #aside-area-vm:has(.control-panel-ctnr-new) .chat-history-panel {
height: calc(100% - 104px) !important;
}
#aside-area-vm:has(.control-panel-ctnr-new) #chat-control-panel-vm {
height: 114px !important;
}
#chat-control-panel-vm .control-panel-ctnr-new {
padding-top: 5px !important;
}
#chat-control-panel-vm .chat-input-ctnr-new {
margin-top: 5px !important;
}
#chat-control-panel-vm .control-panel-ctnr-new .danmakuPreference,
#chat-control-panel-vm .control-panel-ctnr-new .blockSetting,
#chat-control-panel-vm .control-panel-ctnr-new .effectBlock {
bottom: 114px !important;
}
/* 直播分区 */
.live-area {
display: flex !important;
}
/* 排行榜 */
.rank-list-section.new .gift-rank-cntr .top3 > div ~ div,
.rank-list-section.new .guard-rank-cntr .top3-cntr > span ~ span,
.rank-list-section.new .pilot,
/* 人气榜 */
#head-info-vm .popular-and-hot-rank,
#head-info-vm #LiveRoomHotrankEntries,
/* 礼物星球 */
#head-info-vm .gift-planet-entry,
/* 活动榜 */
#head-info-vm .activity-entry,
/* 粉丝团 */
#head-info-vm .follow-ctnr,
/* 头像框 */
.blive-avatar-pendant,
/* 主播城市 */
.anchor-location,
/* 水印 */
.web-player-icon-roomStatus,
.blur-edges-ctnr,
/* 遮罩 */
#web-player-module-area-mask-panel {
display: none !important;
}
/* 兼容chrome 105以下版本 */
@supports not selector(:has(a, b)) {
.chat-history-panel.new {
height: calc(100% - 114px) !important;
}
.rank-list-section~.chat-history-panel.new {
height: calc(100% - 98px - 114px) !important;
}
.chat-history-panel.new~#chat-control-panel-vm {
height: 114px !important;
}
.player-full-win #aside-area-vm .chat-history-panel.new {
height: calc(100% - 104px) !important;
}
}`;
}
if (this.config.menu.noFansMedalIcon.enable) {