-
Notifications
You must be signed in to change notification settings - Fork 126
/
tech-study.js
6180 lines (6180 loc) · 219 KB
/
tech-study.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 不学习何以强国
// @namespace http://tampermonkey.net/
// @version 1.7.5
// @description 有趣的 `学习强国` 油猴插件。读文章,看视频,做习题。问题反馈: https://github.com/Xu22Web/tech-study-js/issues 。
// @author 原作者:techxuexi 荷包蛋。现作者:Xu22Web
// @match https://www.xuexi.cn/*
// @match https://pc.xuexi.cn/points/exam-practice.html
// @match https://pc.xuexi.cn/points/exam-weekly-detail.html?id=*
// @match https://pc.xuexi.cn/points/exam-paper-detail.html?id=*
// @match https://login.xuexi.cn/login/xuexiWeb?appid=dingoankubyrfkttorhpou&goto=https%3A%2F%2Foa.xuexi.cn&type=1&state=ffdea2ded23f45ab%2FKQreTlDFe1Id3B7BVdaaYcTMp6lsTBB%2Fs3gGevuMKfvpbABDEl9ymG3bbOgtpSN&check_login=https%3A%2F%2Fpc-api.xuexi.cn
// @require https://cdn.jsdelivr.net/npm/blueimp-md5@2.9.0
// @run-at document-start
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_openInTab
// @grant GM_addValueChangeListener
// @grant unsafeWindow
// @updateURL https://raw.githubusercontent.com/Xu22Web/tech-study-js/master/tech-study.js
// @downloadURL https://raw.githubusercontent.com/Xu22Web/tech-study-js/master/tech-study.js
// @supportURL https://github.com/Xu22Web
// ==/UserScript==
const css = '* { -webkit-tap-highlight-color: transparent;}:root { --themeColor: #fa3333; --scale: 1; font-size: calc(10px * var(--scale));}@media (min-height: 678px) and (max-height: 768px) { :root { --scale: 0.8; }}@media (max-height: 667px) { :root { --scale: 0.75; }}@keyframes fade { from { opacity: 0.8; } to { opacity: 0.4; background: #ccc; }}.egg_icon { width: 1em; height: 1em; fill: currentColor;}.egg_hr_wrap { position: relative; display: flex; justify-content: center; color: #ccc;}.egg_hr_wrap .egg_hr { position: absolute; top: 50%; transform: translateY(-50%); background: currentColor; height: 0.1rem; width: 30%;}.egg_hr_wrap .egg_hr:nth-of-type(1) { left: 0;}.egg_hr_wrap .egg_hr:nth-last-of-type(1) { right: 0;}.egg_hr_title { font-size: 1.2rem;}.egg_exam_btn { transition: background 80ms; outline: none; border: none; padding: 1.2rem 2rem; border-radius: 1.2rem; cursor: pointer; font-size: 1.8rem; font-weight: bold; text-align: center; color: #ffffff; background: #ccc;}.egg_exam_btn.manual { background: var(--themeColor);}.egg_panel_wrap * { padding: 0; margin: 0; box-sizing: border-box; outline: none; border: none;}.egg_panel_wrap { position: fixed; left: 0; top: 0; z-index: 99999; width: 100%; height: 100%; color: #333; font-size: 1.6rem; pointer-events: none;}.egg_panel { position: absolute; top: 5rem; left: 1rem; padding: 1.2rem 2rem; border-radius: 1rem; background: #ffffffe6; backdrop-filter: blur(1rem); box-shadow: 0 0 0.1rem 0.1rem #f1f1f1; transition: 80ms ease-out; pointer-events: all;}.egg_panel.hide { left: 0; transform: translateX(-100%);}.egg_panel_wrap.mobile .egg_panel { top: 1rem;}@media (min-height: 678px) and (max-height: 768px) { .egg_panel { top: 2rem; }}@media (max-height: 667px) { .egg_panel { top: 1rem; }}.egg_panel button { outline: none; border: none; padding: 0; cursor: pointer; background: none;}.egg_panel .egg_btns_wrap { position: absolute; left: 100%; top: 50%; transform: translate(-50%, -50%); transition: 80ms ease; z-index: 9;}.egg_panel.hide .egg_btns_wrap { left: 100%; transform: translate(0, -50%);}.egg_panel .egg_btns_wrap button { border-radius: 50%; width: 3rem; height: 3rem; padding: 0; overflow: hidden; border: 0.2rem solid currentColor; color: white; display: grid; place-items: center; font-size: 1.8rem;}.egg_panel.hide .egg_panel_show_btn { background: var(--themeColor);}.egg_panel .egg_panel_show_btn { background: #ccc;}.egg_panel .egg_frame_show_btn { background: var(--themeColor); margin-bottom: 1rem;}.egg_panel .egg_frame_show_btn.hide { display: none;}.egg_panel .egg_settings_show_btn { background: #ccc; margin-top: 1rem;}.egg_panel .egg_settings_show_btn.active { background: var(--themeColor);}.egg_panel .egg_settings_reset_btn { background: #ccc; margin-top: 1rem;}.egg_panel .egg_settings_reset_btn:active { background: var(--themeColor);}.egg_login_item { display: flex; justify-content: center; align-items: center; flex-direction: column; padding: 0.5rem 0;}.egg_login_item .egg_login_btn { font-size: 1.4rem; border-radius: 1rem; transition: 80ms ease; color: white; background: var(--themeColor); padding: 0.8rem 2.4rem;}.egg_login_item .egg_login_btn:active { opacity: 0.8;}.egg_login_item .egg_login_img_wrap { height: 0; border-radius: 1rem; transition: height 80ms ease; overflow: hidden;}.egg_login_item .egg_login_img_wrap.active { padding: 0.8rem; margin-top: 0.8rem; height: auto; background: white;}.egg_login_img_wrap .egg_login_img { width: 15rem; height: 15rem;}.egg_info_item .egg_login_btn { font-size: 1.4rem; border-radius: 1rem; transition: 80ms ease; color: white; background: #ccc; padding: 0.4rem 0.8rem;}.egg_info_item .egg_login_btn:active { opacity: 0.8;}.egg_info_item { display: flex; justify-content: space-between; align-items: center;}.egg_info_item .egg_userinfo { display: flex; justify-content: center; align-items: center; padding: 0.5rem 0;}.egg_userinfo .egg_avatar .egg_avatar_nick,.egg_userinfo .egg_avatar .egg_avatar_img { height: 5rem; width: 5rem; border-radius: 50%; background: var(--themeColor); display: flex; justify-content: center; align-items: center; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size: 2rem; color: white;}.egg_userinfo .egg_nick { padding-left: 0.5rem; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 10rem;}.egg_score_item .egg_scoreinfo { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0;}.egg_scoreinfo .egg_totalscore,.egg_scoreinfo .egg_todayscore { font-size: 1.2rem; user-select: none;}.egg_scoreinfo .egg_totalscore span,.egg_scoreinfo .egg_todayscore .egg_todayscore_btn span { padding-left: 0.2rem;}.egg_scoreinfo .egg_totalscore span,.egg_todayscore .egg_todayscore_btn span,.egg_todayscore .egg_score_details span { color: var(--themeColor); font-weight: bold;}.egg_scoreinfo .egg_todayscore { position: relative;}.egg_todayscore .egg_todayscore_btn { display: flex; align-items: center;}.egg_todayscore_btn .egg_icon { opacity: 0.3;}.egg_todayscore .egg_score_details { position: absolute; left: calc(100% + 1rem); top: 0; background: #fffffff2; border-radius: 0.5rem; opacity: 1; width: 10rem; box-shadow: 0 0 0.1rem 0.1rem #f1f1f1; transition: 80ms ease; z-index: 9;}.egg_todayscore .egg_score_details.hide { visibility: hidden; opacity: 0; left: 100%;}.egg_score_details .egg_score_title { border-bottom: 0.1rem solid #eee; padding: 0.5rem 0.8rem; display: flex; align-items: center;}.egg_score_details .egg_score_title .egg_icon { font-size: 1.4rem;}.egg_score_details .egg_score_title .egg_score_title_text { font-weight: bold; padding-left: 0.2rem;}.egg_score_details .egg_score_item { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.8rem;}.egg_task_list { position: relative;}.egg_task_item { user-select: none; min-height: 3rem; min-width: 18rem; display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0;}.egg_task_item .egg_label_wrap { flex-grow: 1; padding-right: 0.5rem;}.egg_label_wrap .egg_task_title_wrap { display: flex; justify-content: space-between; align-items: center;}.egg_task_title_wrap .egg_task_progress_wrap { display: flex; align-items: center; font-size: 1.4rem; width: 3.5rem;}.egg_task_progress_wrap .egg_task_current { color: var(--themeColor);}.egg_task_progress_wrap .egg_task_max { color: #999; font-size: 1.2rem;}.egg_label_wrap .egg_progress { display: flex; justify-content: space-between; align-items: center; padding-top: 0.8rem;}.egg_progress .egg_track { background: #ccc; height: 0.5rem; border-radius: 1rem; flex: 1 1 auto; overflow: hidden;}.egg_progress .egg_track .egg_bar { height: 0.5rem; background: var(--themeColor); border-radius: 1rem; width: 0; transition: width 0.5s;}.egg_setting_item { min-height: 3rem; min-width: 18rem; display: flex; align-items: center; justify-content: space-between; box-sizing: border-box;}.egg_setting_item .egg_label_wrap { flex-grow: 1;}.egg_detail { background: #ccc; color: white; border-radius: 10rem; font-size: 1.2rem; width: 1.6rem; height: 1.6rem; margin-left: 0.4rem; display: inline-block; text-align: center; line-height: 1.6rem; cursor: pointer;}.egg_switch { cursor: pointer; margin: 0; outline: 0; appearance: none; -webkit-appearance: none; -moz-appearance: none; position: relative; width: 4.2rem; height: 2.2rem; background: #ccc; border-radius: 5rem; transition: background 0.3s; --border-padding: 0.5rem; box-shadow: -0.1rem 0 0.1rem -0.1rem #999 inset, 0.1rem 0 0.1rem -0.1rem #999 inset;}.egg_switch::after { content: \'\'; display: inline-block; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: #fff; box-shadow: 0 0 0.2rem #999; transition: left 0.4s; position: absolute; top: calc(50% - (1.4rem / 2)); position: absolute; left: var(--border-padding);}.egg_switch:checked { background: var(--themeColor);}.egg_switch:disabled { opacity: 0.5; background: #ccc;}.egg_switch:checked::after { left: calc(100% - var(--border-padding) - 1.4rem);}.egg_tip_list { font-size: 1.2rem; max-width: 18rem; line-height: 2rem; color: var(--themeColor);}.egg_tip_list .egg_tip_btn { padding: 0.2rem 0.4rem; background: #f1f1f1; color: #333;}.egg_tip_list .egg_tip_btn:disabled { opacity: 0.5; background: #ccc;}.egg_tip_list .egg_tip_content { text-align: center; padding-top: 0.2rem;}.egg_study_item { display: flex; justify-content: center; padding-top: 0.5rem;}.egg_study_item .egg_study_btn { background: var(--themeColor); padding: 0.8rem 2.4rem; font-size: 1.4rem; border-radius: 1rem; color: white; transition: 80ms ease;}.egg_study_item .egg_study_btn:not(.loading):active { opacity: 0.8;}.egg_study_item .egg_study_btn.loading { animation: fade 2s ease infinite alternate;}.egg_study_item .egg_study_btn:disabled { background: #ccc;}.egg_tip_wrap { position: fixed; left: 0; top: 0; z-index: 999999; width: 100%; height: 100%; pointer-events: none;}.egg_tip_wrap * { padding: 0; margin: 0; box-sizing: border-box; outline: none; border: none;}.egg_tip_wrap .egg_tip { position: absolute; bottom: 2rem; left: 2rem; padding: 1.2rem 1.4rem; border: none; border-radius: 1rem; background: var(--themeColor); color: white; font-size: 1.4rem; transition: 200ms ease; opacity: 0; transform: scale(0.9) translateY(1rem);}.egg_tip_wrap .egg_tip.active { opacity: 1; transform: scale(1) translateY(0);}.egg_tip_wrap .egg_tip.active.delay { opacity: 0.5;}.egg_tip_wrap .egg_tip .egg_countdown { display: inline-block; color: var(--themeColor); background: white; border-radius: 0.5rem; padding: 0.2rem 0.4rem; font-weight: bold; margin-left: 0.4rem; font-size: 1.2rem;}.egg_frame_wrap { position: fixed; left: 0; top: 0; z-index: 999; width: 100%; height: 100%; visibility: visible;}.egg_frame_wrap * { padding: 0; margin: 0; box-sizing: border-box; outline: none; border: none;}.egg_frame_wrap.hide { visibility: hidden;}.egg_frame_wrap.hide .egg_frame_mask,.egg_frame_wrap.hide .egg_frame_content_wrap { opacity: 0;}.egg_frame_wrap.hide .egg_frame_content_wrap { transform: scale(0);}.egg_frame_mask { background: #00000030; width: 100%; height: 100%; opacity: 1; transition: 200ms ease;}.egg_frame_content_wrap { position: absolute; width: 80%; height: 80%; top: 10%; left: 10%; display: flex; flex-direction: column; transition: 200ms ease; border-radius: 1rem; background: #ffffffe6; backdrop-filter: blur(1rem); overflow: hidden; transform: scale(1);}.egg_frame_content_wrap.max { top: 0; left: 0; width: 100%; height: 100%; border-radius: 0;}.egg_frame_content_wrap .egg_frame_controls_wrap { width: 100%; display: flex; justify-content: space-between; align-items: center; box-sizing: border-box;}.egg_frame_controls_wrap .egg_frame_title { padding: 1rem 2rem; font-size: 1.6rem;}.egg_frame_controls .egg_frame_btn { outline: none; border: none; background: none; padding: 1rem 2rem; transition: 80ms ease; cursor: pointer; color: #333; font-size: 1.8rem;}.egg_frame_controls .egg_frame_btn:active { opacity: 0.8;}.egg_frame_wrap .egg_frame_content { width: 100%; flex-grow: 1; border-top: 0.1rem solid #ccc; min-height: 40rem; min-width: 30rem; background: white;}.egg_frame_content .egg_frame { width: 100%; height: 100%; outline: none; border: none;}.egg_time_input { display: inline-flex; align-items: center; justify-content: center;}.egg_time_input .egg_hour_wrap,.egg_time_input .egg_minute_wrap { width: 4rem;}.egg_time_input .egg_separator { padding: 0 0.5rem; font-size: 1.5rem;}.egg_settings_item { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; border-radius: 1rem;}.egg_settings_item .egg_settings { display: inline-flex; flex-direction: column; font-size: 1.4rem; background: white; border-radius: 1rem; overflow: hidden; width: 100%; height: 100%; pointer-events: all; transform: translateX(100%); transition: transform 300ms ease; padding-top: 1rem;}.egg_settings_item .egg_settings.active { transform: translateX(0);}.egg_settings .egg_settings_label { padding-bottom: 1rem; user-select: none;}.egg_settings_item .egg_settings_version_wrap { padding: 1rem 2rem 0 2rem; display: flex; align-items: center; justify-content: space-between;}.egg_settings_version_wrap .egg_settings_version { color: #999; display: flex; align-items: center;}.egg_settings_version .egg_settings_version_detail { color: #24292f; font-size: 1.6rem; width: 1.6rem; height: 1.6rem; margin-left: 0.4rem;}.egg_settings_item .egg_settings_theme_wrap { padding: 1rem 2rem 0 2rem;}.egg_settings_theme_wrap .egg_settings_theme_colors { display: flex; align-items: center; justify-content: space-between;}.egg_settings_theme_color_wrap .egg_settings_theme_color { border-radius: 50%; width: 1.6rem; height: 1.6rem; background: currentColor;}.egg_settings .egg_settings_read_time_wrap,.egg_settings .egg_settings_watch_time_wrap { padding: 1rem 2rem 0 2rem; display: flex; justify-content: space-between; align-items: center;}.egg_settings_read_time_wrap .egg_settings_label,.egg_settings_watch_time_wrap .egg_settings_label { padding: 0.5rem 0;}.egg_settings_read_time_wrap .egg_select,.egg_settings_watch_time_wrap .egg_select { width: 6rem;}.egg_settings .egg_settings_token_wrap { padding: 1rem 2rem 0 2rem;}.egg_settings_token_wrap .egg_settings_token_input { outline: none; border: 0.1rem solid #eee; padding: 1rem; background: white; border-radius: 0.2rem; width: 100%; box-sizing: border-box; color: #ccc;}.egg_settings_token_wrap .egg_settings_token_input.active { color: #333;}.egg_settings_token_input::placeholder { color: #ccc;}.egg_settings .egg_settings_submit_btn_wrap { text-align: right; padding-top: 1rem; display: none;}.egg_settings .egg_settings_submit_btn_wrap.active { display: block;}.egg_settings_submit_btn_wrap .egg_settings_submit_btn { outline: none; border: 0.1rem solid #eee; padding: 0.5rem 1rem; text-align: center; background: white; border-radius: 0.2rem; cursor: pointer;}.egg_settings_submit_btn_wrap .egg_settings_submit_btn:active { background: #eee;}.egg_schedule { height: 100%; display: flex; flex-direction: column;}.egg_schedule_time_wrap { padding: 1rem 2rem; border-bottom: 0.1rem solid #eee;}.egg_schedule_time .egg_schedule_label { padding-bottom: 1rem; user-select: none;}.egg_schedule_time .egg_schedule_time_input_wrap { display: flex; justify-content: space-between; align-items: center;}.egg_schedule_time_input_wrap .egg_schedule_add_btn { outline: none; border: 0.1rem solid #eee; padding: 0.5rem 1rem; text-align: center; background: white; border-radius: 0.2rem; cursor: pointer;}.egg_schedule_time_input_wrap .egg_schedule_add_btn:active { background: #eee;}.egg_schedule_list { height: 100%; overflow: auto;}.egg_schedule_list .egg_schedule_item { display: flex; justify-content: space-between; padding: 0.5rem 1.5rem; font-size: 1.4rem; border-bottom: 0.1rem solid #eee;}.egg_schedule_list::-webkit-scrollbar { width: 0.4rem; background: white; border-radius: 0.2rem;}.egg_schedule_list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 0.2rem;}.egg_schedule_detail_time_wrap { display: flex; align-items: center;}.egg_schedule_detail_time_wrap.inactive { color: #ccc;}.egg_schedule_detail_time_wrap .egg_schedule_detail_icon { padding-right: 0.4rem; display: flex; color: #ccc;}.egg_schedule_detail_del_wrap .egg_schedule_del_btn { outline: none; padding: 1rem; text-align: center; background: white; border-radius: 0.2rem; font-size: 1.4rem; cursor: pointer; color: #ccc;}.egg_schedule_detail_del_wrap .egg_schedule_del_btn:hover { color: #333;}.egg_schedule_detail_del_wrap .egg_schedule_del_btn:active { color: #eee;}.egg_schedule_list .egg_schedule_list_none { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #ccc;}.egg_schedule_list_none .egg_icon { font-size: 2.5rem;}.egg_schedule_list_none_text { padding-top: 1rem;}.egg_select { position: relative;}.egg_select .egg_select_input { outline: none; border: 0.1rem solid #eee; padding: 0.8rem; text-align: center; background: white; border-radius: 0.2rem; display: inline-block; width: 100%; box-sizing: border-box;}.egg_select .egg_select_input::placeholder { color: #ccc;}.egg_select_list { max-height: 12rem; border-radius: 0 0 0.2rem 0.2rem; box-shadow: 0 0.1rem 0.1rem 0.1rem #eee; background: white; user-select: none; transition: 100ms ease; scrollbar-width: thin; overflow: auto; opacity: 1; z-index: 9; width: 100%; position: absolute;}.egg_select_list.hide { opacity: 0; visibility: hidden;}.egg_select_list::-webkit-scrollbar { width: 0.4rem; background: white; border-radius: 0.2rem;}.egg_select_list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 0.2rem;}.egg_select_list .egg_select_item { padding: 0.6rem 1rem; border-bottom: 0.1rem solid #eee; cursor: pointer; color: #333; transition: 300ms ease; text-align: center;}.egg_select_list .egg_select_item.selected { font-weight: bold; background: #f6f6f6;}.egg_select_list .egg_select_item.active { background: #eee;}.egg_select_list .egg_select_item:hover { background: #eee;}';
/**
* @description 嵌入样式
*/
GM_addStyle(css);
load((href) => href.match(URL_CONFIG.home), () => {
// 初始化logo
initLogo();
// 页面提示
log('进入主页面!');
// 初始化主题
initThemeColor();
// 初始化任务配置
initTaskConfig();
// 初始化设置
initSettings();
// 设置字体
initFontSize();
// 初始化主页面
initMainListener();
// 初始化提示
renderTip();
// 渲染面板
renderPanel();
// 渲染窗口
renderFrame();
});
load((href) => href === GM_getValue('readingUrl'), async () => {
// 页面提示
log('进入文章选读页面!');
// 初始化主题
initThemeColor();
// 初始化设置
initSettings();
// 设置字体
initFontSize();
// 最大阅读
initMaxRead();
// 初始化子页面
initChildListener();
// 初始化提示
renderTip();
try {
// 处理文章
await handleNews();
}
catch (err) {
if (err instanceof Error) {
// 提示
createTip(err.message);
// 错误
error(err.message);
return;
}
// 提示
createTip(String(err));
// 错误
error(err);
}
});
load((href) => href === GM_getValue('watchingUrl'), async () => {
// 页面提示
log('进入视听学习页面!');
// 初始化主题
initThemeColor();
// 初始化设置
initSettings();
// 设置字体
initFontSize();
// 最大视听
initMaxWatch();
// 初始化子页面
initChildListener();
// 初始化提示
renderTip();
try {
// 处理视频
await handleVideo();
}
catch (err) {
if (err instanceof Error) {
// 提示
createTip(err.message);
// 错误
error(err.message);
return;
}
// 提示
createTip(String(err));
// 错误
error(err);
}
});
load((href) => href === URL_CONFIG.examPractice, async () => {
// 页面提示
log('进入每日答题页面!');
// 初始化主题
initThemeColor();
// 初始化设置
initSettings();
// 设置字体
initFontSize();
// 初始化子页面
initChildListener();
// 初始化提示
renderTip();
// 创建答题按钮
await renderExamBtn();
try {
// 开始答题
await doingExam(ExamType.PRACTICE);
}
catch (err) {
if (err instanceof Error) {
// 提示
createTip(err.message);
// 错误
error(err.message);
return;
}
// 提示
createTip(String(err));
// 错误
error(err);
}
});
load((href) => href.includes(URL_CONFIG.examPaper), async () => {
// 页面提示
log('进入专项练习页面!');
// 初始化主题
initThemeColor();
// 初始化设置
initSettings();
// 设置字体
initFontSize();
// 初始化子页面
initChildListener();
// 初始化提示
renderTip();
// 创建答题按钮
await renderExamBtn();
// 开始答题
doingExam(ExamType.PAPER);
return;
});
/**
* @description 初始化logo
*/
function initLogo() {
console.log(`%c tech-study.js %c ${version} `, 'background:dodgerblue;color:white;font-size:15px;border-radius:4px 0 0 4px;padding:2px 0;', 'background:black;color:gold;font-size:15px;border-radius:0 4px 4px 0;padding:2px 0;');
}
/**
* @description 初始化配置
*/
function initTaskConfig() {
try {
const taskTemp = JSON.parse(GM_getValue('taskConfig'));
if (taskTemp && Array.isArray(taskTemp)) {
if (taskTemp.length === taskConfig.length) {
taskConfig.forEach((task, i) => {
task.active = taskTemp[i].active;
});
}
}
// 监听值变化
GM_addValueChangeListener('taskConfig', (key, oldVal, newVal, remote) => {
if (remote) {
const taskTemp = JSON.parse(newVal);
if (taskTemp && Array.isArray(taskTemp)) {
if (taskTemp.length === taskConfig.length) {
taskConfig.forEach((task, i) => {
task.active = taskTemp[i].active;
});
}
}
}
});
}
catch (e) { }
}
/**
* @description 初始化配置
*/
function initSettings() {
try {
const settingsTemp = JSON.parse(GM_getValue('studySettings'));
if (settingsTemp && Array.isArray(settingsTemp)) {
if (settingsTemp.length === settings.length) {
for (const i in settingsTemp) {
settings[i] = settingsTemp[i];
}
}
}
// 监听值变化
GM_addValueChangeListener('studySettings', (key, oldVal, newVal, remote) => {
if (remote) {
const settingsTemp = JSON.parse(newVal);
if (settingsTemp && Array.isArray(settingsTemp)) {
if (settingsTemp.length === settings.length) {
for (const i in settingsTemp) {
settings[i] = settingsTemp[i];
}
}
}
}
});
}
catch (e) { }
}
/**
* @description 初始化配置
*/
function initFontSize() {
// 移动端
const moblie = hasMobile();
if (moblie) {
// 清除缩放
const meta = $$('meta[name=viewport]')[0];
if (meta) {
meta.content = 'initial-scale=0, user-scalable=yes';
}
// 缩放比例
const scale = ~~(window.innerWidth / window.outerWidth) || 1;
document.documentElement.style.setProperty('--scale', String(scale));
}
}
/**
* @description 初始化最大阅读时长
*/
function initMaxRead() {
try {
const maxReadTemp = GM_getValue('maxRead');
if (maxReadTemp) {
maxRead.value = maxReadTemp;
}
}
catch (error) { }
}
/**
* @description 初始化最大视听时长
*/
function initMaxWatch() {
try {
const maxWatchTemp = GM_getValue('maxWatch');
if (maxWatchTemp) {
maxWatch.value = maxWatchTemp;
}
}
catch (error) { }
}
/**
* @description 初始化主题色
*/
function initThemeColor() {
try {
// 监听主题变化
watch(themeColor, () => {
// 设置主题
document.documentElement.style.setProperty('--themeColor', themeColor.value);
});
// 主题色
const themeColorTemp = GM_getValue('themeColor');
if (themeColorTemp) {
themeColor.value = themeColorTemp;
}
// 监听值变化
GM_addValueChangeListener('themeColor', (key, oldVal, newVal, remote) => {
if (remote) {
// 主题色
const themeColorTemp = newVal;
if (themeColorTemp) {
themeColor.value = themeColorTemp;
}
}
});
}
catch (error) { }
}
/**
* @description 渲染提示
*/
function renderTip() {
const tipWrap = createElementNode('div', undefined, {
class: 'egg_tip_wrap',
onclick(e) {
e.stopPropagation();
},
onmousedown(e) {
e.stopPropagation();
},
onmousemove(e) {
e.stopPropagation();
},
onmouseup(e) {
e.stopPropagation();
},
onmouseenter(e) {
e.stopPropagation();
},
onmouseleave(e) {
e.stopPropagation();
},
onmouseover(e) {
e.stopPropagation();
},
ontouchstart(e) {
e.stopPropagation();
},
ontouchmove(e) {
e.stopPropagation();
},
ontouchend(e) {
e.stopPropagation();
},
oninput(e) {
e.stopPropagation();
},
onchange(e) {
e.stopPropagation();
},
onblur(e) {
e.stopPropagation();
},
});
mountElement(tipWrap);
}
/**
* @description 渲染答题按钮
*/
async function renderExamBtn() {
const titles = await $_('.title');
if (titles.length) {
// 插入节点
titles[0].parentNode?.insertBefore(ExamBtn().ele, titles[0].nextSibling);
}
}
/**
* @description 渲染面板
* @returns
*/
async function renderPanel() {
// 面板
const panel = Panel();
// 插入节点
mountElement(panel);
}
/**
* @description 渲染窗口
*/
function renderFrame() {
// 窗口
const frame = Frame();
// 插入节点
mountElement(frame);
}
/* 答案 API */
/**
* @description 获取答案
*/
async function getAnswer(question) {
// 数据
const data = {
txt_name: md5(question),
password: '',
};
try {
const params = new URLSearchParams(data);
// 请求
const res = await fetch(API_CONFIG.answerSearch, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: params.toString(),
});
// 请求成功
if (res.ok) {
const result = await res.json();
const { data, status } = result;
if (status !== 0) {
// 答案列表
const answerList = JSON.parse(data.txt_content);
// 答案
const answers = answerList[0].content.split(/[;\s]/);
return answers;
}
}
}
catch (error) { }
return [];
}
/**
* @description 保存答案
*/
async function saveAnswer(question, answer) {
try {
// 内容
const content = JSON.stringify([{ title: md5(question), content: answer }]);
// 数据
const data = {
txt_name: md5(question),
txt_content: content,
password: '',
v_id: '',
};
const params = new URLSearchParams(data);
// 请求
const res = await fetch(API_CONFIG.answerSave, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: params.toString(),
});
// 请求成功
if (res.ok) {
const data = await res.json();
return data;
}
}
catch (error) { }
}
/* 数据 API */
/**
* @description 获取新闻数据
*/
async function getNewsList() {
// 随机
const randNum = ~~(Math.random() * API_CONFIG.todayNews.length);
try {
// 获取重要新闻
const res = await fetch(API_CONFIG.todayNews[randNum], {
method: 'GET',
});
// 请求成功
if (res.ok) {
const data = await res.json();
return data;
}
}
catch (err) { }
}
/**
* @description 获取视频数据
*/
async function getVideoList() {
// 随机
const randNum = ~~(Math.random() * API_CONFIG.todayVideos.length);
try {
// 获取重要新闻
const res = await fetch(API_CONFIG.todayVideos[randNum], {
method: 'GET',
});
// 请求成功
if (res.ok) {
const data = await res.json();
return data;
}
}
catch (err) { }
}
/**
* @description 专项练习数据
*/
async function getExamPaper(pageNo) {
// 链接
const url = `${API_CONFIG.paperList}?pageSize=50&pageNo=${pageNo}`;
try {
// 获取专项练习
const res = await fetch(url, {
method: 'GET',
credentials: 'include',
});
// 请求成功
if (res.ok) {
const data = await res.json();
const paperJson = decodeURIComponent(escape(window.atob(data.data_str.replace(/-/g, '+').replace(/_/g, '/'))));
// JSON格式化
const paper = JSON.parse(paperJson);
return paper;
}
}
catch (err) {
return [];
}
return [];
}
/**
* @description 生成二维码
*/
async function generateQRCode() {
try {
// 推送
const res = await fetch(API_CONFIG.generateQRCode, {
method: 'GET',
mode: 'cors',
});
// 请求成功
if (res.ok) {
const data = await res.json();
if (data.success) {
return data.result;
}
}
}
catch (error) { }
}
/**
* @description 用二维码登录
*/
async function loginWithQRCode(qrCode) {
try {
const params = new URLSearchParams({
qrCode,
goto: 'https://oa.xuexi.cn',
pdmToken: '',
});
// 推送
const res = await fetch(API_CONFIG.loginWithQRCode, {
method: 'POST',
mode: 'cors',
credentials: 'include',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
},
body: params.toString(),
});
// 请求成功
if (res.ok) {
const data = await res.json();
return data;
}
}
catch (error) { }
}
/**
* @description 签名
*/
async function getSign() {
try {
// 推送
const res = await fetch(API_CONFIG.sign, {
method: 'GET',
mode: 'cors',
credentials: 'include',
});
// 请求成功
if (res.ok) {
const data = await res.json();
if (data.ok) {
return data.data.sign;
}
}
}
catch (error) { }
}
/**
* @description 安全检查
* @param data
*/
async function secureCheck(data) {
try {
const params = new URLSearchParams(data);
const url = `${API_CONFIG.secureCheck}?${params}`;
// 推送
const res = await fetch(url, {
method: 'GET',
mode: 'cors',
credentials: 'include',
});
// 请求成功
if (res.ok) {
const data = await res.json();
return data.success;
}
}
catch (error) { }
return false;
}
/* 推送 API */
/**
* @description 推送
*/
async function pushPlus(token, title, content, template, toToken) {
try {
// 参数体
const body = {
token,
title,
content,
template,
};
// 好友令牌
if (toToken) {
body.to = toToken;
}
// 推送
const res = await fetch(API_CONFIG.push, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
// 请求成功
if (res.ok) {
const data = await res.json();
return data;
}
}
catch (error) { }
}
/* 用户 API */
/**
* @description 获取用户信息
*/
async function getUserInfo() {
try {
const res = await fetch(API_CONFIG.userInfo, {
method: 'GET',
credentials: 'include',
});
// 请求成功
if (res.ok) {
const { data } = await res.json();
return data;
}
}
catch (err) { }
}
/**
* @description 获取总积分
*/
async function getTotalScore() {
try {
const res = await fetch(API_CONFIG.totalScore, {
method: 'GET',
credentials: 'include',
});
// 请求成功
if (res.ok) {
const { data } = await res.json();
// 总分
const { score } = data;
return score;
}
}
catch (err) { }
}
/**
* @description 获取当天总积分
*/
async function getTodayScore() {
try {
const res = await fetch(API_CONFIG.todayScore, {
method: 'GET',
credentials: 'include',
});
// 请求成功
if (res.ok) {
const { data } = await res.json();
// 当天总分
const { score } = data;
return score;
}
}
catch (err) { }
}
/**
* @description 获取任务列表
*/
async function getTaskList() {
try {
const res = await fetch(API_CONFIG.taskList, {
method: 'GET',
credentials: 'include',
});
// 请求成功
if (res.ok) {
const { data } = await res.json();
// 进度和当天总分
const { taskProgress } = data;
return taskProgress;
}
}
catch (err) { }
}
/* task·配置 */
/**
* @description 单次最大新闻数
*/
const maxNewsNum = 6;
/**
* @description 单次最大视频数
*/
const maxVideoNum = 6;
/**
* @description 二维码最大刷新次数
*/
const maxRefreshCount = 10;
/**
* @description 二维码自动刷新间隔
*/
const autoRefreshQRCodeInterval = 100000;
/**
* @description url配置
*/
const URL_CONFIG = {
// 主页正则
home: /^https\:\/\/www\.xuexi\.cn(\/(index\.html)?)?$/,
// 主页
homeOrigin: 'https://www.xuexi.cn',
// 每日答题页面
examPractice: 'https://pc.xuexi.cn/points/exam-practice.html',
// 专项练习页面
examPaper: 'https://pc.xuexi.cn/points/exam-paper-detail.html',
};
/**
* @description api配置
*/
const API_CONFIG = {
// 用户信息
userInfo: 'https://pc-api.xuexi.cn/open/api/user/info',
// 总分
totalScore: 'https://pc-proxy-api.xuexi.cn/delegate/score/get',
// 当天分数
todayScore: 'https://pc-proxy-api.xuexi.cn/delegate/score/today/query',
// 任务列表
taskList: 'https://pc-proxy-api.xuexi.cn/delegate/score/days/listScoreProgress?sence=score&deviceType=2',
// 新闻数据
todayNews: [
'https://www.xuexi.cn/lgdata/35il6fpn0ohq.json',
'https://www.xuexi.cn/lgdata/1ap1igfgdn2.json',
'https://www.xuexi.cn/lgdata/vdppiu92n1.json',
'https://www.xuexi.cn/lgdata/152mdtl3qn1.json',
],
// 视频数据
todayVideos: [
'https://www.xuexi.cn/lgdata/525pi8vcj24p.json',
'https://www.xuexi.cn/lgdata/11vku6vt6rgom.json',
'https://www.xuexi.cn/lgdata/2qfjjjrprmdh.json',
'https://www.xuexi.cn/lgdata/3o3ufqgl8rsn.json',
'https://www.xuexi.cn/lgdata/591ht3bc22pi.json',
'https://www.xuexi.cn/lgdata/1742g60067k.json',
'https://www.xuexi.cn/lgdata/1novbsbi47k.json',
],
// 专项练习列表
paperList: 'https://pc-proxy-api.xuexi.cn/api/exam/service/paper/pc/list',
// 文本服务器保存答案
answerSave: 'https://a6.qikekeji.com/txt/data/save',
// 文本服务器获取答案
answerSearch: 'https://a6.qikekeji.com/txt/data/detail',
// 推送
push: 'https://www.pushplus.plus/send',
// 生成二维码
generateQRCode: 'https://login.xuexi.cn/user/qrcode/generate',
//二维码登录
loginWithQRCode: 'https://login.xuexi.cn/login/login_with_qr',
// 签名
sign: 'https://pc-api.xuexi.cn/open/api/sns/sign',
// 安全检查
secureCheck: 'https://pc-api.xuexi.cn/login/secure_check',
// 二维码
qrcode: 'https://api.qrserver.com/v1/create-qr-code',
};
/**
* @description 版本号
*/
const version = '1.7.5';
/**
* @description 任务类型
*/
var TaskType;
(function (TaskType) {
TaskType[TaskType["LOGIN"] = 0] = "LOGIN";
TaskType[TaskType["READ"] = 1] = "READ";
TaskType[TaskType["WATCH"] = 2] = "WATCH";
TaskType[TaskType["PRACTICE"] = 3] = "PRACTICE";
})(TaskType || (TaskType = {}));
/**
* @description 设置类型
*/
var SettingType;
(function (SettingType) {
SettingType[SettingType["AUTO_START"] = 0] = "AUTO_START";
SettingType[SettingType["SAME_TAB"] = 1] = "SAME_TAB";
SettingType[SettingType["SILENT_RUN"] = 2] = "SILENT_RUN";
SettingType[SettingType["SCHEDULE_RUN"] = 3] = "SCHEDULE_RUN";
SettingType[SettingType["VIDEO_MUTED"] = 4] = "VIDEO_MUTED";
SettingType[SettingType["RANDOM_EXAM"] = 5] = "RANDOM_EXAM";
SettingType[SettingType["AUTO_ANSWER"] = 6] = "AUTO_ANSWER";
SettingType[SettingType["REMOTE_PUSH"] = 7] = "REMOTE_PUSH";
})(SettingType || (SettingType = {}));
/**
* @description 进度类型
*/
var TaskStatusType;
(function (TaskStatusType) {
TaskStatusType[TaskStatusType["LOADING"] = 0] = "LOADING";
TaskStatusType[TaskStatusType["LOADED"] = 1] = "LOADED";
TaskStatusType[TaskStatusType["START"] = 2] = "START";
TaskStatusType[TaskStatusType["PAUSE"] = 3] = "PAUSE";
TaskStatusType[TaskStatusType["FINISH"] = 4] = "FINISH";
})(TaskStatusType || (TaskStatusType = {}));
// 当前订阅
let currentSub;
// 订阅
const subscription = new WeakMap();
/**
* @description Proxy Map
*/
const proxyMap = new WeakMap();
/**
* @description 收集 Ref 依赖
* @param target
* @param key
*/
const trackRef = (target) => {
// 当前订阅
if (!currentSub) {
return;
}
// target 订阅列表
let subList = subscription.get(target);
// 不存在订阅列表
if (!subList) {
subList = new Map();
// 键订阅
const subkeyList = new Set();
// 添加订阅
subkeyList.add(currentSub);
subList.set('value', subkeyList);
subscription.set(target, subList);
return;
}
// 键订阅
let subkeyList = subList.get('value');
if (!subkeyList) {
// 键订阅
subkeyList = new Set();
// 添加订阅
subkeyList.add(currentSub);
subList.set('value', subkeyList);
subscription.set(target, subList);
return;
}
// 添加订阅
subkeyList.add(currentSub);
};
/**
* @description 通知 Ref 订阅
* @param terget
* @param key
* @returns
*/
function triggerRef(target, newVal, oldVal) {
// target 订阅列表
const subList = subscription.get(target);
if (!subList) {
return;
}
// 键订阅
let subkeyList = subList.get('value');
if (!subkeyList) {
return;
}
// 通知订阅
for (const fn of subkeyList) {
if (fn instanceof Function) {
fn(newVal, oldVal);
}
}
}
/**
* @description 收集依赖
* @param target
* @param key
*/
const track = (target, key) => {
// 当前订阅
if (!currentSub) {
return;
}
// proxy
const proxyTarget = proxyMap.get(target);
if (!proxyTarget) {
return;
}
// target 订阅列表
let subList = subscription.get(target);
// 不存在订阅列表
if (!subList) {
subList = new Map();
// 键订阅
const subkeyList = new Set();
// 添加订阅
subkeyList.add(currentSub);
subList.set(key, subkeyList);
subscription.set(target, subList);
return;
}
// 键订阅
let subkeyList = subList.get(key);
if (!subkeyList) {
// 键订阅
subkeyList = new Set();
// 添加订阅
subkeyList.add(currentSub);
subList.set(key, subkeyList);
subscription.set(target, subList);
return;
}
// 添加订阅
subkeyList.add(currentSub);
};
/**
* @description 通知订阅
* @param terget
* @param key
* @returns
*/
function trigger(target, key, newVal, oldVal) {
// proxy
const proxyTarget = proxyMap.get(target);
if (!proxyTarget) {
return;
}
// proxyTarget 订阅列表
const subList = subscription.get(target);
if (!subList) {
return;
}
// 键订阅
let subkeyList = subList.get(key);
if (!subkeyList) {
return;
}
// 通知订阅
for (const fn of subkeyList) {
fn(newVal, oldVal);
}
}
/**
* @description 只读键
*/
var ReactiveFlags;
(function (ReactiveFlags) {
ReactiveFlags["IS_REF"] = "_isRef";
ReactiveFlags["IS_SHALLOW"] = "_isShallow";
ReactiveFlags["IS_REACTIVE"] = "_isReactive";
ReactiveFlags["IS_READONLY"] = "_isReadonly";
})(ReactiveFlags || (ReactiveFlags = {}));
/**
* @description Ref
*/
class Ref {
_isShallow = false;
_isRef = true;
_value;
value;
constructor(val, shallow = false) {
const _this = this;
this._isShallow = shallow;
if (val && typeof val === 'object' && shallow) {
const reactiveVal = reactive(val);
this._value = reactiveVal;
this.value = reactiveVal;
}
else {
this._value = val;
this.value = val;
}
// 定义属性
Object.defineProperty(this, 'value', {