-
Notifications
You must be signed in to change notification settings - Fork 326
/
OrangeJs_种豆得豆自动脚本.js
1525 lines (1485 loc) · 107 KB
/
OrangeJs_种豆得豆自动脚本.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
context_thisScriptName = "种豆得豆自动脚本";
context_thisScriptVersion = "(Beta1.24)";
ScriptMENU();
function ScriptMENU() {
ui.run(() => {
let view = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<card gravity="center_vertical" cardElevation="0dp" cardBackgroundColor="{{context_framebg}}" margin="0 10">
<img src="{{context_Logo}}" w="100" h="35"/>
<linear gravity="center||right">
<img id="ExitScript" src="@drawable/ic_clear_black_48dp" w="35" h="35" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true"/>
</linear>
</card>
<text text="{{context_thisScriptName+context_thisScriptVersion}}" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 0 0 0"/>
<linear orientation="horizontal" align="left" margin="0" paddingTop="0">
<card id="StartRunning" layout_weight="50" h="50"cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 5 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<vertical gravity="center">
<img src="@drawable/ic_play_arrow_black_48dp" h="30" tint="{{context_textColor}}" marginTop="5"/>
<text text="开始运行" textStyle="bold" textColor="{{context_textColor}}" textSize="8sp" gravity="center" paddingBottom="5"/>
</vertical>
</card>
<card id="WaitForRun" layout_weight="50" h="50" cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 0 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<vertical gravity="center">
<img src="@drawable/ic_build_black_48dp" h="20" tint="{{context_textColor}}" margin="0 10 0 5"/>
<text text="手动运行" textStyle="bold" textColor="{{context_textColor}}" gravity="center" textSize="8sp" paddingBottom="5"/>
</vertical>
</card>
<card id="ScriptSetting" layout_weight="50" h="50" cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<vertical gravity="center">
<img src="@drawable/ic_settings_black_48dp" h="20" tint="{{context_textColor}}" margin="0 10 0 5"/>
<text text="脚本设置" textStyle="bold" textColor="{{context_textColor}}" gravity="center" textSize="8sp" paddingBottom="5"/>
</vertical>
</card>
</linear>
</vertical>, null, false);
let DHK = dialogs.build({
customView: view,
wrapInScrollView: false,
autoDismiss: false,
cancelable: false
}).show();
view.StartRunning.click(() => {
DHK.dismiss();
threads.start(function() {
StopScriptWindowOn();
FloatJournal();
openInTask();
DoTask();
});
});
view.WaitForRun.click(() => {
DHK.dismiss();
ShouDong();
});
view.ScriptSetting.click(() => {
if (files.listDir("/sdcard").length != 0) {
DHK.dismiss();
ScriptSettings();
} else {
let view = ui.inflate(
<vertical bg="{{context_framebg}}" padding="25 0 25 0">
<img src="@drawable/ic_warning_black_48dp" h="35" tint="{{context_textColor}}" margin="5"/>
<text text="未授予本软件“存储权限”,无法更改脚本配置" textSize="15" textStyle="bold" textColor="{{context_textColor}}" gravity="center" margin="5"/>
</vertical>
);
dialogs.build({
customView: view,
wrapInScrollView: false,
autoDismiss: true
}).show();
}
});
view.ExitScript.longClick(() => {
toast("关闭脚本");
});
view.ExitScript.click(() => {
DHK.dismiss();
exit();
});
});
}
function ShouDong() {
ui.run(() => {
let view = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<card gravity="center_vertical" cardElevation="0dp" cardBackgroundColor="{{context_framebg}}" margin="0 10 0 5">
<img src="{{context_Logo}}" w="100" h="35"/>
<linear gravity="center||right">
<img id="ExitScript" src="@drawable/ic_clear_black_48dp" w="35" h="35" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true"/>
<linear gravity="center||right">
<img id="GoBack" src="@drawable/ic_chevron_left_black_48dp" w="40" h="40" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true"/>
</linear>
</linear>
</card>
<text text="{{context_thisScriptName+context_thisScriptVersion}}" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 0 0 0"/>
<card gravity="center_vertical" cardElevation="0dp" cardBackgroundColor="{{context_framebg}}">
<text text="手动运行" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 0 0 0"/>
<linear gravity="center||right">
<img id="Question" src="@drawable/ic_help_outline_black_48dp" w="20sp" h="20sp" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" marginRight="25"/>
</linear>
</card>
<text text="请选择脚本等待您打开活动页面的时间" textSize="10sp" textColor="{{context_textColor}}" gravity="left" margin="0 0 0 0"/>
<linear orientation="horizontal" align="left" margin="0" paddingTop="0">
<card id="Waiting10s" layout_weight="50" h="40"cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 5 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<text text="10s" textStyle="bold" textColor="{{context_textColor}}" textSize="15sp" gravity="center" paddingBottom="5"/>
</card>
<card id="Waiting20s" layout_weight="50" h="40" cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 0 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<text text="20s" textStyle="bold" textColor="{{context_textColor}}" textSize="15sp" gravity="center" paddingBottom="5"/>
</card>
<card id="Waiting30s" layout_weight="50" h="40" cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="5 5 0 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<text text="30s" textStyle="bold" textColor="{{context_textColor}}" textSize="15sp" gravity="center" paddingBottom="5"/>
</card>
<card id="Waiting50s" layout_weight="50" h="40" cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<text text="50s" textStyle="bold" textColor="{{context_textColor}}" textSize="15sp" gravity="center" paddingBottom="5"/>
</card>
</linear>
</vertical>, null, false);
let DHK = dialogs.build({
customView: view,
wrapInScrollView: false,
autoDismiss: false,
cancelable: false
}).show();
view.Question.longClick(() => {
toast("帮助");
});
view.Question.click(() => {
let answer = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_help_outline_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text text="要进行“手动运行”,您需要选择一个时间另脚本进入等待状态,并在脚本等待期间自行打开京东APP至活动页,脚本等待时间结束后则会开始运行" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 5"/>
<text text="所谓“手动运行”,仅需要您自行手动打开至活动页。若您直接点击“开始运行”后,脚本无法为您自动打开至活动页面,则您才需要尝试“手动运行”。" textSize="10sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 5"/>
</vertical>, null, false);
dialogs.build({
customView: answer,
wrapInScrollView: false,
autoDismiss: false
}).show();
});
view.ExitScript.longClick(() => {
toast("关闭脚本");
});
view.GoBack.longClick(() => {
toast("返回上一级");
});
view.GoBack.click(() => {
DHK.dismiss();
ScriptMENU();
});
view.ExitScript.click(() => {
DHK.dismiss();
exit();
});
view.Waiting10s.click(() => {
DHK.dismiss();
threads.start(function() {
StopScriptWindowOn();
FloatJournal();
for (let deng = 10; deng > 0; deng--) {
toastLog("请打开京东至种豆得豆的主界面\n剩余" + deng + "秒后运行脚本...");
sleep(1000);
}
DoTask();
});
});
view.Waiting20s.click(() => {
DHK.dismiss();
threads.start(function() {
StopScriptWindowOn();
FloatJournal();
for (let deng = 20; deng > 0; deng--) {
toastLog("请打开京东至种豆得豆的主界面\n剩余" + deng + "秒后运行脚本...");
sleep(1000);
}
DoTask();
});
});
view.Waiting30s.click(() => {
DHK.dismiss();
threads.start(function() {
StopScriptWindowOn();
FloatJournal();
for (let deng = 30; deng > 0; deng--) {
toastLog("请打开京东至种豆得豆的主界面\n剩余" + deng + "秒后运行脚本...");
sleep(1000);
}
DoTask();
});
});
view.Waiting50s.click(() => {
DHK.dismiss();
threads.start(function() {
StopScriptWindowOn();
FloatJournal();
for (let deng = 50; deng > 0; deng--) {
toastLog("请打开京东至种豆得豆的主界面\n剩余" + deng + "秒后运行脚本...");
sleep(1000);
}
DoTask();
});
});
});
}
function ScriptSettings() {
ui.run(() => {
let view = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<card gravity="center_vertical" cardElevation="0dp" cardBackgroundColor="{{context_framebg}}" margin="0 10 0 5">
<img src="{{context_Logo}}" w="100" h="35"/>
<linear gravity="center||right">
<img id="ExitScript" src="@drawable/ic_clear_black_48dp" w="35" h="35" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true"/>
<linear gravity="center||right">
<img id="GoBack" src="@drawable/ic_chevron_left_black_48dp" w="40" h="40" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true"/>
</linear>
</linear>
</card>
<text text="{{context_thisScriptName+context_thisScriptVersion}}" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 0 0 0"/>
<text text="脚本设置" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 0 0 0"/>
<card id="UseRootBack" h="40" cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 5 5"cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<linear orientation="horizontal" gravity="center||left">
<img src="@drawable/ic_wrap_text_black_48dp" w="20" h="20" circle="true" tint="{{context_textColor}}" margin="10 5"/>
<linear orientation="vertical" gravity="center">
<text text="使用Root权限进行返回操作" textColor="{{context_textColor}}" textStyle="bold" textSize="12sp"/>
</linear>
</linear>
<linear gravity="center||right" marginRight="10">
<text id="UseRootBackText" textStyle="bold" textSize="12sp"/>
</linear>
</card>
<card id="ToastOrFloatjournal" layout_weight="50" h="40"cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 5 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<linear orientation="horizontal" align="left" margin="0" paddingTop="0">
<img src="@drawable/ic_chat_black_48dp" w="20" h="20" tint="{{context_textColor}}" layout_gravity="left||center" margin="10 5"/>
<text text="“吐司(Toast)”/“悬浮日志”切换" textStyle="bold" textColor="{{context_textColor}}" textSize="12sp"layout_gravity="left||center"/>
</linear>
</card>
</vertical>, null, false);
function Setstate() {
if (files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt") == "true") {
view.UseRootBackText.setText("已开启");
view.UseRootBackText.setTextColor(colors.parseColor("#FF1E56"));
RootBack = true;
} else if (files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt") == "false") {
view.UseRootBackText.setText("已关闭");
view.UseRootBackText.setTextColor(colors.parseColor("#17B978"));
RootBack = false;
}
}
Setstate();
let DHK = dialogs.build({
customView: view,
wrapInScrollView: false,
autoDismiss: false,
cancelable: false
}).show();
view.UseRootBack.click(() => {
if (RootBack == true) {
files.write("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt", "false");
} else {
files.write("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt", "true");
}
Setstate();
});
view.ToastOrFloatjournal.click(() => {
let answer = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_chat_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text id="WhatNow" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
<text text="请选择您要切换的方式" textSize="10sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 5"/>
<linear orientation="horizontal" align="left" margin="0" paddingTop="0">
<card id="UseToast" layout_weight="50" h="50"cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 5 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<vertical gravity="center">
<img src="@drawable/ic_speaker_notes_black_48dp" h="20" tint="{{context_textColor}}" margin="0 10 0 5"/>
<text text="吐司(Toast)" textStyle="bold" textColor="{{context_textColor}}" textSize="8sp" gravity="center" paddingBottom="5"/>
</vertical>
</card>
<card id="UseFloatjournal" layout_weight="50" h="50" cardCornerRadius="5dp" cardElevation="0dp" gravity="center_vertical" margin="0 5 0 5" cardBackgroundColor="{{context_SettingsCard}}" foreground="?attr/selectableItemBackground" clickable="true">
<vertical gravity="center">
<img src="@drawable/ic_assignment_black_48dp" h="20" tint="{{context_textColor}}" margin="0 10 0 5"/>
<text text="悬浮日志" textStyle="bold" textColor="{{context_textColor}}" gravity="center" textSize="8sp" paddingBottom="5"/>
</vertical>
</card>
</linear>
</vertical>, null, false);
if (files.exists("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt") == true) {
if (files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt") == "日志") {
answer.WhatNow.setText("当前脚本使用:悬浮日志");
} else if (files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt") == "吐司") {
answer.WhatNow.setText("当前脚本使用:吐司(Toast)");
}
}
answer.UseToast.click(() => {
files.createWithDirs("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt");
if (files.exists("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt") == true) {
try {
files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt");
files.write("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt", "吐司");
DHKs.dismiss();
let answerT = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_check_circle_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text id="tipR" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
<text id="Ttips" textSize="10sp" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
</vertical>, null, false);
answerT.tipR.setText("已成功切换为“吐司(Toast)”\n重新运行脚本即可生效");
dialogs.build({
customView: answerT,
wrapInScrollView: false,
autoDismiss: false
}).show();
} catch (e) {
log(e);
DHKs.dismiss();
let answerT = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_warning_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text text="存储权限异常,切换为“吐司(Toast)”失败!" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
<text id="Ttips" textSize="10sp" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
</vertical>, null, false);
answerT.Ttips.setText("由于脚本需要将脚本设置文件保存至您的设备中,因此请您授予本软件“存储权限”以保障软件正常运行\n" + e);
dialogs.build({
customView: answerT,
wrapInScrollView: false,
autoDismiss: false
}).show();
}
} else {
let answerT = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_warning_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text text="存储权限异常,切换为“吐司(Toast)”失败!" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
<text id="Ttips" textSize="10sp" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
</vertical>, null, false);
answerT.Ttips.setText("由于脚本需要将脚本设置文件保存至您的设备中,因此请您授予本软件“存储权限”以保障软件正常运行");
dialogs.build({
customView: answerT,
wrapInScrollView: false,
autoDismiss: false
}).show();
}
});
answer.UseFloatjournal.click(() => {
files.createWithDirs("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt");
if (files.exists("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt") == true) {
try {
files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt");
files.write("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt", "日志");
DHKs.dismiss();
let answerT = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_check_circle_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text id="tipR" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
<text id="Ttips" textSize="10sp" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
</vertical>, null, false);
answerT.tipR.setText("已成功切换为“悬浮日志”\n重新运行脚本即可生效");
dialogs.build({
customView: answerT,
wrapInScrollView: false,
autoDismiss: false
}).show();
} catch (e) {
log(e);
DHKs.dismiss();
let answerT = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_warning_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text text="存储权限异常,切换为“悬浮日志”失败!" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
<text id="Ttips" textSize="10sp" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
</vertical>, null, false);
answerT.Ttips.setText("由于脚本需要将脚本设置文件保存至您的设备中,因此请您授予本软件“存储权限”以保障软件正常运行\n" + e);
dialogs.build({
customView: answerT,
wrapInScrollView: false,
autoDismiss: false
}).show();
}
} else {
let answerT = ui.inflate(
<vertical bg="{{context_framebg}}" padding="35 0 35 0">
<img src="@drawable/ic_warning_black_48dp" w="25" h="25" tint="{{context_textColor}}" foreground="?attr/selectableItemBackground" clickable="true" margin="0 5"/>
<text text="存储权限异常,切换为“悬浮日志”失败!" textSize="15sp" textStyle="bold" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
<text id="Ttips" textSize="10sp" textColor="{{context_textColor}}" gravity="left" margin="0 2"/>
</vertical>, null, false);
answerT.Ttips.setText("由于脚本需要将脚本设置文件保存至您的设备中,因此请您授予本软件“存储权限”以保障软件正常运行");
dialogs.build({
customView: answerT,
wrapInScrollView: false,
autoDismiss: false
}).show();
}
});
let DHKs = dialogs.build({
customView: answer,
wrapInScrollView: false,
autoDismiss: false
}).show();
});
view.ExitScript.longClick(() => {
toast("关闭脚本");
});
view.GoBack.longClick(() => {
toast("返回上一级");
});
view.GoBack.click(() => {
DHK.dismiss();
ScriptMENU();
});
view.ExitScript.click(() => {
DHK.dismiss();
exit();
});
});
}
function Justback() {
if (RootBack != true) {
toastLog("尝试使用“无障碍权限”进行返回")
back();
sleep(1000);
} else {
toastLog("尝试使用“ROOT权限”进行返回")
Back();
sleep(1000);
}
}
if (files.exists("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt") == true && files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/吐司or日志.txt") == "吐司") {
var ChangeToastLog = null;
} else {
var ChangeToastLog = true;
}
if (ChangeToastLog == true) {
function toastLog(message) {
log(message);
var myDate = new Date();
ui.run(() => {
context_FloatJournal.WZ.setText(myDate.getHours() + "时" + myDate.getMinutes() + "分" + myDate.getSeconds() + "秒:" + message + "\n" + context_FloatJournal.WZ.getText());
});
}
}
if (files.listDir("/sdcard/").length == 0) {
toastLog("未授予“存储权限”,使用默认配置");
RootBack = false;
} else {
if (files.exists("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt") == true) {
if (files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt") == "true") {
RootBack = true;
} else if (files.read("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt") == "false") {
RootBack = false;
} else {
toastLog("脚本配置文件错误,已尝试删除错误配置文件:(/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt)" + files.remove("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt"));
files.createWithDirs("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt");
files.write("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt", "false");
RootBack = false;
}
} else {
files.createWithDirs("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt");
files.write("/storage/emulated/0/OrangeJs/种豆得豆自动脚本/Root返回开关.txt", "false");
RootBack = false;
}
}
function StopScriptWindowOn() {
var window = floaty.window(
<frame>
<button id="action" text="点击停止脚本" w="120" h="40" bg="#F0EB4336"/>
</frame>
);
var execution = null;
var x = 0,
y = 0;
var windowX, windowY;
var downTime;
window.action.setOnTouchListener(function(view, event) {
switch (event.getAction()) {
case event.ACTION_DOWN:
x = event.getRawX();
y = event.getRawY();
windowX = window.getX();
windowY = window.getY();
downTime = new Date().getTime();
return true;
case event.ACTION_MOVE:
window.setPosition(windowX + (event.getRawX() - x),
windowY + (event.getRawY() - y));
if (new Date().getTime() - downTime > 1500) {
toast("长按可以移动位置哦~");
}
return true;
case event.ACTION_UP:
if (Math.abs(event.getRawY() - y) < 5 && Math.abs(event.getRawX() - x) < 5) {
onClick();
}
return true;
}
return true;
});
function onClick() {
floaty.closeAll();
threads.shutDownAll();
let view = ui.inflate(
<vertical bg="{{context_framebg}}" padding="25 0 25 0">
<img src="@drawable/ic_warning_black_48dp" h="35" tint="{{context_textColor}}" margin="5"/>
<text text="种豆得豆自动脚本:已为您停止运行" textSize="15" textStyle="bold" textColor="{{context_textColor}}" gravity="center" margin="5"/>
</vertical>
);
dialogs.build({
customView: view,
wrapInScrollView: false,
autoDismiss: true
}).show();
log("用户点击了停止按钮");
exit();
}
}
function FloatJournal() {
if (ChangeToastLog == true) {
context_FloatJournal = floaty.rawWindow(
<card bg="#80000000">
<vertical align="center">
<img src="{{getStorageData('APPbasic', 'URLprefix')}}/OrangeJs-logoWhite.png" h="30" margin="0 10 0 5"/>//黑色logo
<text text="─ 当前脚本运行日志 ─" textSize="15" color="#FFFFFF" textStyle="bold" gravity="center" margin="0 0 0 5"/>
<text id="WZ" text="" textSize="15" color="#FFFFFF" marginLeft="10" gravity="left"/>
</vertical>
</card>
);
context_FloatJournal.setSize(device.width, 500);
context_FloatJournal.setTouchable(false);
context_FloatJournal.setPosition(0, device.height - 500);
}
}
function openInTask() {
function closeJDLocationView() {
let jddwdhk = id("com.jingdong.app.mall:id/bn").text("为保证您正常地使用此功能,需要获取您的位置信息使用权限,请允许。").findOnce();
if (jddwdhk != null && jddwdhk.parent().parent().childCount() > 1 &&
jddwdhk.parent().parent().child(1).childCount() > 0) {
for (let i = 0; i < jddwdhk.parent().parent().child(1).childCount(); i++) {
if (jddwdhk.parent().parent().child(1).child(i).text() == "取消") {
if (jddwdhk.parent().parent().child(1).child(i).clickable() == true) {
jddwdhk.parent().parent().child(1).child(i).click();
toastLog("已尝试盲点“关闭京东位置权限授权框”");
sleep(2000);
} else {
let a = jddwdhk.parent().parent().child(1).child(i).bounds();
click(a.centerX(), a.centerY());
toastLog("已尝试点击“关闭京东位置权限授权框”");
sleep(2000);
}
}
}
}
}
while (true) {
closeJDLocationView();
function ClickRk() {
let a = className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/gm").findOnce();
if (className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/h4").findOnce() != null) {
var b = className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/h4").findOnce();
} else if (className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/h0").findOnce() != null) {
var b = className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/h0").findOnce();
} else if (className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/ha").findOnce() != null) {
var b = className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/ha").findOnce();
} else if (className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/he").findOnce() != null) {
var b = className("android.widget.LinearLayout").id("com.jd.lib.personal.feature:id/he").findOnce();
}
let yhA = selector().findOnce();
for (let v = 3; v >= 0; v--) {
if (b != null && b.childCount() > 0 &&
b.child(0).childCount() > 0 &&
b.child(0).child(0).childCount() > 3 &&
b.child(0).child(0).child(3).childCount() > 0 &&
b.child(0).child(0).child(3).child(0).scrollable() == true) {
let hd = b.child(0).child(0).child(3).child(0).scrollForward();
toastLog("已尝试左滑菜单控件:" + hd);
sleep(2000);
if (hd == false) {
toastLog("滑动停止");
break;
}
} else if (b != null && b.childCount() > 0 &&
b.child(0).childCount() > 0 &&
b.child(0).child(0).childCount() > 4 &&
b.child(0).child(0).child(4).childCount() > 0 &&
b.child(0).child(0).child(4).child(0).scrollable() == true) {
let hd = b.child(0).child(0).child(4).child(0).scrollForward();
toastLog("已尝试左滑菜单控件:" + hd);
sleep(2000);
if (hd == false) {
toastLog("滑动停止");
break;
}
}
}
if (a != null && a.childCount() > 0 &&
a.child(0).childCount() > 0 &&
a.child(0).child(0).childCount() > 3 &&
a.child(0).child(0).child(3).childCount() > 0 &&
a.child(0).child(0).child(3).child(0).childCount() > 0 &&
a.child(0).child(0).child(3).child(0).child(0).className() == "androidx.recyclerview.widget.RecyclerView" &&
a.child(0).child(0).child(3).child(0).child(0).childCount() > 5) {
for (let ii = 0; ii < a.child(0).child(0).child(3).child(0).childCount(); ii++) {
for (let i = 0; i < a.child(0).child(0).child(3).child(0).child(ii).childCount(); i++) {
if (a.child(0).child(0).child(3).child(0).child(ii).child(i).childCount() > 0 &&
a.child(0).child(0).child(3).child(0).child(ii).child(i).child(0).childCount() > 1 &&
a.child(0).child(0).child(3).child(0).child(ii).child(i).child(0).child(1).text() == "种豆得豆") {
return a.child(0).child(0).child(3).child(0).child(ii).child(i);
}
}
}
} else if (a != null && a.childCount() > 0 &&
a.child(0).childCount() > 0 &&
a.child(0).child(0).childCount() > 4 &&
a.child(0).child(0).child(4).childCount() > 0 &&
a.child(0).child(0).child(4).child(0).childCount() > 0 &&
a.child(0).child(0).child(4).child(0).child(0).className() == "androidx.recyclerview.widget.RecyclerView" &&
a.child(0).child(0).child(4).child(0).child(0).childCount() > 5) {
for (let ii = 0; ii < a.child(0).child(0).child(4).child(0).childCount(); ii++) {
for (let i = 0; i < a.child(0).child(0).child(4).child(0).child(ii).childCount(); i++) {
if (a.child(0).child(0).child(4).child(0).child(ii).child(i).childCount() > 0 &&
a.child(0).child(0).child(4).child(0).child(ii).child(i).child(0).childCount() > 1 &&
a.child(0).child(0).child(4).child(0).child(ii).child(i).child(0).child(1).text() == "种豆得豆") {
return a.child(0).child(0).child(4).child(0).child(ii).child(i);
}
}
}
} else if (b != null && b.childCount() > 0 &&
b.child(0).childCount() > 0 &&
b.child(0).child(0).childCount() > 4 &&
b.child(0).child(0).child(4).childCount() > 0 &&
b.child(0).child(0).child(4).child(0).childCount() > 0 &&
b.child(0).child(0).child(4).child(0).child(0).className() == "androidx.recyclerview.widget.RecyclerView" &&
b.child(0).child(0).child(4).child(0).child(0).childCount() > 5) {
for (let ii = 0; ii < b.child(0).child(0).child(4).child(0).childCount(); ii++) {
for (let i = 0; i < b.child(0).child(0).child(4).child(0).child(ii).childCount(); i++) {
if (b.child(0).child(0).child(4).child(0).child(ii).child(i).childCount() > 0 &&
b.child(0).child(0).child(4).child(0).child(ii).child(i).child(0).childCount() > 1 &&
b.child(0).child(0).child(4).child(0).child(ii).child(i).child(0).child(1).text() == "种豆得豆") {
return b.child(0).child(0).child(4).child(0).child(ii).child(i);
}
}
}
} else if (b != null && b.childCount() > 0 &&
b.child(0).childCount() > 0 &&
b.child(0).child(0).childCount() > 3 &&
b.child(0).child(0).child(3).childCount() > 0 &&
b.child(0).child(0).child(3).child(0).childCount() > 0 &&
b.child(0).child(0).child(3).child(0).child(0).className() == "androidx.recyclerview.widget.RecyclerView" &&
b.child(0).child(0).child(3).child(0).child(0).childCount() > 5) {
for (let ii = 0; ii < b.child(0).child(0).child(3).child(0).childCount(); ii++) {
for (let i = 0; i < b.child(0).child(0).child(3).child(0).child(ii).childCount(); i++) {
if (b.child(0).child(0).child(3).child(0).child(ii).child(i).childCount() > 0 &&
b.child(0).child(0).child(3).child(0).child(ii).child(i).child(0).childCount() > 1 &&
b.child(0).child(0).child(3).child(0).child(ii).child(i).child(0).child(1).text() == "种豆得豆") {
return b.child(0).child(0).child(3).child(0).child(ii).child(i);
}
}
}
} else if (yhA != null && yhA.childCount() > 0 &&
yhA.child(0).childCount() > 4 &&
yhA.child(0).child(4).childCount() > 0 &&
yhA.child(0).child(4).child(0).childCount() > 0 &&
yhA.child(0).child(4).child(0).child(0).childCount() > 1 &&
yhA.child(0).child(4).child(0).child(0).child(1).childCount() > 0 &&
yhA.child(0).child(4).child(0).child(0).child(1).child(0).text() == "种豆得豆") {
return yhA.child(0).child(4).child(0).child(0).child(1);
}
}
if (className("android.view.View").desc("我的").findOnce() != null && text("种豆得豆").className("android.widget.TextView").findOnce() != null && text("瓜分亿万京豆").className("android.widget.TextView").findOnce() != null) {
if (text("种豆得豆").className("android.widget.TextView").findOnce().parent().clickable() == true) {
text("种豆得豆").className("android.widget.TextView").findOnce().parent().click();
toastLog("已尝试盲点“种豆得豆”入口按钮");
sleep(3000);
} else {
let a = text("种豆得豆").className("android.widget.TextView").findOnce().parent().bounds();
click(a.centerX(), a.centerY());
toastLog("已尝试点击“种豆得豆”入口按钮");
sleep(3000);
}
break;
} else if (className("android.view.View").desc("我的").findOnce() != null && ClickRk() != undefined) {
let a = ClickRk();
if (a.clickable() == true) {
a.click();
toastLog("已尝试盲点“种豆得豆”入口按钮");
sleep(3000);
} else {
let aa = a.bounds();
click(aa.centerX(), aa.centerY());
toastLog("已尝试点击“种豆得豆”入口按钮");
sleep(3000);
}
break;
} else if (className("android.view.View").desc("我的").findOnce() != null) {
className("android.view.View").desc("我的").findOnce().click();
toastLog("已尝试点击京东主页“我的”按钮");
sleep(2000);
} else if (currentPackage() != "com.jingdong.app.mall") {
app.startActivity({
action: "android.intent.action.VIEW",
packageName: "com.jingdong.app.mall",
className: "com.jingdong.app.mall.main.MainActivity"
});
toastLog("当前未处于京东APP中,正在重新打开京东……");
console.warn("当前活动:" + currentActivity() + ",当前包名:" + currentPackage() + "当前应用名:" + getAppName(currentPackage()));
sleep(2000);
} else {
if (className("android.widget.ImageView").desc("返回").clickable(true).findOnce() != null) {
className("android.widget.ImageView").desc("返回").clickable(true).findOnce().click();
toastLog("已尝试点击“返回”按钮");
} else {
Justback();
}
sleep(2000);
}
}
for (var d = 10; d > 0; d--) {
if (MakeSureInHD() == true) {
sleep(3000);
break
} else {
toastLog("正在等待“种豆得豆”活动界面加载,剩余" + d + "秒……");
sleep(2000);
}
}
if (MakeSureInHD() == false) {
openInTask();
}
}
function MakeSureInHD() {
if (className("android.widget.TextView").text("收取营养液").findOnce() != null) {
return true;
} else {
return false;
}
}
function DoTask() {
if (id("com.jingdong.app.mall:id/aba").findOnce() != null &&
id("com.jingdong.app.mall:id/aba").findOnce().childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(0).childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(0).child(0).childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(0).child(0).child(0).childCount() > 0 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(0).child(0).child(0).child(0).childCount() == 2 &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(0).child(0).child(0).child(0).child(0).className() == "android.view.ViewGroup" &&
id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(0).child(0).child(0).child(0).child(1).className() == "android.widget.ImageView"
) {
let a = id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(0).child(0).child(0).child(0).child(1);
if (a.clickable() == true) {
a.click();
toastLog("已尝试盲点“收豆蒙版”按钮");
} else {
let b = a.bounds();
click(b.centerX(), b.centerY());
toastLog("已尝试点击“收豆蒙版”按钮");
}
sleep(3000);
if (className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce() != null && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().childCount() == 4 &&
className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(0).className() == "android.widget.TextView" && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(1).className() == "android.widget.TextView" && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(2).className() == "android.widget.TextView" && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(3).className() == "android.widget.TextView") {
toastLog(className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(0).text() + className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(1).text() + className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(2).text() + className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(3).text())
}
if (className("android.widget.TextView").text("收下京豆").findOnce() != null) {
let b = className("android.widget.TextView").text("收下京豆").findOnce().bounds();
click(b.centerX(), b.centerY());
sleep(3000);
}
} else if (className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce() != null &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).childCount() > 0 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).childCount() > 0 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).childCount() > 0 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).childCount() > 7 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(7).childCount() > 0 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(7).child(0).childCount() > 0 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(7).child(0).child(0).childCount() > 1 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(7).child(0).child(0).child(1).className() == "android.widget.ImageView" &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(7).child(0).child(0).child(0).childCount() > 0 &&
className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(7).child(0).child(0).child(0).child(0).className() == "android.widget.ImageView") {
let a = className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce().child(0).child(0).child(0).child(0).child(7).child(0).child(0).child(1).bounds();
click(a.centerX(), a.centerY());
toastLog("已尝试点击“收取提醒小手”");
sleep(3000);
if (className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce() != null && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().childCount() == 4 &&
className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(0).className() == "android.widget.TextView" && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(1).className() == "android.widget.TextView" && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(2).className() == "android.widget.TextView" && className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(3).className() == "android.widget.TextView") {
toastLog(className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(0).text() + className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(1).text() + className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(2).text() + className("android.widget.TextView").text("上轮您的豆豆成长值为").findOnce().parent().child(3).text())
}
if (className("android.widget.TextView").text("收下京豆").findOnce() != null) {
let b = className("android.widget.TextView").text("收下京豆").findOnce().bounds();
click(b.centerX(), b.centerY());
sleep(3000);
}
}
let ShouQu = ["好友帮收", "逛逛会场", "点击领取", "营养液", "每日签到", "618活动", "浏览店铺", "挑选商品", "金融双签", "疯抢爆品", "收取好友", "低价包邮", "高考加油", "千万京豆", "种豆专享", "健康宝藏"];
for (let a = 0; a < ShouQu.length; a++) {
while (className("android.widget.TextView").text(ShouQu[a]).findOnce() != null && className("android.widget.TextView").text(ShouQu[a]).findOnce().parent().child(0).childCount() > 2 && className("android.widget.TextView").text(ShouQu[a]).findOnce().parent().child(0).child(2).className() == "android.widget.TextView") {
let b = className("android.widget.TextView").text(ShouQu[a]).findOnce().parent().child(0).child(2);
click(b.bounds().centerX(), b.bounds().centerY());
toastLog("已尝试点击“" + ShouQu[a] + b.text() + "”");
sleep(2000);
}
}
function findQBRW() {
let a = className("android.widget.LinearLayout").id("com.jingdong.app.mall:id/aba").findOnce();
if (a != null && a.childCount() > 0 &&
a.child(0).childCount() > 0 &&
a.child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).childCount() > 0) {
for (let i = 0; i < a.child(0).child(0).child(0).child(0).child(0).child(0).childCount(); i++) {
if (a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).child(0).childCount() > 1 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).child(0).child(1).text().search("更多任务") >= 0 ||
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).child(0).childCount() > 1 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).child(0).child(1).text().search("全部任务") >= 0) {
return a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).child(0);
} else if (a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).childCount() > 1 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).child(1).text().search("更多任务") >= 0 ||
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).childCount() > 1 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i).child(1).text().search("全部任务") >= 0) {
return a.child(0).child(0).child(0).child(0).child(0).child(0).child(i);
}
}
}
if (a != null &&
a.childCount() > 0 &&
a.child(0).childCount() > 0 &&
a.child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).child(0).childCount() > 0 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).childCount() > 2) {
let i = a.child(0).child(0).child(0).child(0).child(0).child(0).childCount();
if (a.child(0).child(0).child(0).child(0).child(0).child(0).child(i - 2).childCount() > 1 &&
a.child(0).child(0).child(0).child(0).child(0).child(0).child(i - 2).child(1).text().search("更多任务") >= 0) {
return a.child(0).child(0).child(0).child(0).child(0).child(0).child(i - 2).child(1);
}
}
}
log("r" + findQBRW());
if (findQBRW() != undefined) {
let a = findQBRW().bounds();
click(a.centerX(), a.centerY());
toastLog("已尝试点击“全部任务”按钮X");
sleep(3000);
} else if (className("android.widget.ScrollView").findOnce() != null && className("android.widget.ScrollView").findOnce().childCount() > 0 && className("android.widget.ScrollView").findOnce().child(0).childCount() > 2) {
let a = className("android.widget.ScrollView").findOnce().child(0).child(className("android.widget.ScrollView").findOnce().child(0).childCount() - 2).bounds();
click(a.centerX(), a.centerY());
toastLog("已尝试点击“全部任务”按钮");
sleep(3000);
} else if (className("android.widget.TextView").text("收取营养液").findOnce() != null && className("android.widget.TextView").text("收取营养液").findOnce().parent().className() == "android.view.ViewGroup" && className("android.widget.TextView").text("收取营养液").findOnce().parent().parent().childCount() > 14) {
let a = className("android.widget.TextView").text("收取营养液").findOnce().parent().parent().child(13).bounds();
click(a.centerX(), a.centerY());
toastLog("已尝试点击“全部任务”按钮");
sleep(3000);
}
var ax = 0;
var DoNotDoPJRW = null;
var DoNotDoGGHC = null;
while (true) {
if (className("android.widget.TextView").text("全部任务").findOnce() != null && className("android.widget.TextView").text("全部任务").findOnce().parent().child(className("android.widget.TextView").text("全部任务").findOnce().parent().childCount() - 1).className() == "android.widget.ScrollView") {
var A = className("android.widget.TextView").text("全部任务").findOnce().parent().child(className("android.widget.TextView").text("全部任务").findOnce().parent().childCount() - 1);
var B = A.child(0);
} else if (className("android.widget.TextView").textContains("当前通过任务获得").findOnce() != null &&
className("android.widget.TextView").textContains("当前通过任务获得").findOnce().parent().parent().childCount() > 2 &&
className("android.widget.TextView").textContains("当前通过任务获得").findOnce().parent().parent().child(2).className() == "android.widget.ScrollView" &&
className("android.widget.TextView").textContains("当前通过任务获得").findOnce().parent().parent().child(2).childCount() == 1) {
var B = className("android.widget.TextView").textContains("当前通过任务获得").findOnce().parent().parent().child(2).child(0);
}
toastLog("任务列表可滑动区域为:" + B.bounds().top + "," + B.bounds().bottom);
if (ax >= B.childCount()) {
break;
} else {
try {
if (B.child(ax).child(0).childCount() > 1 && B.child(ax).child(0).child(1).className() == "android.widget.TextView") {
var RwTitle = B.child(ax).child(0).child(1).text();
} else if (B.child(ax).child(0).childCount() > 0 && B.child(ax).child(0).child(0).childCount() > 1 && B.child(ax).child(0).child(0).child(1).className() == "android.widget.TextView") {
var RwTitle = B.child(ax).child(0).child(0).child(1).text();
}
if (B.child(ax).childCount() > 0 &&
B.child(ax).child(0).childCount() > 2 &&
B.child(ax).child(0).child(2).childCount() > 1 &&
B.child(ax).child(0).child(2).child(1).className() == "android.widget.TextView") {
var ZhuangTai = B.child(ax).child(0).child(2).child(1).text();
} else if (B.child(ax).childCount() > 0 &&
B.child(ax).child(0).childCount() > 2 &&
B.child(ax).child(0).child(2).childCount() > 0 &&
B.child(ax).child(0).child(2).child(0).className() == "android.widget.TextView") {
var ZhuangTai = B.child(ax).child(0).child(2).child(0).text();
}
log(ZhuangTai);
if (B.child(ax).childCount() > 0 &&
B.child(ax).child(0).childCount() > 5 &&
B.child(ax).child(0).child(5).className() == "android.view.ViewGroup") {
var Button = B.child(ax).child(0).child(5).child(0);
} else if (B.child(ax).childCount() > 0 &&
B.child(ax).child(0).childCount() > 4 &&
B.child(ax).child(0).child(4).className() == "android.widget.TextView") {
var Button = B.child(ax).child(0).child(4);
} else if (B.child(ax).childCount() > 0 &&
B.child(ax).child(0).childCount() > 4 &&
B.child(ax).child(0).child(4).className() == "android.view.ViewGroup") {
var Button = B.child(ax).child(0).child(4).child(0);
}
log(RwTitle, ZhuangTai, Button.text());
} catch (e) {
console.warn("当前活动:" + currentActivity() + ",当前包名:" + currentPackage() + "当前应用名:" + getAppName(currentPackage()));
toastLog("当前未处于“任务列表”界面或返回任务界面出错,正在重新进入:" + e);
openInTask();
DoTask();
}
if (ZhuangTai.search("/") > 0) {
let Start = ZhuangTai.search("/");
now = null;
xz = null;
i = Start - 1;
while (true) {
if (now != null && isNaN(ZhuangTai[i]) == true) {
break;
} else if (now == null) {
var now = ZhuangTai[i];
} else {
var now = ZhuangTai[i] + now;
}
i--;
}
i = Start + 1;
while (true) {
if (xz != null && isNaN(ZhuangTai[i]) == true) {
break;
} else if (xz == null) {
var xz = ZhuangTai[i];
} else {
var xz = xz + ZhuangTai[i];
}
i++;
}
} else {
log("无法确定任务上限及当前完成数,请联系开发者解决", "任务名状态名:" + ZhuangTai);
alert("无法确定任务上限及当前完成数,请联系开发者解决", "任务名状态名:" + ZhuangTai);
exit();
}
toastLog("当前任务完成已完成" + now + "次,当前任务上限为" + xz + "次");
if (Button.bounds().centerY() > B.bounds().bottom - 10) {
swipe(B.bounds().centerX(), B.bounds().centerY(), B.bounds().centerX(), B.bounds().centerY() - 500, 500);
toastLog("已尝试上滑当前任务页,滑动前按钮“" + Button.text() + "”中心点Y坐标为:" + Button.bounds().centerY());
sleep(1000);
} else if (Button.bounds().centerY() < B.bounds().top) {
swipe(B.bounds().centerX(), B.bounds().centerY(), B.bounds().centerX(), B.bounds().centerY() + 500, 500);
toastLog("已尝试下滑当前任务页,滑动前按钮“" + Button.text() + "”中心点Y坐标为:" + Button.bounds().centerY());
sleep(1000);
} else if (now != xz && RwTitle != "逛逛会场" && RwTitle != "评价商品" && RwTitle != "好友助力" || now != xz && RwTitle == "逛逛会场" && DoNotDoGGHC == null && now == 0 || now != xz && RwTitle == "评价商品" && DoNotDoPJRW == null) {
if (Button.clickable() == true) {
Button.click();
toastLog("已尝试盲点“" + Button.text() + "”按钮");
} else {
let a = Button.bounds();
click(a.centerX(), a.centerY());
toastLog("已尝试点击“" + Button.text() + "”按钮");
}
sleep(3000);
for (var JustWait = 10; JustWait > 0; JustWait--) {
if (className("android.widget.TextView").text("进店任务").findOnce() != null) { //浏览店铺
var limit = Number(xz);
var over = 0;
var ALL = className("android.widget.TextView").text("进店并关注").find().size();
try {