-
Notifications
You must be signed in to change notification settings - Fork 23
/
MainWindow.xaml.cs
1156 lines (1028 loc) · 48 KB
/
MainWindow.xaml.cs
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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using CefSharp;
using JdLoginTool.Wpf.Model;
using JdLoginTool.Wpf.Model.Qinglong;
using JdLoginTool.Wpf.Service;
using JdLoginTool.Wpf.Utility;
using Newtonsoft.Json;
using RestSharp;
using Cookie = CefSharp.Cookie;
namespace JdLoginTool.Wpf
{
public class JsObj
{
public static MainWindow Main { get; set; }
public void SetJsBox(string s)
{
Main.SetJsBox(s);
}
public bool Test()
{
return true;
}
}
public partial class MainWindow : Window, INotifyPropertyChanged
{
public static string CachePath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "cache.json");
public static string CookiePath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "config.sh");
public static string Phone = "";
private string _defaultUa;
private bool _IsRunning;
private Visibility _IsSimpleMode = Visibility.Hidden;
private ObservableCollection<User> _userList = new ObservableCollection<User>();
private ICookieManager CookieManager;
public List<string> CookieStringList = new List<string>();
private bool exit;
private bool stop;
public MainWindow()
{
InitializeComponent();
DateTimePicker.Value = DateTime.Now;
DataContext = this;
var j = "[]";
if (!File.Exists(CachePath))
{
File.Create(CachePath, 1024 * 10, FileOptions.RandomAccess);
}
else
{
j = File.ReadAllText(CachePath);
}
if (File.Exists("ua.txt"))
{
_defaultUa = File.ReadAllText("ua.txt");
}
if (File.Exists("url.txt"))
{
UrlBox.Text = File.ReadAllText("url.txt");
}
if (File.Exists("js.txt"))
{
JsBox.Text = File.ReadAllText("js.txt");
}
if (!string.IsNullOrWhiteSpace(j))
{
try
{
var tmp = JsonConvert.DeserializeObject<List<User>>(j);
if (tmp.Any())
{
foreach (var userInfo in tmp)
{
UserList.Add(userInfo);
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
CefSharpSettings.WcfEnabled = false;
Browser.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
JsObj.Main = this;
Browser.JavascriptObjectRepository.Register("gui", new JsObj(), true); //这个地方相当于注册了一个BO(浏览器对象,和window对象是平级的)
Browser.TitleChanged += Browser_TitleChanged;
Browser.KeyUp += TryGetUserInputPhone;
Loaded += (o, e) => { Browser.Address = "m.jd.com"; };
Browser.MenuHandler = new MenuHandler();
Browser.FrameLoadEnd += Browser_FrameLoadEnd;
Closing += (o, e) =>
{
var json = JsonConvert.SerializeObject(UserList, Formatting.Indented);
Console.WriteLine(json);
File.WriteAllText(CachePath, json);
stop = true;
exit = true;
};
if (string.IsNullOrWhiteSpace(UrlBox.Text))
{
UrlBox.Text =
"https://coupon.m.jd.com/coupons/show.action?key=c0m2c5s1o3a04f8c8c925cac41c942bb&roleId=88645899&time=1668045928261#183_871058406";
}
}
public Visibility IsSimpleMode
{
get => _IsSimpleMode;
set
{
_IsSimpleMode = value;
RaisePropertyChanged();
}
}
public ObservableCollection<User> UserList
{
get => _userList;
set
{
_userList = value;
RaisePropertyChanged();
}
}
public int CkIndex { get; set; }
public bool IsRunning
{
get => _IsRunning;
set
{
_IsRunning = value;
RaisePropertyChanged();
}
}
public static ObservableCollection<string> UAs { get; set; } = new ObservableCollection<string>
{
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 PrivaBrowser-iOS/0.75 Version/75 Safari/605.1.15",
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/105.0.5195.98 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/99.0.4844.47 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Linux; Android............like Gecko) Chrome/92.0.4515.105 HuaweiBrowser/12.1.2.311 Mobile Safari/537.36",
"jdapp;iPhone;11.2.6;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.2.5;;;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
"jdapp;android;11.2.4;;;Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;android;11.2.2;;;Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;iPhone;11.2.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.1.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.1.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.1.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.0.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.0.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.0.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.2.8;;;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;android;11.2.6;;;Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36",
"jdapp;iPhone;11.2.5;;;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79",
"jdapp;android;11.2.4;;;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;android;11.2.2;;;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;android;11.2.0;;;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36",
"jdapp;android;11.1.4;;;Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;android;11.1.2;;;Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;android;11.1.0;;;Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;iPhone;11.0.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.0.2;;;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;iPhone;11.0.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;10.5.0;;;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
"jdapp;android;11.2.8;;;Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
"jdapp;iPhone;11.2.5;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.2.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.2.2;;;Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36",
"jdapp;android;11.2.0;;;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
"jdapp;iPhone;11.1.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.0.1;;;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;iPhone;11.1.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.1.0;;;Mozilla/5.0 (Linux; Android 10; Mi Note 5 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
"jdapp;android;11.0.4;;;Mozilla/5.0 (Linux; Android 11; LIO-AN00 Build/HUAWEILIO-AN00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;android;11.0.2;;;Mozilla/5.0 (Linux; Android 10; SKW-A0 Build/SKYW2001202CN00MQ0; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;iPhone;11.0.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;10.5.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.2.8;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.2.5;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.2.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.2.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.2.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.1.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.1.2;;;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;android;11.1.0;;;Mozilla/5.0 (Linux; Android 12; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36",
"jdapp;iPhone;11.0.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79",
"jdapp;android;11.0.2;;;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;android;11.0.0;;;Mozilla/5.0 (Linux; Android 12; HWI-AL00 Build/HUAWEIHWI-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;android;10.5.4;;;Mozilla/5.0 (Linux; Android 10; ANE-AL00 Build/HUAWEIANE-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36",
"jdapp;android;10.5.2;;;Mozilla/5.0 (Linux; Android 9; ELE-AL00 Build/HUAWEIELE-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;android;10.5.0;;;Mozilla/5.0 (Linux; Android 10; LIO-AL00 Build/HUAWEILIO-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;android;11.2.8;;;Mozilla/5.0 (Linux; Android 10; SM-G9750 Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
"jdapp;iPhone;11.2.5;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.2.4;;;Mozilla/5.0 (Linux; Android 12; EVR-AL00 Build/HUAWEIEVR-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
"jdapp;iPhone;11.2.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.2.0;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.1.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.1.2;;;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
"jdapp;android;11.1.0;;;Mozilla/5.0 (Linux; Android 9; HLK-AL00 Build/HONORHLK-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
"jdapp;iPhone;11.0.4;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;iPhone;11.0.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
"jdapp;android;11.0.0;;;Mozilla/5.0 (Linux; Android 10; LYA-AL10 Build/HUAWEILYA-AL10; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36",
"jdapp;android;10.5.4;;;Mozilla/5.0 (Linux; Android 10; MI 9 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
"jdapp;iPhone;10.5.2;;;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"
};
public string DefaultUA
{
get
{
if (string.IsNullOrEmpty(_defaultUa))
{
_defaultUa = UAs.FirstOrDefault();
}
return _defaultUa;
}
set
{
_defaultUa = value;
RaisePropertyChanged();
JdService.ClientUserAgent = value;
File.WriteAllText("ua.txt", value);
if (MessageBox.Show("已切换新的UserAgent,是否重启?", "确认", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
{
var fileName = Assembly.GetExecutingAssembly().Location;
Process.Start(fileName.Replace("dll", "exe"));
Dispatcher.Invoke((ThreadStart)delegate { Application.Current.Shutdown(); }
);
}
}
}
public MyCommand SaveCommand
{
get { return new MyCommand(() => { IsSimpleMode = Visibility.Visible; }); }
}
public event PropertyChangedEventHandler PropertyChanged;
public void SetJsBox(string s)
{
Application.Current.Dispatcher.Invoke(() => { JsBox.Text = s; })
;
}
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
JumpToLoginPage();
}
private async void TryGetUserInputPhone(object sender, KeyEventArgs e)
{
var script = "function get_phone(){\r\n" +
"return document.querySelector('#app>div>div:nth-child(3)>p:nth-child(1)>input').value;\r\n" +
"}\r\n" +
"get_phone();";
await Browser.EvaluateScriptAsync(script).ContinueWith(respA =>
{
var resp = respA.Result; //respObj此时有两个属性: name、age
Phone = (string)resp.Result;
});
}
private async void JumpToLoginPage()
{
var title = "";
Browser.Dispatcher.Invoke(() => { title = Browser.Title; });
Trace.WriteLine(title);
if (title == "多快好省,购物逛京东!"|| title == "多快好省,购物上京东!")
{
var script = "document.querySelector('#msShortcutLogin').click()";
await Browser.EvaluateScriptAsync(script).ContinueWith(respA =>
{
var resp = respA.Result; //respObj此时有两个属性: name、age
Trace.WriteLine((string)resp.Result);
});
}
}
private void Browser_TitleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (CookieManager == null)
{
CookieManager = Browser.WebBrowser.GetCookieManager();
}
if (LoginMode.IsChecked != true) return;
if (!GetBrowserCk()) return;
ClearBrowserCk();
JumpToLoginPage();
}
private bool GetBrowserCk()
{
var result = false;
Browser.Dispatcher.Invoke(() =>
{
var ckList = GetJingdongCk();
var ckString = ckList.ToCkString();
if (ckString.Contains("pt_key") && ckString.Contains("pt_pin"))
{
try
{
Clipboard.SetText(ckString);
}
catch (Exception exception)
{
Console.WriteLine(exception);
File.AppendAllText("cookies.log", DateTime.Now + ":" + ckString);
if (MessageOn.IsChecked != true)
{
MessageBox.Show(this,
"复制到剪切板失败,(远程桌面下会出这个问题或重启电脑可能就好了),已经ck写入cookies.txt中,开始尝试上传.错误信息" + exception.Message);
}
}
var encodedContent = HttpUtility.UrlEncode(ckString);
Console.WriteLine(encodedContent);
SendToEmail(encodedContent);
var ptPin = QingLongJdCookie.Parse(ckString).ptPin;
var user = FindOrAddUser(ptPin);
user.Cookies = ckList.ToArray();
if (!string.IsNullOrWhiteSpace(Phone) && Helper.IsPhoneNumber(Phone))
{
user.Phone = Phone;
}
UploadToServer(ckString);
QingLongService.UploadToQingLong(ckString, Phone, this.MessageOn.IsChecked);
result = true;
}
else
{
result = false;
}
});
return result;
}
private void ClearBrowserCk()
{
CookieManager.DeleteCookies(".jd.com", "pt_key");
CookieManager.DeleteCookies(".jd.com", "pt_pin");
Browser.Address = "m.jd.com";
Phone = "";
}
private List<Cookie> GetJingdongCk()
{
var visitor = new TaskCookieVisitor();
CookieManager.VisitAllCookies(visitor);
var cks = visitor.Task.Result;
return cks.Where(cookie => cookie.Name == "pt_key" || cookie.Name == "pt_pin" || cookie.Name == "exp")
.ToList();
}
private User FindOrAddUser(string ptPin)
{
var now = DateTime.Now;
//todo:检测中英文问题.
var user = UserList.FirstOrDefault(u => u.Pin == ptPin
|| HttpUtility.UrlEncode(u.Pin) == ptPin
|| u.Pin == HttpUtility.UrlEncode(ptPin));
if (user == null)
{
user = new User(Phone, now.AddDays(29));
UserList.Add(user);
}
return user;
}
private async void WritePhone(string phone)
{
try
{
var script = "if (!document.querySelector(`#app > div > p.policy_tip > input`).checked) {\r\n" +
" \r\n" +
" var xresult = document.evaluate(`//*[@id='app']/div/div[3]/p[1]/input`, document, null, XPathResult.ANY_TYPE, null);" +
$" var p=xresult.iterateNext();p.value=`{phone}`;" +
" p.dispatchEvent(new Event('input'));\r\n }";
var result = await Browser.EvaluateScriptAsPromiseAsync(script);
}
catch (Exception e)
{
LogLabel.Content = e.Message;
}
finally
{
TextBox.Clear();
}
}
private bool WriteCaptcha(string captcha)
{
try
{
Browser.EvaluateScriptAsPromiseAsync(
$"var xresult = document.evaluate(`//*[@id=\"authcode\"]`, document, null, XPathResult.ANY_TYPE, null);var p=xresult.iterateNext();p.value=\"{captcha}\";p.dispatchEvent(new Event('input'));");
return true;
}
catch (Exception e)
{
LogLabel.Content = e.Message;
return false;
}
finally
{
TextBox.Clear();
}
}
private async Task<bool> ClickLoginButton()
{
try
{
Thread.Sleep(500);
var result = await Browser.EvaluateScriptAsync(
" var xresult = document.evaluate(`//*[@id=\"app\"]/div/a[1]`, document, null, XPathResult.ANY_TYPE, null);var p=xresult.iterateNext();p.click();");
return result.Success;
}
catch (Exception e)
{
LogLabel.Content = e.Message;
return false;
}
}
private void SendToEmail(string msg)
{
var email = ConfigurationManager.AppSettings["Email"];
var emailPassword = ConfigurationManager.AppSettings["EmailPassword"];
var emailHost = ConfigurationManager.AppSettings["EmailHost"];
if (string.IsNullOrEmpty(emailHost) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(emailPassword))
{
return;
}
//实例化一个发送邮件类。
var mailMessage = new MailMessage();
//发件人邮箱地址,方法重载不同,可以根据需求自行选择。
mailMessage.From = new MailAddress(email);
//收件人邮箱地址。
mailMessage.To.Add(new MailAddress(email));
//抄送人邮箱地址。
//message.CC.Add(sender);
//邮件标题。
mailMessage.Subject = "JdLogin";
//邮件内容。
mailMessage.Body = msg;
//是否支持内容为HTML。
//mailMessage.IsBodyHtml = true;
//实例化一个SmtpClient类。
var client = new SmtpClient();
client.Port = 587;
//在这里使用的是qq邮箱,所以是smtp.qq.com,如果你使用的是126邮箱,那么就是smtp.126.com。
//client.Host = "smtp.163.com";
client.Host = emailHost;
//使用安全加密连接(是否启用SSL)
client.EnableSsl = true;
//设置超时时间
//client.Timeout = 10000;
//不和请求一块发送。
client.UseDefaultCredentials = false;
//验证发件人身份(发件人的邮箱,邮箱里的生成授权码);
client.Credentials = new NetworkCredential(email, emailPassword); //szcodirtgvjgbfii
//网易邮箱客户端授权码DJURBEKTXEWXQATX
//client.Credentials = new NetworkCredential("liulijun3236@163.com", "ZAJDNCKWHUBHQIMY");
try
{
//发送
client.Send(mailMessage);
//发送成功
}
catch (Exception e) //发送异常
{
LogLabel.Content = e.Message;
}
}
private void UploadToServer(string ck)
{
var upload = ConfigurationManager.AppSettings["upload"] == "true";
var ckServer = ConfigurationManager.AppSettings["server"];
if (upload && !string.IsNullOrWhiteSpace(ckServer))
{
var method = ConfigurationManager.AppSettings["method"];
try
{
var client = new RestClient(ckServer + ck)
{
Timeout = 1000
};
var request = new RestRequest(method == "post" ? Method.POST : Method.GET);
var response = client.Execute(request);
Console.WriteLine(response.Content);
if (MessageOn.IsChecked == true)
{
}
else
{
MessageBox.Show(this, ck, "Cookie已上传服务器");
}
}
catch (Exception e)
{
MessageBox.Show(this, e.Message);
}
}
}
private void Browser_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
}
private void Browser_OnMouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
}
private void ButtonSetPhone_OnClick(object sender, RoutedEventArgs e)
{
Phone = Clipboard.GetText();
Clipboard.Clear();
if (!Helper.IsPhoneNumber(Phone))
{
Phone = TextBox.Text;
}
if (Helper.IsPhoneNumber(Phone))
{
WritePhone(Phone);
try
{
Browser.EvaluateScriptAsync(
" var xresult = document.querySelector(\"#app > div > p.policy_tip > input\").click();");
Thread.Sleep(500);
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
ClickGetCaptchaButton();
}
else
{
WritePhone("");
}
}
private bool ClickGetCaptchaButton()
{
try
{
var result = Browser.EvaluateScriptAsync("document.querySelector('#app div button').click()");
return result.Result.Success;
}
catch (Exception e)
{
LogLabel.Content = e.Message;
return false;
}
}
private async void ButtonSetCaptcha_OnClick(object sender, RoutedEventArgs e)
{
var captcha = Clipboard.GetText();
Clipboard.Clear();
if (!Helper.IsCaptcha(captcha))
{
captcha = TextBox.Text;
}
if (Helper.IsCaptcha(captcha))
{
WriteCaptcha(captcha);
await ClickLoginButton();
}
}
private async void ButtonHandleId_OnClick(object sender, RoutedEventArgs e)
{
if (UserList.FirstOrDefault(u => u.Phone == Phone) is { } user)
{
try
{
var id_2d_clip = Clipboard.GetText();
if (string.IsNullOrEmpty(user.Id2_4) &&
(!string.IsNullOrEmpty(TextBox.Text) || !string.IsNullOrEmpty(id_2d_clip)))
{
user.Id2_4 = string.IsNullOrEmpty(TextBox.Text) ? id_2d_clip : TextBox.Text;
}
if (string.IsNullOrEmpty(user.Id2_4))
{
return;
}
if (user.Id2_4.Length == 6)
{
user.Id2_4 = user.Id2_4.Insert(2, " ");
}
for (var i = 0; i < user.Id2_4.Length; i++)
{
var js =
$"document.querySelector(\"#app > div > div.wrap > div.input-box > div > div:nth-child({1 + i})\").innerText = {user.Id2_4[i]}";
var r = await Browser.EvaluateScriptAsPromiseAsync(js);
Console.WriteLine($"{r.Message}");
if (i == 1)
{
i++;
}
}
}
catch (Exception exception)
{
if (MessageOn.IsChecked == true)
{
}
else
{
MessageBox.Show(exception.Message);
}
}
//todo:sendkey
}
//todo:获取本次登陆手机号的缓存(或textbox输入内容解析)的身份证信息,然后自动点击验证身份证,自动输入,自动执行
}
private bool WriteUserId2_4(string id2_4)
{
try
{
Browser.EvaluateScriptAsPromiseAsync(
$"var xresult = document.evaluate(`//*[@id=\"authcode\"]`, document, null, XPathResult.ANY_TYPE, null);var p=xresult.iterateNext();p.value=\"{id2_4}\";p.dispatchEvent(new Event('input'));");
if (UserList.FirstOrDefault(u => u.Phone == Phone) is User user)
{
user.Id2_4 = id2_4;
}
// UserList.Add(new User(phone, DateTime.Now,ck) { Id2_4 = id2_4 });
return true;
}
catch (Exception e)
{
LogLabel.Content = e.Message;
return false;
}
finally
{
TextBox.Clear();
}
}
private void ButtonBrowSource_OnClick(object sender, RoutedEventArgs e)
{
Browser.ViewSource();
}
protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private async void ButtonSetCK_OnClick(object sender, RoutedEventArgs e)
{
//todo:判定ck合法性,设置到浏览器
var ck = Clipboard.GetText();
if (!Helper.IsCk(ck))
{
ck = TextBox.Text;
}
if (Helper.IsCk(ck))
{
await SetBrowserCk(ck);
//GetBrowserCk();
}
else
{
WritePhone("");
}
}
private async Task SetBrowserCk(string ck)
{
var cookie = QingLongJdCookie.Parse(ck);
await CookieManager.SetCookieAsync("https://m.jd.com/", new Cookie
{
Domain = ".jd.com",
Name = "pt_pin",
Value = cookie.ptPin
});
await CookieManager.SetCookieAsync("https://m.jd.com/", new Cookie
{
Domain = ".jd.com",
Name = "pt_key",
Value = cookie.ptKey
});
Browser.ReloadCommand.Execute(null);
}
private void ButtonReadAllCK_OnClick(object sender, RoutedEventArgs e)
{
ReadAllCK();
}
private void ReadAllCK()
{
try
{
if (!File.Exists(CookiePath))
{
File.Create(CookiePath);
}
CookieStringList = File.ReadAllLines(CookiePath).ToList();
CkIndex = 0;
if (string.IsNullOrWhiteSpace(JsBox.Text))
{
JsBox.Text =
"var btn=document.evaluate('id(\"vueContainer\")/div[@class=\"coupon - btns\"]/div[@class=\"btn\"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;btn.click();";
}
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
private void AutoLoopRun()
{
if (IsRunning)
{
return;
}
Task.Factory.StartNew(async () =>
{
IsRunning = true;
while (CkIndex < CookieStringList.Count && !stop)
{
try
{
var ck = "";
var js = "";
var url = "";
Application.Current.Dispatcher.Invoke(() =>
{
TextBox.Text = CookieStringList[CkIndex++];
ck = TextBox.Text;
js = JsBox.Text;
url = UrlBox.Text;
});
await DoAction(ck, js, url);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
IsRunning = false;
});
}
public static string GetElement()
{
return "";
//todo:加载事件绑定(附加条件),监听鼠标右键也行,执行js获取鼠标位置的element(tostring)就是xpath,注入根据xpath获取element代码,
}
private async Task DoAction(string ck, string js, string url)
{
try
{
if (Helper.IsCk(ck))
{
await SetBrowserCk(ck);
Browser.Load(url);
Thread.Sleep(1000 * 3);
if (!string.IsNullOrWhiteSpace(js))
{
await Task.Factory.StartNew(() =>
{
while (!stop && !EvaluateScript(js))
{
Thread.Sleep(1000 * 2);
if (stop)
{
break;
}
}
Thread.Sleep(1000 * 2);
});
}
}
else
{
WritePhone("");
}
}
catch (Exception exception)
{
if (MessageOn.IsChecked == true)
{
}
else
{
MessageBox.Show(exception.Message);
}
}
}
private void ButtonGoToUrl_OnClick(object sender, RoutedEventArgs e)
{
Browser.Address = UrlBox.Text;
}
private void ButtonDevTools_OnClick(object sender, RoutedEventArgs e)
{
Browser.ShowDevTools();
}
private void DataGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LoginMode.IsChecked == true)
{
var phone = ((sender as DataGrid)?.SelectedItem as User)?.Phone;
if (!string.IsNullOrWhiteSpace(phone))
{
TextBox.Text = ((sender as DataGrid).SelectedItem as User).Phone;
}
var userAgent = ((sender as DataGrid)?.SelectedItem as User)?.UserAgent;
if (!string.IsNullOrWhiteSpace(userAgent) && DefaultUA != userAgent)
{
DefaultUA = userAgent;
}
}
}
private void ButtonCheckAllLogin_OnClick(object sender, RoutedEventArgs e)
{
var b = sender as Button;
b.IsEnabled = false;
Task.Factory.StartNew(() =>
{
foreach (var user in UserList)
{
Dispatcher.Invoke(() =>
{
LogLabel.Content = $"{user.NickName}-{UserList.IndexOf(user)}/{UserList.Count}";
});
CheckAndUpdateUserState(user);
}
Dispatcher.Invoke(() =>
{
LogLabel.Content = "执行完成";
b.IsEnabled = true;
});
});
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
var tb = sender as ToggleButton;
if (tb.IsChecked == true)
{
Width = 1405;
}
else
{
Width = 405;
}
}
public void ButtonCheckLogin_OnClick(object sender, RoutedEventArgs e)
{
var user = DataGrid.SelectedItem as User;
LogLabel.Content = $"{user.NickName}";
CheckAndUpdateUserState(user);
}
private static void CheckAndUpdateUserState(User user)
{
var re = JdService.GetUserInfo(user.CookieString);
if (re.msg == "success" && re.retcode == "0")
{
user.UserInfoData = re;
user.IsLogin = true;
if (user.AddressList == null || !user.AddressList.Any())
{
user.AddressList = JdService.GetAddressList(user.CookieString);
}
}
else
{
user.IsLogin = false;
}
}
private bool EvaluateScript(string js)
{
try
{
var r = Application.Current.Dispatcher.Invoke(() =>
{
try
{
var javascriptResponse = Browser.EvaluateScriptAsync(js, new TimeSpan(0, 0, 1)).Result;
Console.WriteLine(javascriptResponse.Message);
return javascriptResponse.Success;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return true;
}
});
return r;
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
private void ButtonExecuteJS_OnClick(object sender, RoutedEventArgs e)
{