Skip to content

Commit

Permalink
updata
Browse files Browse the repository at this point in the history
  • Loading branch information
cwj851 committed Jun 6, 2022
1 parent 2188039 commit ceea7c9
Show file tree
Hide file tree
Showing 21 changed files with 4,779 additions and 12 deletions.
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let default_config = {
watering_friend_times: '3',
changeBack:true,
//钉钉浇水设置参数
DDmineGroupList:[],
DdGroups_list:[],
DdGroups_list_Ex:[],
DdWateringGroups:[],
Expand Down
116 changes: 116 additions & 0 deletions lib/ProjectBridgeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,121 @@ module.exports = function (BaseHandler) {
postMessageToWebView({ callbackId: callbackId, data: config.huami_account_lists})
}

let group_lists = [];
BaseHandler.scanGroupList = (data, callbackId) => {
console.show()
start_app()
mine_group()
Read_group_lists_by_scroll()
console.log('====================')
console.warn('提取完毕!共提取' + group_lists.length + '个')
if (group_lists.length > 0) {
toast("提取群组列表成功:" + group_lists.length + '个')
} else {
toast("提取群组列表失败!")
}
sleep(5000)
console.hide()
postMessageToWebView({ callbackId: callbackId, data: group_lists })
}

BaseHandler.addGroupToDdWateringGroups = (data, callbackId) => {
config.DdWateringGroups.push(data)
toast(data.GroupName+"加入小号浇水列表成功!")
}

BaseHandler.addGroupToDdWateringGroupsEx = (data, callbackId) => {
config.DdWateringGroupsEx.push(data)
toast(data.GroupName+"加入大号浇水列表成功!")
}
function mine_group() {
app.startActivity({
action: "VIEW",
data: "dingtalk://dingtalkclient/page/link?url=" + encodeURIComponent("https://qr.dingtalk.com/mine_group_conversation.html"),
});
}

function Read_group_lists() {
while (true) {
if (idContains("tv_text").className("android.widget.TextView").text("我加入的").exists()) {
var MyGroups = idContains("tv_text").className("android.widget.TextView").text("我加入的").findOne().parent().parent().parent()
if (MyGroups.selected()) {
//log("当前页面(我加入的)");
log("检测中...请勿操作手机");
var group_listlength = idContains("group_list").find().length
idContains("group_list").find()[group_listlength - 1].children().forEach(child => {
var target = child.findOne(id("group_title"));
if (target) {
if (target.text() != "") {
if (group_lists.map(v => v.GroupName).indexOf(target.text()) < 0) {
group_lists.push({ GroupName: target.text(), WateringDate: '2122-01-01' })
console.verbose(target.text())
}
}
}
});
break
} else {
MyGroups.click()
}
}
sleep(500)
}
}

function Read_group_lists_by_scroll() {
var is_theEnd = false
while (!is_theEnd) {
Read_group_lists()
if (idContains("group_list").exists()) {
var group_listlength = idContains("group_list").find().length
is_theEnd = !idContains("group_list").find()[group_listlength - 1].scrollDown()
sleep(100)
}
sleep(200)
}
}
function start_app() {
log("正在启动app...");
if (!(launchApp("钉钉") || launch('com.alibaba.android.rimet'))) //
{
log("找不到钉钉App!,请自己尝试打开");
// return;
}
sleep(2000)
//ZFB_SY()
while (!packageName('com.alibaba.android.rimet').text("消息").exists()) {
log("正在等待加载出主页,如果一直加载此信息,请手动返回主页,或者无障碍服务可能出现BUG,请停止运行App重新给无障碍服务");
closeUpdata()
clickBack()
closePage()
if (className("android.widget.TextView").text("钉钉小程序").exists()) { back() }
sleep(2000);
}
log("启动app成功!");
sleep(1000);
}

function closeUpdata() {
if (text("暂不更新").exists() && text("更新").exists()) {
text("暂不更新").click();
}
}

function clickBack() {
if (className("android.widget.ImageButton").desc("返回").exists()) {
className("android.widget.ImageButton").desc("返回").click()
}
if (idContains("img_back").desc("返回").exists()) {
idContains("img_back").desc("返回").findOnce().parent().click()
}
closePage()
}

function closePage() {
if (idContains("close_layout").desc("关闭").exists()) {
idContains("close_layout").desc("关闭").click()
}
}
return BaseHandler
}
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"packageName": "com.AntforestDreamPro.assistant",
"scripts": {},
"versionCode": 1,
"versionName": "1.6.4.2"
"versionName": "1.6.6.1"
}
36 changes: 27 additions & 9 deletions unit/DdWatering.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function clickBack() {
function closePage() {
if (idContains("close_layout").desc("关闭").exists()) {
idContains("close_layout").desc("关闭").click()
sleep(200)
}
}

Expand Down Expand Up @@ -603,9 +604,9 @@ function watering_Ex(group_name, waterNum) {
if (text('总排行榜').exists()) {
cooperate_energy = get_cooperate_energy()
var WaterPoint = checkAndClickWater()
//sleep(200)
if (WaterPoint) {
click(WaterPoint.centerX, WaterPoint.centerY)
sleep(500)
}
while (true) {
if (text("我知道了").exists() && text("继续浇水").exists()) {
Expand Down Expand Up @@ -635,17 +636,21 @@ function watering_Ex(group_name, waterNum) {
var Etext2 = gtext.findOne(className("android.widget.EditText")).text()
logUtils.infoLog('本次浇水:' + Etext2 + 'g');
floaty_show_text('本次浇水:' + Etext2 + 'g')
complete = true
watercount += parseInt(Etext2);
click(waterTarget.centerX(), waterTarget.centerY())
sleep(200)
AntForestDao.saveFriendCollect(group_name, cooperate_energy, My_energy, parseInt(Etext2))
closePage()
complete = true
break
}
}
} else {
WaterPoint = checkAndClickWater()
if (WaterPoint) { click(WaterPoint.centerX, WaterPoint.centerY) }
if (WaterPoint) {
click(WaterPoint.centerX, WaterPoint.centerY)
sleep(500)
}
}
if (className("android.view.View").text("知道了").exists()) {
var ikonwTarget = text("知道了").findOne().bounds()
Expand Down Expand Up @@ -711,6 +716,7 @@ function watering(group_name, waterNum) {
//sleep(200)
if (WaterPoint) {
click(WaterPoint.centerX, WaterPoint.centerY)
sleep(500)
}
while (true) {
if (text("我知道了").exists() && text("继续浇水").exists()) {
Expand Down Expand Up @@ -751,11 +757,12 @@ function watering(group_name, waterNum) {
var Etext2 = gtext.findOne(className("android.widget.EditText")).text()
logUtils.infoLog('本次浇水:' + Etext2 + 'g');
floaty_show_text('本次浇水:' + Etext2 + 'g')
complete = true
watercount += parseInt(Etext2);
click(waterTarget.centerX(), waterTarget.centerY())
sleep(200)
AntForestDao.saveFriendCollect(group_name, cooperate_energy, My_energy, parseInt(Etext2))
closePage()
complete = true
break
}
}
Expand All @@ -775,18 +782,22 @@ function watering(group_name, waterNum) {
var Etext2 = gtext.findOne(className("android.widget.EditText")).text()
logUtils.infoLog('本次浇水:' + Etext2 + 'g');
floaty_show_text('本次浇水:' + Etext2 + 'g')
complete = true
watercount += parseInt(Etext2);
click(waterTarget.centerX(), waterTarget.centerY())
sleep(200)
AntForestDao.saveFriendCollect(group_name, cooperate_energy, My_energy, parseInt(Etext2))
closePage()
complete = true
break
}
}
}
} else {
WaterPoint = checkAndClickWater()
if (WaterPoint) { click(WaterPoint.centerX, WaterPoint.centerY) }
if (WaterPoint) {
click(WaterPoint.centerX, WaterPoint.centerY)
sleep(500)
}
}
if (className("android.view.View").text("知道了").exists()) {
var ikonwTarget = text("知道了").findOne().bounds()
Expand Down Expand Up @@ -853,6 +864,7 @@ function continue_watering(group_name, waterNum) {
//sleep(200)
if (WaterPoint) {
click(WaterPoint.centerX, WaterPoint.centerY)
sleep(500)
}
while (true) {
if (text("我知道了").exists() && text("继续浇水").exists()) {
Expand Down Expand Up @@ -893,11 +905,12 @@ function continue_watering(group_name, waterNum) {
var Etext2 = gtext.findOne(className("android.widget.EditText")).text()
logUtils.infoLog('本次浇水:' + Etext2 + 'g');
floaty_show_text('本次浇水:' + Etext2 + 'g')
complete = true
watercount += parseInt(Etext2);
click(waterTarget.centerX(), waterTarget.centerY())
sleep(200)
AntForestDao.saveFriendCollect(group_name, cooperate_energy, My_energy, parseInt(Etext2))
closePage()
complete = true
break
}
}
Expand All @@ -916,18 +929,22 @@ function continue_watering(group_name, waterNum) {
var Etext2 = gtext.findOne(className("android.widget.EditText")).text()
logUtils.infoLog('本次浇水:' + Etext2 + 'g');
floaty_show_text('本次浇水:' + Etext2 + 'g')
complete = true
watercount += parseInt(Etext2);
click(waterTarget.centerX(), waterTarget.centerY())
sleep(200)
AntForestDao.saveFriendCollect(group_name, cooperate_energy, My_energy, parseInt(Etext2))
closePage()
complete = true
break
}
}
}
} else {
WaterPoint = checkAndClickWater()
if (WaterPoint) { click(WaterPoint.centerX, WaterPoint.centerY) }
if (WaterPoint) {
click(WaterPoint.centerX, WaterPoint.centerY)
sleep(500)
}
}
if (className("android.view.View").text("知道了").exists()) {
var ikonwTarget = text("知道了").findOne().bounds()
Expand Down Expand Up @@ -1357,6 +1374,7 @@ function bandage_Alipay() {
//sleep(200)
if (WaterPoint) {
click(WaterPoint.centerX, WaterPoint.centerY)
sleep(500)
}
sleep(1000)
}
Expand Down
32 changes: 32 additions & 0 deletions unit/导入小米运动账号Ex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var { default_config, config, storage_name: _storage_name } = require('../config.js')(runtime, global)
let args = engines.myEngine().execArgv
let storageConfig = storages.create(_storage_name)


function readHMAccount() {
let counti = 0
if (args.HMAccountText) {
var text = args.HMAccountText
let HMAccountlist = text.split('\n');
for (var i = 0; i < HMAccountlist.length; i++) {
var t = HMAccountlist[i].split('----');
if (t[1] && t[0]) {
if (config.huami_account_lists.map(v => v.username).indexOf(t[0].replace(/\r/g, '')) < 0) {
config.huami_account_lists.push({ username: t[0].replace(/\r/g, ''), password: t[1].replace(/\r/g, '') });
counti++
}
}
}
} else {
toastLog('未输入账号文本!')
}
if (counti > 0) {
storageConfig.put("huami_account_lists", config.huami_account_lists)
toastLog("成功导入小米运动账号:" + counti + '个')
} else {
toastLog("所有账号已保存或账号文本为空!")
}
}

readHMAccount()

Loading

0 comments on commit ceea7c9

Please sign in to comment.