-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbilibili-up-filter.user.js
More file actions
1330 lines (1161 loc) · 45.2 KB
/
Copy pathbilibili-up-filter.user.js
File metadata and controls
1330 lines (1161 loc) · 45.2 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
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-up-filter
// @namespace https://github.com/sansan0/useful-userscripts
// @version 3.0
// @description 一个用于B站的用户脚本,提供快速屏蔽和管理UP主内容的功能,以及便捷的UP主访问方式
// @author sansan
// @match https://www.bilibili.com/*
// @grant GM_addStyle
// @license GPL-3.0 License
// @icon data:image/png;base64,/9j/4AAQSkZJRgABAQEAqACoAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCACAAIADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6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dcjx/p17p6tcSY6b2XBkx/t5r0jQ9CsfDGjWum6ZY2em6dYxCG2tLSFYYLdB0VEUBVA9AKx7v4o6VbA7GuJ29Ejxn8TisHWPi1d3KstnDHar/fb53/AMP51cacn0JlU6XO21fW7XQ7UzXUyxL2B+83sB3rzbxj46m8Ty+WgMNmpysfdz6t/h2qhbxal4x1Xy4I7zU7yQ4CRI0rn8BnFev/AAt/Yr1jxFLHdeJpDotjkN9mjIe6lHoeqx/jk+1FavQwy5q0l+vyRrh8JiMVLloxb/L5vY88+EXwZ1D40+MlhtIxHHCqre6i0YP2aLOdu7qSf4Uz156ZNfbPhTwvZeC/Dtnpenw+RZ2MYiiTqcdyT3YnJJ7kmm+EvB2meBNCh03SbOKys4eQidWPdmPVmPcnmtNF5r4vNM0li56aRWy/V+f5H3+UZTHBQu9Zvd/ovL8xRwM0sf8ArPwP8qCOvpQn3/wP8q8k9gH5b8B/KgHiho2J/Ad/ajY3+TQAhHNDrS+W3+TR5be350ARsuap674a07xTbGHUtPs9Qh6bbmFZAPpkcfhWgYmx/wDXo8pvb8xTjJp3QpRTVmeb6v8AspeA9XZm/sT7IxPW1uJIh+WcfpWRL+xR4LP3W1teegvAcfmtevGFj/8ArpPJb1/UV2RzLFRVlUl97OKWV4OTu6UfuR5FF+xR4KRvmOtyD0a8A/korZ0f9ljwJozhl0FLpl73U0k36E4/SvRPJb/JFKYW/wAkUpZjipKzqS+9hDK8JF3jSj9yKWjeH7Hw3aeTp9naWEP9y3hWJT/3yKuBcUvlNn/64pfKb2/OuRtt3Z3JJKyG4704rigxNjt+dHlt/k0gAjihOH/A/wAqNjD/APWKVY23Z9j3oA//2Q==
// ==/UserScript==
(function () {
"use strict";
// 如果当前窗口不是顶层窗口,则直接退出
if (window !== window.top) {
return;
}
/**
* 常量定义
* 定义了程序中使用的各种固定值
*/
const CONSTANTS = {
BLOCKED_UPS_KEY: "blocked_up_users",
TOAST_DISPLAY_DURATION: 2000,
TOAST_ANIMATION_DURATION: 300,
HOVER_DELAY: 100,
};
/**
* 添加样式到页面
* 包含了所有UI组件的样式:按钮、复选框、提示框、动画等
*/
function addStyles() {
GM_addStyle(`
/* 基础按钮样式 */
.id-block-toggle,
.blocked-ups-toggle,
.following-toggle {
position: fixed;
right: 10px;
padding: 10px;
border-radius: 8px;
cursor: pointer;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
z-index: 9999;
display: flex;
align-items: center;
justify-content: space-between;
width: 100px;
box-sizing: border-box;
transition: all 0.3s ease;
color: white;
}
/* ID屏蔽按钮特定样式 */
.id-block-toggle {
top: calc(50% - 80px);
background: #9254de;
}
.id-block-toggle:hover {
background: #a872e8;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
/* 已屏蔽按钮特定样式 */
.blocked-ups-toggle {
top: 50%;
transform: translateY(-50%);
background: #00aeec;
}
.blocked-ups-toggle:hover {
background: #0095cc;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
/* 关注者按钮特定样式 */
.following-toggle {
top: calc(50% + 40px);
background: #FB7299;
}
.following-toggle:hover {
background: #fc8bab;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
/* ID屏蔽输入框样式 */
.id-block-input {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(146, 84, 222, 0.9);
border: none;
color: white;
padding: 10px;
border-radius: 8px;
outline: none;
display: none;
font-size: 14px;
box-sizing: border-box;
}
.id-block-input::placeholder {
color: rgba(255, 255, 255, 0.8);
}
.id-block-toggle.input-mode .id-block-input {
display: block;
}
.id-block-toggle.input-mode span {
opacity: 0;
}
/* 隐藏状态样式 */
.id-block-toggle.hide,
.blocked-ups-toggle.hide,
.following-toggle.hide {
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
}
/* 复选框样式 */
.block-checkbox {
position: absolute;
top: -40px;
bottom: auto;
left: 0;
background: white;
padding: 6px 10px;
border: 1px solid #e3e5e7;
border-radius: 6px;
display: none;
z-index: 10;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
transition: all 0.3s ease;
font-size: 13px;
color: #18191c;
width: 130px;
white-space: nowrap;
box-sizing: border-box;
pointer-events: auto;
}
.bili-video-card__info--owner {
position: relative;
z-index: 9;
}
.block-checkbox:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.block-checkbox label {
display: flex;
align-items: center;
cursor: pointer;
user-select: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
}
.block-checkbox input[type="checkbox"] {
flex-shrink: 0;
appearance: none;
-webkit-appearance: none;
width: 16px;
height: 16px;
border: 2px solid #c9ccd0;
border-radius: 3px;
margin-right: 6px;
position: relative;
cursor: pointer;
transition: all 0.2s ease;
padding: 0;
}
.block-checkbox input[type="checkbox"]:checked {
background-color: #00aeec;
border-color: #00aeec;
}
.block-checkbox input[type="checkbox"]:checked::after {
content: "";
position: absolute;
left: 4px;
top: 1px;
width: 5px;
height: 9px;
border: solid white;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
.block-checkbox input[type="checkbox"]:hover {
border-color: #00aeec;
}
.block-checkbox input[type="checkbox"]:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(0,174,236,0.2);
}
.block-checkbox input[type="checkbox"]:disabled {
background-color: #f5f5f5;
border-color: #e0e0e0;
cursor: not-allowed;
}
.block-checkbox label span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
letter-spacing: 0.3px;
}
/* 提示框样式 */
.toast-notification {
position: fixed;
top: 16px;
right: 16px;
background: rgba(0, 0, 0, 0.8);
color: white;
padding: 12px 24px;
border-radius: 8px;
z-index: 9999999;
font-size: 14px;
opacity: 0;
transform: translateX(100%);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
gap: 8px;
pointer-events: none;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast-notification.show {
opacity: 1;
transform: translateX(0);
}
.toast-notification.hide {
opacity: 0;
transform: translateX(100%);
}
.toast-icon {
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
}
.toast-block { color: #ff6b6b; }
.toast-unblock { color: #69db7c; }
/* 动画效果 */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(5px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeOutDown {
from {
opacity: 1;
transform: translateY(0);
}
to {
opacity: 0;
transform: translateY(5px);
}
}
.block-checkbox.show {
animation: fadeInUp 0.3s ease forwards;
}
.block-checkbox.hide {
animation: fadeOutDown 0.3s ease forwards;
}
/* 面板样式 */
.blocked-ups-panel,
.following-panel {
position: fixed;
right: -350px;
top: 0;
width: 320px;
height: 100vh;
background: white;
box-shadow: -2px 0 8px rgba(0,0,0,0.1);
z-index: 9998;
transition: right 0.3s ease;
display: flex;
flex-direction: column;
}
.blocked-ups-panel.show,
.following-panel.show {
right: 0;
}
.blocked-ups-header {
padding: 16px;
background: #f6f7f8;
border-bottom: 1px solid #e3e5e7;
font-weight: bold;
display: flex;
justify-content: space-between;
align-items: center;
}
.blocked-ups-list {
flex: 1;
overflow-y: auto;
padding: 12px;
}
.blocked-up-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-bottom: 1px solid #f0f1f2;
transition: background-color 0.2s ease;
}
.blocked-up-item:hover {
background-color: #f6f7f8;
}
.blocked-up-info {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #18191c;
text-decoration: none;
margin-right: 10px;
}
.blocked-up-remove {
padding: 4px 8px;
border: none;
background: #ff6b6b;
color: white;
border-radius: 4px;
cursor: pointer;
margin-left: 8px;
transition: background-color 0.2s ease;
}
.blocked-up-remove:hover {
background: #ff5252;
}
.follow-time {
color: #99a2aa;
font-size: 12px;
margin-left: auto;
padding-left: 10px;
white-space: nowrap;
}
/* 滚动条样式 */
.blocked-ups-list::-webkit-scrollbar {
width: 6px;
}
.blocked-ups-list::-webkit-scrollbar-track {
background: #f1f1f1;
}
.blocked-ups-list::-webkit-scrollbar-thumb {
background: #c0c0c0;
border-radius: 3px;
}
.blocked-ups-list::-webkit-scrollbar-thumb:hover {
background: #a0a0a0;
}
/* 移除动画 */
@keyframes removeItem {
0% {
opacity: 1;
transform: translateX(0);
}
100% {
opacity: 0;
transform: translateX(100%);
height: 0;
padding: 0;
margin: 0;
}
}
.blocked-up-item.removing {
animation: removeItem 0.3s ease-out forwards;
overflow: hidden;
}
/* Toast动画 */
@keyframes toastIn {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
@keyframes toastOut {
from {
transform: translateX(0);
opacity: 1;
}
to {
transform: translateX(100%);
opacity: 0;
}
}
.toast-notification.show {
animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.toast-notification.hide {
animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
`);
}
/**
* 数据存储与管理模块
* 处理与localStorage相关的所有操作
*/
const DataManager = {
/**
* 从localStorage获取被屏蔽的UP主列表
* @returns {Array} 返回被屏蔽UP主的数组,每个元素包含id和name
*/
getBlockedUps() {
try {
const blockedUps = localStorage.getItem(CONSTANTS.BLOCKED_UPS_KEY);
return blockedUps ? JSON.parse(blockedUps) : [];
} catch (error) {
console.error("Error getting blocked UPs:", error);
return [];
}
},
/**
* 添加UP主到屏蔽列表
* @param {string} upId - UP主的ID
* @param {string} upName - UP主的昵称
*/
addBlockedUp(upId, upName) {
const blockedUps = this.getBlockedUps();
const existingIndex = blockedUps.findIndex((up) => up.id === upId);
if (existingIndex > -1 && !blockedUps[existingIndex].name) {
blockedUps[existingIndex].name = upName;
} else if (existingIndex === -1) {
blockedUps.push({ id: upId, name: upName });
}
localStorage.setItem(
CONSTANTS.BLOCKED_UPS_KEY,
JSON.stringify(blockedUps)
);
if (document.body.hasAttribute("data-panel-initialized")) {
UIManager.updateBlockedUpsList();
}
},
/**
* 从屏蔽列表中移除指定UP主
* @param {string} upId - 需要移除的UP主ID
*/
removeBlockedUp(upId) {
const blockedUps = this.getBlockedUps();
const filteredUps = blockedUps.filter((up) => up.id !== upId);
localStorage.setItem(
CONSTANTS.BLOCKED_UPS_KEY,
JSON.stringify(filteredUps)
);
if (document.body.hasAttribute("data-panel-initialized")) {
UIManager.updateBlockedUpsList();
}
},
/**
* 检查UP主是否被屏蔽
* @param {string} upId - UP主ID
* @returns {boolean} 如果被屏蔽返回true,否则返回false
*/
isBlocked(upId) {
return this.getBlockedUps().some((up) => up.id === upId);
},
};
/**
* UI管理模块
* 处理所有界面元素的创建、更新和交互
*/
const UIManager = {
blockedUpsPanel: null,
/**
* 显示操作提示框
* @param {string} upName - UP主昵称
* @param {boolean} isBlocking - true表示屏蔽操作,false表示取消屏蔽
*/
showToast(upName, isBlocking) {
const existingToast = document.querySelector(".toast-notification");
if (existingToast) existingToast.remove();
const toast = document.createElement("div");
toast.className = "toast-notification";
const icon = isBlocking ? "🚫" : "✅";
const action = isBlocking ? "已屏蔽" : "已取消屏蔽";
toast.innerHTML = `
<span class="toast-icon ${
isBlocking ? "toast-block" : "toast-unblock"
}">${icon}</span>
<span>${action} UP主:${upName}</span>
`;
document.body.appendChild(toast);
toast.offsetHeight; // 触发重绘
requestAnimationFrame(() => toast.classList.add("show"));
setTimeout(() => {
toast.classList.add("hide");
setTimeout(() => toast.remove(), CONSTANTS.TOAST_ANIMATION_DURATION);
}, CONSTANTS.TOAST_DISPLAY_DURATION);
},
/**
* 更新被屏蔽UP主列表显示
*/
updateBlockedUpsList() {
const panel = document.querySelector(".blocked-ups-panel");
const listContainer = panel?.querySelector(".blocked-ups-list");
if (!listContainer) return;
const blockedUps = DataManager.getBlockedUps();
const reversedUps = [...blockedUps].reverse();
listContainer.innerHTML = reversedUps
.map(
(up) => `
<div class="blocked-up-item" data-up-id="${up.id}">
<a href="https://space.bilibili.com/${up.id}"
target="_blank"
class="blocked-up-info">
${up.name || `ID: ${up.id}`}
</a>
<button class="blocked-up-remove">移除</button>
</div>
`
)
.join("");
const toggleButton = document.querySelector(".blocked-ups-toggle");
if (toggleButton) {
toggleButton.querySelector("span:last-child").textContent =
blockedUps.length;
}
const countElement = panel.querySelector(".blocked-count");
if (countElement) {
countElement.textContent = blockedUps.length;
}
},
/**
* 创建UP主屏蔽控制的复选框
* @param {string} upId - UP主ID
* @param {string} upName - UP主昵称
* @returns {HTMLElement} 返回创建的复选框元素
*/
createCheckbox(upId, upName) {
const checkbox = document.createElement("div");
checkbox.className = "block-checkbox";
const isBlocked = DataManager.isBlocked(upId);
checkbox.innerHTML = `
<label>
<input type="checkbox" ${isBlocked ? "checked" : ""}>
<span>屏蔽该UP主</span>
</label>
`;
const input = checkbox.querySelector("input");
input.addEventListener("change", (e) => {
if (e.target.checked) {
DataManager.addBlockedUp(upId, upName);
this.showToast(upName, true);
} else {
DataManager.removeBlockedUp(upId);
this.updateCheckboxStatus(upId);
this.showToast(upName, false);
}
ContentFilter.filterBlockedContent();
});
return checkbox;
},
/**
* 更新所有相关复选框的状态
* @param {string} upId - UP主ID
*/
updateCheckboxStatus(upId) {
document
.querySelectorAll(".bili-video-card__info--owner")
.forEach((link) => {
const href = link.getAttribute("href");
if (!href) return;
const currentUpId = href.match(/\/(\d+)$/)?.[1];
if (currentUpId === upId) {
const checkbox = link.querySelector(
'.block-checkbox input[type="checkbox"]'
);
if (checkbox) {
checkbox.checked = false;
}
}
});
},
/**
* 处理UP主链接的鼠标悬停事件
* @param {HTMLElement} element - UP主链接元素
*/
handleHover(element) {
const href = element.getAttribute("href");
if (!href) return;
const upId = href.match(/\/(\d+)$/)?.[1];
if (!upId) return;
const authorSpan = element.querySelector(
".bili-video-card__info--author"
);
const upName = authorSpan?.getAttribute("title") || "未知UP主";
let checkbox = element.querySelector(".block-checkbox");
if (!checkbox) {
checkbox = this.createCheckbox(upId, upName);
element.style.position = "relative";
element.appendChild(checkbox);
} else {
const input = checkbox.querySelector('input[type="checkbox"]');
const isBlocked = DataManager.isBlocked(upId);
input.checked = isBlocked;
}
let hideTimeout;
let isOverElement = false;
let isOverCheckbox = false;
const showCheckbox = () => {
checkbox.style.display = "block";
requestAnimationFrame(() => {
checkbox.style.opacity = "1";
checkbox.style.transform = "translateY(0)";
});
};
const hideCheckbox = () => {
checkbox.style.opacity = "0";
checkbox.style.transform = "translateY(5px)";
hideTimeout = setTimeout(() => {
checkbox.style.display = "none";
}, CONSTANTS.TOAST_ANIMATION_DURATION);
};
const checkVisibility = () => {
setTimeout(() => {
if (!isOverElement && !isOverCheckbox) {
hideCheckbox();
}
}, CONSTANTS.HOVER_DELAY);
};
element.addEventListener("mouseenter", () => {
isOverElement = true;
clearTimeout(hideTimeout);
showCheckbox();
});
element.addEventListener("mouseleave", () => {
isOverElement = false;
checkVisibility();
});
checkbox.addEventListener("mouseenter", () => {
isOverCheckbox = true;
clearTimeout(hideTimeout);
});
checkbox.addEventListener("mouseleave", () => {
isOverCheckbox = false;
checkVisibility();
});
element.setAttribute("data-hover-initialized", "true");
},
/**
* 切换所有按钮的显示/隐藏状态
* @param {boolean} hide - 为true时隐藏按钮,为false时显示按钮
*/
toggleAllButtons(hide = true) {
const followingToggle = document.querySelector(".following-toggle");
const blockedToggle = document.querySelector(".blocked-ups-toggle");
const idBlockToggle = document.querySelector(".id-block-toggle");
if (hide) {
followingToggle?.classList.add("hide");
blockedToggle?.classList.add("hide");
idBlockToggle?.classList.add("hide");
} else {
followingToggle?.classList.remove("hide");
blockedToggle?.classList.remove("hide");
idBlockToggle?.classList.remove("hide");
}
},
/**
* 创建并管理被屏蔽UP主列表面板
* @returns {Object} 返回包含更新面板方法的对象
*/
createBlockedUpsPanel() {
// 创建ID屏蔽按钮
const idBlockButton = document.createElement("div");
idBlockButton.className = "id-block-toggle";
idBlockButton.innerHTML = `
<span>手动屏蔽ID</span>
<span></span>
<input type="text" class="id-block-input" placeholder="输入UP主ID" pattern="[0-9]*">
`;
// 获取输入框元素
const idInput = idBlockButton.querySelector(".id-block-input");
// 处理ID输入框事件
this._setupIdInputEvents(idBlockButton, idInput);
document.body.appendChild(idBlockButton);
// 创建已屏蔽按钮
const toggleButton = document.createElement("div");
toggleButton.className = "blocked-ups-toggle";
toggleButton.innerHTML = `
<span>已屏蔽</span>
<span>${DataManager.getBlockedUps().length}</span>
`;
// 创建屏蔽列表面板
const panel = document.createElement("div");
panel.className = "blocked-ups-panel";
panel.innerHTML = `
<div class="blocked-ups-header">
<span>已屏蔽的UP主</span>
<span class="blocked-count">${
DataManager.getBlockedUps().length
}</span>
</div>
<div class="blocked-ups-list"></div>
`;
// 设置面板交互
this._setupPanelInteraction(toggleButton, panel);
this._setupRemoveButtons(panel);
document.body.appendChild(toggleButton);
document.body.appendChild(panel);
this.updateBlockedUpsList();
document.body.setAttribute("data-panel-initialized", "true");
return {
updateBlockedUpsList: () => this.updateBlockedUpsList(),
};
},
/**
* 设置ID输入框的事件处理
* @private
* @param {HTMLElement} idBlockButton - ID屏蔽按钮元素
* @param {HTMLElement} idInput - 输入框元素
*/
_setupIdInputEvents(idBlockButton, idInput) {
// 处理鼠标进入事件
idBlockButton.addEventListener("mouseenter", () => {
idBlockButton.classList.add("input-mode");
idInput.focus();
});
// 处理鼠标离开事件
idBlockButton.addEventListener("mouseleave", () => {
if (document.activeElement !== idInput) {
idBlockButton.classList.remove("input-mode");
idInput.value = "";
}
});
// 处理输入事件
idInput.addEventListener("input", (e) => {
e.target.value = e.target.value.replace(/\D/g, "");
});
// 处理键盘事件
idInput.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
const upId = e.target.value.trim();
if (upId) {
DataManager.addBlockedUp(upId, null);
this.showToast(`ID: ${upId}`, true);
e.target.value = "";
idBlockButton.classList.remove("input-mode");
this.updateBlockedUpsList();
ContentFilter.filterBlockedContent();
}
} else if (e.key === "Escape") {
idBlockButton.classList.remove("input-mode");
e.target.value = "";
idBlockButton.blur();
}
});
// 处理失去焦点事件
idInput.addEventListener("blur", () => {
setTimeout(() => {
if (document.activeElement !== idInput) {
idBlockButton.classList.remove("input-mode");
idInput.value = "";
}
}, 200);
});
},
/**
* 设置面板交互事件
* @private
* @param {HTMLElement} toggleButton - 触发按钮
* @param {HTMLElement} panel - 面板元素
*/
_setupPanelInteraction(toggleButton, panel) {
let mouseInPanel = false;
toggleButton.addEventListener("mouseenter", () => {
panel.classList.add("show");
this.toggleAllButtons(true);
this.updateBlockedUpsList();
});
panel.addEventListener("mouseenter", () => {
mouseInPanel = true;
});
panel.addEventListener("mouseleave", () => {
mouseInPanel = false;
setTimeout(() => {
if (!mouseInPanel && !toggleButton.matches(":hover")) {
panel.classList.remove("show");
this.toggleAllButtons(false);
}
}, 200);
});
toggleButton.addEventListener("mouseleave", () => {
setTimeout(() => {
if (!mouseInPanel) {
panel.classList.remove("show");
this.toggleAllButtons(false);
}
}, 200);
});
},
/**
* 设置移除按钮的事件处理
* @private
* @param {HTMLElement} panel - 面板元素
*/
_setupRemoveButtons(panel) {
panel.addEventListener("click", (e) => {
if (e.target.classList.contains("blocked-up-remove")) {
const upItem = e.target.closest(".blocked-up-item");
if (!upItem) return;
const upId = upItem.dataset.upId;
const upName = upItem
.querySelector(".blocked-up-info")
.textContent.trim();
upItem.classList.add("removing");
setTimeout(() => {
DataManager.removeBlockedUp(upId);
this.updateCheckboxStatus(upId);
this.showToast(upName, false);
this.updateBlockedUpsList();
ContentFilter.filterBlockedContent();
}, 300);
}
});
},
/**
* 添加屏蔽复选框到UP主头像
*/
addCheckboxToUpAvatar() {
const upAvatar = document.querySelector("a.up-avatar");
if (!upAvatar) return;
const href = upAvatar.getAttribute("href");
if (!href) return;
const upId = href.match(/\/(\d+)$/)?.[1];
if (!upId) return;
const upNameElement = document.querySelector(".up-name");
const upName = upNameElement?.textContent?.trim() || "未知UP主";
const createAndAddCheckbox = () => {
let checkbox = upAvatar.querySelector(".block-checkbox");
if (!checkbox) {
checkbox = this.createCheckbox(upId, upName);
upAvatar.style.position = "relative";
upAvatar.appendChild(checkbox);
checkbox.style.display = "block";
checkbox.style.opacity = "1";
checkbox.style.transform = "translateY(0)";
}
};
// 立即创建一次
createAndAddCheckbox();
// 创建专门监听 up-avatar 的观察器
const avatarObserver = new MutationObserver(() => {
createAndAddCheckbox();
});
// 配置观察器
avatarObserver.observe(upAvatar, {
childList: true, // 监听子元素变化
subtree: true, // 监听所有后代元素
characterData: true, // 监听文本内容变化
attributes: true, // 监听属性变化
});
},
/**
* 创建并管理关注列表面板
* @returns {Promise<void>}
*/
async createFollowingPanel() {
if (this.followingPanelInitialized) return;
try {
const statsContainer = await DOMUtils.waitForElement(
".logged-in > .stats"
);
if (!statsContainer) return;
const followLink = statsContainer.querySelector("a");
if (!followLink) {