-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.html
796 lines (766 loc) · 27.6 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>BiliCLOnline</title>
<meta charset="utf-8" />
<meta name="referrer" content="no-referrer" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui-v2.5.7/css/layui.css" />
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
<script src="https://fastly.jsdelivr.net/npm/[email protected]/qrcode.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
</head>
<div id="introd"
style="display: none; padding: 20px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">
由于当前收到的捐助无法支持原有部署平台成本,已经将服务迁移到其它平台<br>网络环境可能不稳定,请谅解<br>项目维护与运行需要资金支持,望各方多多帮助<br>
<div style="text-align: center;"><a style="color: red;"
href="https://www.bilibili.com/v/pay/charge/?upmid=20580011&upurl=%2F%2Fspace.bilibili.com%2F20580011&upname=InJeCTrL&upavatar=https%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F3f866eddf3ab8ca4a56539e5f8a666d6f0453343.jpg&oid=20580011&otype=up">-》B站充电捐助《-</a>
</div>
<div style="text-align: center;"><a style="color: red;"
href="https://www.bilibili.com/v/pay/charge/?upmid=20580011&upurl=%2F%2Fspace.bilibili.com%2F20580011&upname=InJeCTrL&upavatar=https%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F3f866eddf3ab8ca4a56539e5f8a666d6f0453343.jpg&oid=20580011&otype=up">-》B站充电捐助《-</a>
</div>
<div style="text-align: center;"><a style="color: red;"
href="https://www.bilibili.com/v/pay/charge/?upmid=20580011&upurl=%2F%2Fspace.bilibili.com%2F20580011&upname=InJeCTrL&upavatar=https%3A%2F%2Fi2.hdslb.com%2Fbfs%2Fface%2F3f866eddf3ab8ca4a56539e5f8a666d6f0453343.jpg&oid=20580011&otype=up">-》B站充电捐助《-</a>
</div>
</div>
<div id="loginwnd"
style="display: none; padding: 20px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300; text-align: center;">
请使用Bilibili移动端扫码登录<br>二维码有效时间3分钟<br>登录成功该窗体自动消失<br>
<div id="loginqrcode" style="margin-top: 10px;"></div>
</div>
<style type="text/css">
td>.layui-table-cell {
height: auto;
white-space: normal;
}
</style>
<body class="layui-bg-blue">
<script src="https://www.layuicdn.com/layui-v2.5.7/layui.js"></script>
<div class="layui-fluid">
<ul class="layui-nav layui-bg-green" style="margin-bottom: 25px;">
<li class="layui-nav-item layui-this">B站评论区抽奖</li>
<li class="layui-nav-item layui-layout-right">
<a href="https://github.com/InJeCTrL/BiliCLOnline" target="_blank">
<img src="https://github.githubassets.com/favicons/favicon.svg" />
</a>
</li>
</ul>
<div class="layui-tab" lay-filter="tabs">
<ul class="layui-tab-title" style="display: none;">
<li class="layui-this" lay-id="first"></li>
<li lay-id="second"></li>
<li lay-id="third"></li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="layui-row">
<div class="layui-col-xs12">
<form id="getbaseinfo" class="layui-card layui-bg-gray">
<div class="layui-card-header">设置目标稿件/动态</div>
<div class="layui-card-body">
<div class="layui-form-item">
<label class="layui-form-label">ID或URL</label>
<div class="layui-input-block">
<input type="text" id="pattern" name="pattern" autocomplete="off"
placeholder="" class="layui-input">
</div>
</div>
<div id="captcha1" style="text-align:center" class="h-captcha"
data-sitekey="cb9b8821-c860-4a95-96a9-07f71cc79937"></div>
<div>
<input id="set" type="button" value="OK"
class="layui-btn layui-btn-normal layui-btn-lg layui-btn-radius layui-btn-fluid">
</div>
<div style="margin-top: 15px;">
说明:
<ul>
<li>
ID可以是AV号、BV号、CV号、动态ID中的任意一种
</li>
<li>
URL可以是视频稿件、专栏稿件、动态的网页链接或分享链接中的任意一种
</li>
</ul>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="layui-tab-item">
<div class="layui-row">
<div class="layui-col-xs12">
<div class="layui-card layui-bg-gray">
<div class="layui-card-header">目标信息</div>
<div class="layui-card-body">
<form class="layui-form layui-form-pane">
<div id="titleContainer" class="layui-form-item">
<label class="layui-form-label">稿件标题</label>
<div class="layui-input-block">
<input type="text" id="title" disabled="disabled" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">作品ID</label>
<div class="layui-input-inline">
<input type="text" id="id" disabled="disabled" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">类型</label>
<div class="layui-input-inline">
<input type="text" id="type" disabled="disabled"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<a id="workurl" href="" target="_blank" style="text-align: center;">
<div>点此跳转到作品</div>
</a>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">作者用户ID</label>
<div class="layui-input-inline">
<input type="text" id="uid" disabled="disabled" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">作者用户名</label>
<div class="layui-input-inline">
<input type="text" id="uname" disabled="disabled"
class="layui-input">
</div>
</div>
<div id="faceContainer" class="layui-inline">
<a id="authorhomepage" href="" target="_blank">
<img id="face" width="50" height="50" src="" />
</a>
(点击用户头像进入主页)
</div>
</div>
<div class="layui-form-item">
<div id="viewContainer" class="layui-inline">
<label class="layui-form-label">查看量</label>
<div class="layui-input-inline">
<input type="text" id="view" disabled="disabled"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">点赞数</label>
<div class="layui-input-inline">
<input type="text" id="like" disabled="disabled"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">分享数</label>
<div class="layui-input-inline">
<input type="text" id="share" disabled="disabled"
class="layui-input">
</div>
</div>
<div id="collectContainer" class="layui-inline">
<label class="layui-form-label">收藏数</label>
<div class="layui-input-inline">
<input type="text" id="collect" disabled="disabled"
class="layui-input">
</div>
</div>
<div id="coinContainer" class="layui-inline">
<label class="layui-form-label">投币数</label>
<div class="layui-input-inline">
<input type="text" id="coin" disabled="disabled"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">总评论数</label>
<div class="layui-input-inline">
<input type="text" id="comment" disabled="disabled"
class="layui-input">
</div>
</div>
<div id="pubContainer" class="layui-inline">
<label class="layui-form-label">发布时间</label>
<div class="layui-input-inline">
<input type="text" id="pubtime" disabled="disabled"
class="layui-input">
</div>
</div>
</div>
<div id="fetch_container">
<div id="captcha2" style="text-align:center" class="h-captcha"
data-sitekey="94bcabb4-f991-44ab-8dde-3b7b9fc40849"></div>
<hr />
<div class="layui-form-item">
<label class="layui-form-label">B站Cookie</label>
<div class="layui-input-block">
<input type="password" id="custom_cookie" class="layui-input" placeholder="不填Cookie则需要扫码登录">
</div>
</div>
<div>
<button id="fetch" type="button"
class="layui-btn layui-btn-normal layui-btn-lg layui-btn-radius layui-btn-fluid">获取评论</button>
</div>
<div style="margin-top: 15px;">
提示:不会获取评论区中的楼中楼!
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="lotterySetting" style="display: none;margin-top: 10px;" class="layui-row">
<div class="layui-col-xs12">
<div class="layui-card layui-bg-gray">
<div class="layui-card-header">评论列表与抽奖</div>
<div class="layui-card-body">
<div id="replyTimeGraph" style="height: 400px;"></div>
<table class="layui-hide" id="replylist" lay-filter="replylist"></table>
<form class="layui-form layui-form-pane">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">设定中奖数</label>
<div class="layui-input-inline">
<input type="text" id="count" class="layui-input">
</div>
</div>
</div>
<hr />
<div class="layui-form-item" pane>
<label class="layui-form-label">筛选等级</label>
<div class="layui-input-block">
<input type="checkbox" name="level" title="Lv0" value="0">
<input type="checkbox" name="level" title="Lv1" value="1" checked>
<input type="checkbox" name="level" title="Lv2" value="2" checked>
<input type="checkbox" name="level" title="Lv3" value="3" checked>
<input type="checkbox" name="level" title="Lv4" value="4" checked>
<input type="checkbox" name="level" title="Lv5" value="5" checked>
<input type="checkbox" name="level" title="Lv6" value="6" checked>
</div>
</div>
<div>* 0级用户为抽奖号的风险较大,默认不会抽取</div>
<hr />
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" style="width: 130px">限制评论时间</label>
<div class="layui-input-inline">
<input type="checkbox" id="limittime" lay-skin="switch"
lay-text="是|否">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">时间范围</label>
<div class="layui-input-block">
<input type="text" id="timerange" class="layui-input"
placeholder="点击选择">
</div>
</div>
<hr />
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" style="width: 130px">允许重复UID</label>
<div class="layui-input-inline">
<input type="checkbox" id="duplicateduid" lay-skin="switch"
lay-text="是|否">
</div>
</div>
</div>
<hr />
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" style="width: 130px">评论内容去重 <span
id="dedupreplytip"
style="cursor: pointer;color: blue;">?</span></label>
<div class="layui-input-inline">
<input type="checkbox" id="deduplicatedreply" lay-skin="switch"
lay-text="是|否">
</div>
</div>
</div>
<hr />
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"
style="width: 220px">仅筛选包含特定关键词的评论</label>
<div class="layui-input-inline">
<input type="checkbox" id="onlyspecified" lay-skin="switch"
lay-text="是|否">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">关键词</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="contentspecified">
</div>
</div>
<hr />
<div>
<button id="lottery" type="button"
class="layui-btn layui-bg-red layui-btn-lg layui-btn-radius layui-btn-fluid">抽奖</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="layui-tab-item">
<div class="layui-row">
<div class="layui-col-xs6">
<button id="back"
class="layui-btn layui-bg-cyan layui-btn-lg layui-btn-radius layui-btn-fluid">返回</button>
</div>
<div class="layui-col-xs6">
<button id="allopen"
class="layui-btn layui-bg-red layui-btn-lg layui-btn-radius layui-btn-fluid">全部开启</button>
</div>
</div>
<table class="layui-hide" id="luckylist" lay-filter="luckylist"></table>
</div>
</div>
</div>
<div style="text-align: center;padding-bottom: 10px;">
Running .NET 7.0 <span id="envLbl">on AWS-EC2 via Docker<br>若频繁提示服务不可用,请运行<a
href="https://github.com/InJeCTrL/BiliCLOnline/releases/tag/LocalVersion">本地版本</a></span>
</div>
</div>
<script type="text/html" id="tools">
<button lay-event="open" class="layui-btn layui-bg-red layui-btn-lg layui-btn-fluid open">开</button>
</script>
<script type="text/javascript">
var Id = "";
var replyData = [];
var startDateTime;
var endDateTime;
var tryLoginCnt = 0;
var loginKey = "";
var biliCookie = "";
var totalUrl = window.location.href;
var qrcode = new QRCode(document.getElementById("loginqrcode"));
var isLocalVersion = (totalUrl.indexOf("?localversion") != -1);
var onlineDomain = "https://biliclonline.injectrl.app";
var localDomain = "http://127.0.0.1";
if (isLocalVersion) {
document.getElementById('captcha1').style.display = "none";
document.getElementById('captcha2').style.display = "none";
document.getElementById('envLbl').innerText = "Locally";
localDomain += ':' + totalUrl.substring(totalUrl.indexOf("?localversion") + 14);
}
layui.use(['layer', 'element', 'form', 'layedit', 'laydate', 'table'], function () {
var layer = layui.layer
, $ = layui.$
, element = layui.element
, layedit = layui.layedit
, laydate = layui.laydate
, table = layui.table;
layer.open({
type: 1
, title: "访问说明"
, closeBtn: false
, area: '300px;'
, shade: 0.8
, id: 'LAY_layuipro'
, resize: false
, btn: ['了解']
, btnAlign: 'c'
, moveType: 1
, content: $("#introd")
, success: function (layero) {
layer.close(0);
}
});
laydate.render({
elem: '#timerange'
, type: 'datetime'
, range: true
, done: function (value, start, end) {
startDateTime = new Date(start.year, start.month - 1, start.date, start.hours, start.minutes, start.seconds);
endDateTime = new Date(end.year, end.month - 1, end.date, end.hours, end.minutes, end.seconds);
}
});
$("#dedupreplytip").click(function () {
layer.open({
type: 4,
content: ['在重复内容的评论中只选取最早评论的用户,确保待抽取的评论内容不重复', '#dedupreplytip']
});
});
$("#back").click(function () {
element.tabChange('tabs', 'second');
});
$("#allopen").click(function () {
let opens = document.getElementsByClassName("open");
for (let i = 0; i < opens.length; i++) {
opens[i].click();
}
});
$("#set").click(function () {
$('#set').addClass("layui-btn-disabled").attr("disabled", true);
$.ajax({
url: (isLocalVersion ? localDomain : onlineDomain) + "/api/Bearer",
type: "get",
headers: { "h-captcha-response": isLocalVersion ? "" : $("#captcha1")[0].children[0].attributes["data-hcaptcha-response"].nodeValue },
data: { pattern: $("#pattern").val() },
crossDomain: true,
success: function (data) {
$('#set').removeClass("layui-btn-disabled").attr("disabled", false);
if (data["code"] != 0) {
layer.msg(data["message"]);
}
else {
let bearer = data["data"]["bearer"];
Id = bearer["id"];
$("#id").val(Id);
$("#uid").val(bearer["uid"]);
$("#uname").val(bearer["uName"]);
$("#workurl").attr("href", bearer["url"]);
$("#like").val(bearer["likeCount"]);
$("#share").val(bearer["shareCount"]);
$("#comment").val(bearer["commentCount"]);
switch (data["data"]["type"]) {
case 0:
$("#type").val("视频稿件");
$("#title").val(bearer["title"]);
$("#view").val(bearer["viewCount"]);
$("#face").attr("src", bearer["faceURL"]);
$("#authorhomepage").attr("href", bearer["userHomeURL"]);
$("#collect").val(bearer["collectCount"]);
$("#coin").val(bearer["coinCount"]);
$("#pubtime").val(new Date(bearer["pubTime"]).toLocaleString());
element.tabChange('tabs', 'second');
break;
case 1:
$("#type").val("专栏稿件");
$("#title").val(bearer["title"]);
$("#view").val(bearer["viewCount"]);
$("#collect").val(bearer["collectCount"]);
$("#coin").val(bearer["coinCount"]);
$("#pubContainer").css("display", "none");
$("#faceContainer").css("display", "none");
element.tabChange('tabs', 'second');
break;
case 2:
$("#type").val("动态");
$("#titleContainer").css("display", "none");
$("#face").attr("src", bearer["faceURL"]);
$("#authorhomepage").attr("href", bearer["userHomeURL"]);
$("#pubtime").val(new Date(bearer["pubTime"]).toLocaleString());
$("#viewContainer").css("display", "none");
$("#collectContainer").css("display", "none");
$("#coinContainer").css("display", "none");
element.tabChange('tabs', 'second');
break;
default:
console.log(data);
break;
}
}
},
error: function (e) {
layer.msg("服务暂不可用");
console.log(e);
}
});
});
// 统计每小时评论数量
function renderReplyTimeGraph(replies) {
function _ASC(x, y) {
return x[0] - y[0];
}
let myChart = echarts.init(
document.getElementById('replyTimeGraph'), null, {
renderer: 'canvas',
useDirtyRect: false
});
let timeReplyCntMap = {};
for (let idxReply = 0; idxReply < replies.length; ++idxReply) {
let reply = replies[idxReply];
let replyTime = new Date(reply.pubTime);
replyTime.setMinutes(0, 0, 0);
let timeStamp = replyTime.getTime();
if (!timeReplyCntMap.hasOwnProperty(timeStamp)) {
timeReplyCntMap[timeStamp] = 0;
}
timeReplyCntMap[timeStamp] += 1;
}
let timeReplyCntList = [];
for (var key in timeReplyCntMap) {
timeReplyCntList.push([parseInt(key), timeReplyCntMap[key]]);
}
timeReplyCntList.sort(_ASC);
let option = {
title: {
text: '评论数-时间分布'
},
xAxis: {
type: 'time',
interval: 3600 * 1000 * 24,
axisLabel: {
show: true,
formatter: function (value, index) {
let date = new Date(value);
return [date.getFullYear(), date.getMonth() + 1, date.getDate()].join("-");
}
}
},
yAxis: {
name: '数量',
type: 'value'
},
series: [
{
data: timeReplyCntList,
type: 'bar',
areaStyle: {},
showSymbol: false
},
],
tooltip: {
trigger: 'axis'
}
};
if (option && typeof option === 'object') {
myChart.setOption(option);
}
window.addEventListener('resize', myChart.resize);
}
function refreshConfirmation(taskID) {
$.ajax({
url: (isLocalVersion ? localDomain : onlineDomain) + "/api/Confirmation/" + taskID,
type: "get",
crossDomain: true,
success: function (data) {
if (data["code"] === 1) {
$("#fetch_container").show();
layer.msg(data["message"]);
}
else if (data["code"] === 0) {
$("#fetch_container").remove();
$('#lotterySetting').css('display', 'block');
replyData = data["data"];
renderReplyTimeGraph(replyData);
table.render({
elem: '#replylist',
cellMinWidth: 80,
cols: [[
{
title: "用户 [UID]",
templet: function (d) {
return '<a href="' + d.userHomeURL + '" target="_blank">' + d.uName + ' [' + d.uid + ']</a>';
}
},
{
title: "评论内容节选",
templet: function (d) {
return '<a href="' + d.url + '" target="_blank">' + d.content.substring(0, 30) + '</a>';
}
}
]],
page: true,
data: data["data"]
});
}
else if (data["code"] === 2) {
layer.msg(data["message"]);
setTimeout(function () {
refreshConfirmation(taskID);
}, 5000);
}
},
error: function (j, e) {
if (j.status == 400) {
layer.msg("参数错误");
}
else {
layer.msg("服务暂不可用");
}
console.log(e);
},
});
}
function fetchComments() {
$.ajax({
url: (isLocalVersion ? localDomain : onlineDomain) + "/api/Reply/" + Id + "/" + biliCookie,
type: "get",
headers: { "h-captcha-response": isLocalVersion ? "" : $("#captcha2")[0].children[0].attributes["data-hcaptcha-response"].nodeValue },
crossDomain: true,
success: function (data) {
if (data["code"] != 0) {
$("#fetch_container").show();
layer.msg(data["message"]);
}
else {
layer.close(layer.index);
refreshConfirmation(data["data"]);
}
},
error: function (j, e) {
if (j.status == 400) {
layer.msg("参数错误");
}
else {
layer.msg("服务暂不可用");
}
console.log(e);
},
});
}
function getLoginResult() {
++tryLoginCnt;
$.ajax({
url: (isLocalVersion ? localDomain : onlineDomain) + "/api/Login/result/" + loginKey,
type: "get",
crossDomain: true,
success: function (data) {
// 其它立即错误
if (data["code"] != 0) {
if (tryLoginCnt > 60) {
$("#loginstatus").text("二维码过期,请刷新页面");
return;
}
$("#loginstatus").text(data["message"]);
setTimeout(getLoginResult, 3000);
}
else {
biliCookie = data["data"];
layer.close(layer.index);
fetchComments();
}
},
error: function (j, e) {
if (j.status == 400) {
layer.msg("参数错误");
}
else {
layer.msg("服务暂不可用");
}
console.log(e);
},
});
}
$("#fetch").click(function () {
let customCookie = $("#custom_cookie").val();
// 自定义Cookie为空则需要扫码登录
if (customCookie == null || customCookie == '') {
$.ajax({
url: (isLocalVersion ? localDomain : onlineDomain) + "/api/Login/qrcode",
type: "get",
crossDomain: true,
success: function (data) {
if (data["code"] != 0) {
layer.msg(data["message"]);
}
else {
$("#fetch_container").hide();
loginKey = data["message"];
layer.open({
type: 1
, title: false
, closeBtn: false
, area: '300px;'
, shade: 0.8
, id: 'LAY_out'
, resize: false
, btnAlign: 'c'
, moveType: 1
, content: $("#loginwnd")
});
qrcode.makeCode(data["data"]);
tryLoginCnt = 0;
getLoginResult();
}
},
error: function (j, e) {
if (j.status == 400) {
layer.msg("参数错误");
}
else {
layer.msg("服务暂不可用");
}
console.log(e);
},
});
}
// 自定义Cookie存在则直接使用
else {
biliCookie = customCookie.replaceAll(" ", "");
fetchComments();
}
});
$("#lottery").click(function () {
let cnt = $("#count").val();
if (isNaN(parseFloat(cnt))) {
layer.msg("中奖数必须为整数");
return;
}
if ($("#limittime").is(':checked') &&
(startDateTime > endDateTime || typeof (startDateTime) === 'undefined' || typeof (endDateTime) === 'undefined' ||
startDateTime.toString() === 'Invalid Date' || endDateTime.toString() === 'Invalid Date')) {
layer.msg("起止时间不正确");
return;
}
let levelSet = new Set();
$('input[name=level]:checked').each(function () {
levelSet.add(parseInt($(this).val()));
});
let lotteryData = {
data: replyData, count: cnt, limitTime: $("#limittime").is(':checked'), levels: levelSet,
startDateTime: startDateTime, endDateTime: endDateTime,
duplicatedUID: $("#duplicateduid").is(':checked'),
deDuplicatedReply: $("#deduplicatedreply").is(':checked'),
onlySpecified: $("#onlyspecified").is(':checked'), contentSpecified: $("#contentspecified").val()
};
let worker = new Worker("lottery.js");
worker.postMessage(lotteryData);
layer.msg("请稍等");
$('#lottery').addClass("layui-btn-disabled").attr("disabled", true);
worker.onmessage = function (event) {
$('#lottery').removeClass("layui-btn-disabled").attr("disabled", false);
let data = event.data;
if (data.err === true) {
layer.msg(data.msg);
} else {
layer.msg("已生成中奖列表");
table.render({
elem: '#luckylist',
cols: [[
{
field: 'faceURL', title: '明细', style: 'visibility: hidden;',
templet: function (d) {
return '<div><a href="' + d.userHomeURL + '" target="_blank"><img src="' + d.faceURL +
'" width=50 height=50></a><br>' + d.uName + '</div><br>评论内容节选: <a href="' + d.url + '" target="_blank">' +
d.content.substring(0, 30) + '</a><br>获赞数: ' + d.likeCount + '<br>时间: ' + new Date(d.pubTime).toLocaleString();
},
},
{
width: 100, align: 'center', title: '操作', toolbar: '#tools'
}
]],
data: data["data"],
limit: data["count"]
});
table.on('tool(luckylist)', function (obj) {
switch (obj.event) {
case 'open':
obj.tr[0].firstChild.setAttribute('style', 'cursor: pointer;');
break;
default:
break;
}
});
element.tabChange('tabs', 'third');
}
};
});
});
</script>
</body>
</html>