This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
forked from Nick-Hopps/Ant-Forest-autoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
63 lines (53 loc) · 1.65 KB
/
main.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
/*
* @Author: NickHopps
* @Last Modified by: NickHopps
* @Last Modified time: 2019-04-08 08:44:22
* @Description: 蚂蚁森林自动收能量
*/
/***********************
* 初始化
***********************/
// 检查手机是否开启无障碍服务
auto();
// 请求截图权限
if (! requestScreenCapture()) {
toast("请求截图失败");
exit();
}
// 检查脚本是否重复运行
engines.all().slice(1).forEach(script => {
if (script.getSource().getName().indexOf(engines.myEngine().getSource())) {
//log(script.getSource().getName());
//log(engines.myEngine().getSource());
//log(script.getSource().getName().indexOf(engines.myEngine().getSource()));
toastLog("脚本后台运行中,即将结束并重新执行");
engines.stopAll();
engines.execScriptFile(engines.myEngine().getSource());
//engines.myEngine().forceStop();
//script.forceStop();
//toastLog("脚本正在运行中");
//engines.myEngine().forceStop();
}
});
/************************
* 依赖加载
***********************/
// 检查更新
//engines.execScriptFile("./update.js");
// 加载本地配置
var config = storages.create("ant_forest_config");
if (!config.contains("color_offset")) {
toastLog("请完善配置后再运行");
engines.execScriptFile("./config.js");
engines.myEngine().forceStop();
}
var Automator = require("./lib/Automator.js");
var Unlock = require("./lib/Unlock.js");
var Ant_forest = require("./core/Ant_forest.js");
var automator = Automator();
var unlock = Unlock(automator);
var ant_forest = Ant_forest(automator, unlock);
/************************
* 主程序
***********************/
ant_forest.exec();