Home > front end >  Please analyze a ants energy forest harvest script automatically, if you have any questions?
Please analyze a ants energy forest harvest script automatically, if you have any questions?

Time:01-16

Recently saw an open source project: ants energy forest harvest script automatically, if you have any questions? The open source project address: https://github.com/SuperMonster003/Ant-Forest

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
/* *
* @ description alipay ant forest intelligent collection script
*
* @ since Nov 16, 2020,
* @ version 1.9.25
* @ author SuperMonster003 {@ link https://github.com/SuperMonster003}
*
* @ see {@ link https://github.com/SuperMonster003/Ant_Forest}
*/

'use strict';

Let $$init={
Check () {
CheckAlipayPackage ();
CheckModulesMap ();
CheckSdkAndAJVer ();
CheckProviderSettings ();
CheckRootAccess ();
CheckAccessibility ();

return this;

//tool function (s)//

The function checkAlipayPackage () {
Let _pkg="com. Eg. Android. AlipayGphone";
Let _pkg_mgr=context. GetPackageManager ();
Let _app_name _app_info;
Try {
_app_info=_pkg_mgr. GetApplicationInfo (_pkg, 0).
_app_name=_pkg_mgr. GetApplicationLabel (_app_info);
} the catch (e) {
ShowSplitLineRaw ();
The console. Warn (e.m essage);
The console. Warn (e.s tack);
}
if (! _app_name) {
Let the _msg='this device may not installed "alipay" application'.
Toast (_msg);
ShowSplitLineRaw ();
The console. The error (" script cannot continue ");
The console. The error (_msg);
ShowSplitLineRaw ();
exit();
}
Global. _ $_pkg_name=_pkg;
}

The function checkModulesMap () {
Void [
"MODULE_MONSTER_FUNC", "MODULE_STORAGE,"
"MODULE_DEFAULT_CONFIG", "MODULE_PWMAP,"
"MODULE_TREASURY_VAULT", "MODULE_UNLOCK,"
"" EXT_TIMERS EXT_DIALOGS", ", "EXT_DEVICE,"
"" EXT_IMAGES EXT_APP", ", "EXT_ENGINES
"]. Filter ((mod)=& gt; (
! Files. The exists ("./Modules/" + mod + "js")
)). Some ((mod, independence idx, arr)=& gt; {
Let _str="";
_str +="script cannot continue | the following modules are missing or path error: |";
_str +="-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - |";
Arr. ForEach (n=& gt; _str +='- & gt; "' + n +" | ");
_str +="-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - |";
_str +="please check or reposition the module";
ShowSplitLineRaw ();
_str. Split (" | "). The forEach (s=& gt; MessageActionRaw (s, 4));
ShowSplitLineRaw ();
Toast (" module is missing or path error ", "Long");
exit();
});
}

The function checkSdkAndAJVer () {
//do not ` the require () ` before ` checkModulesMap ` ()
Global $_app=the require ("./Modules/MODULE_MONSTER_FUNC "). CheckSdkAndAJVer ();
}

The function checkProviderSettings () {
//the checker for legacy bug (before v1.9.24 Beta)
//which may cause a tiny value for ` System. SCREEN_OFF_TIMEOUT `

Let the System=android. The provider. Settings. The System;

Let _scr_off_tt=System. SCREEN_OFF_TIMEOUT;
Let _ctx_reso=context. GetContentResolver ();

Let _scr_off_tt_val=System. Get int (_ctx_reso, _scr_off_tt, 0);
Let _min_normal_val=15 * 1 e3; 15 seconds//
Let _normal_val=2 * 60 e3.//2 minutes
Let _normal_mm=Number ((_normal_val/60 e3). ToFixed (2));
If (_scr_off_tt_val & lt; _min_normal_val) {
ShowSplitLineRaw ();
MessageActionRaw (" screen timeout parameter correction abnormal equipment ");
MessageActionRaw (" revised: "+ _normal_val +" (" + _normal_mm + minutes ") ");
System. PutInt (_ctx_reso _scr_off_tt, _normal_val);
}
}

The function checkRootAccess () {
Global. _ $_autojs_has_root=the require ("./Modules/EXT_APP "). HasRoot ();
Global. _ $_autojs_has_secure=the require ("./Modules/EXT_APP "). HasSecure ();
}

The function checkAccessibility () {
Let _line=showSplitLineRaw;
Let _getDash=()=& gt; "-". Repeat (17). The trim ();
Let the _msg=messageActionRaw;

_checkSvc ();
_checkFunc ();

//tool function (s)//

The function _checkSvc () {
//do not ` the require () ` before ` checkModulesMap ` ()
Let _a11y=the require ("./Modules/EXT_DEVICE "). The a11y;
{if (_a11y. State ())
return;
}

Let _perm="android. Permission. WRITE_SECURE_SETTINGS";
Let _pkg_n_perm=context. + "" + packageName _perm;

Let _mod_mon=the require ("./Modules/MODULE_MONSTER_FUNC ");
Let _mod_sto=the require ("./Modules/MODULE_STORAGE ");
Let $_cfg=_mod_sto. Create (" af_cfg "). The get (" config ", {});
If ($_cfg auto_enable_a11y_svc==="ON") {
_tryEnableAndRestart ();
If (global) _ $_autojs_has_root) {
Shell (PM grant, "" + _pkg_n_perm, true);
_tryEnableAndRestart ();
}
_failedHint ();
}

If (typeof auto waitFor!=="function") {
Try {
Auto ();
} the catch (e) {
//consume errors MSG under caused by auto ()
}
exit();
}

Let _thd=threads. Start (function () {
//script will continue running rather than stop
//when the org.eclipse.swt.accessibility service enabled by the user
Auto. WaitFor ();
});
_thd. Join (60 e3);

If (_thd isAlive ()) {
_line ();
The _msg (" wait for the user to open barrier-free service timeout ", 4, 1);
_line ();
exit();
}

{//tool function (s)

The function _failedHint () {
Let _shell_sc="adb shell PM grant" + _pkg_n_perm;

_line ();
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related