- UID
- 3977
- 阅读权限
- 150
- 注册时间
- 2022-12-3
- 在线时间
- 小时
累计签到:120 天 连续签到:1 天
|
if (!auto.service) {
toast('无停滞效劳已启动!退出!')
exit()
}
console.show()
function getSetting() {
let indices = []
autoOpen && indices.push(0)
autoMute && indices.push(1)
autoJoin && indices.push(2)
indices.push(3)
let settings = dialogs.multiChoice('使命设置', ['主动翻开京东进进举动。多开或使命列表没法主动翻开时打消勾选', '主动调解媒体音量为0。免得曲播使命收回声音,初次挑选需求修正体系设置权限', '主动完成进会使命。京东将受权脚机号给商家,往后能够会支到推行短疑', '此选项用于包管挑选的处置,勿动!'], indices)
if (settings.length == 0) {
toast('打消挑选,使命截至')
exit()
}
if (settings.indexOf(0) != -1) {
storage.put('autoOpen', true)
autoOpen = true
} else {
storage.put('autoOpen', false)
autoOpen = false
}
if (settings.indexOf(1) != -1) {
storage.put('autoMute', true)
autoMute = true
} else {
storage.put('autoMute', false)
autoMute = false
}
if (settings.indexOf(2) != -1) {
storage.put('autoJoin', true)
autoJoin = true
} else {
storage.put('autoJoin', false)
autoJoin = false
}
}
let storage = storages.create('jd_task')
let autoOpen = storage.get('autoOpen', true)
let autoMute = storage.get('autoMute', true)
let autoJoin = storage.get('autoJoin', true)
getSetting()
if (autoMute) {
try {
device.setMusicVolume(0)
toast('胜利设置媒体音量为0')
} catch (err) {
alert('起首需求开启建复音量权限,请开启后再次运转剧本')
exit()
}
}
console.log('开端完成京东使命...')
console.log('按音量下键截至')
device.keepScreenDim(30 * 60 * 1000) // 避免息屏30分钟
// 自界说打消明屏的退出办法
function quit() {
device.cancelKeepingAwake()
exit()
}
// 监听音量下键
function registerKey() {
try {
events.observeKey()
} catch (err) {
console.log('监听音量键截至失利,该当是无停滞权限堕落,请封闭硬件背景使命从头运转。')
console.log('假如仍是不可能够重启脚机测验考试。')
quit()
}
events.onKeyDown('volume_down', function (event) {
console.log('京东使命剧本截至了')
console.log('请脚动切换回主页里')
quit()
})
}
threads.start(registerKey)
// 自界说一个findTextDescMatchesTimeout
function findTextDescMatchesTimeout(reg, timeout) {
let c = 0
while (c < timeout / 50) {
let result = textMatches(reg).findOnce() || descMatches(reg).findOnce()
if (result) return result
sleep(50)
c++
}
return null
}
// 翻开京东进进举动
function openAndInto() {
console.log('正正在翻开京东App...')
if (!launch('com.jingdong.app.mall')) {
console.log('能够已装置京东App')
}
sleep(2000)
console.log('进进举动页里')
app.startActivity({
action: "VIEW",
data: 'openApp.jdMobile://virtual?params={"category":"jump","action":"to","des":"m","sourceValue":"JSHOP_SOURCE_VALUE","sourceType":"JSHOP_SOURCE_TYPE","url":"https://u.jd.com/6qkqN2X","M_sourceFrom":"mxz","msf_type":"auto"}'
})
}
// 获得金币数目
function getCoin() {
let anchor = text('乏计已拆').findOne(5000)
if (!anchor) {
console.log('找没有到控件')
return false
}
let coin = anchor.parent().child(1).text()
if (coin) {
return parseInt(coin)
} else {
return false
}
}
// 翻开使命列表
function openTaskList() {
console.log('翻开使命列表')
let anchor = text('拆快递').findOne(20000)
if (!anchor) {
console.log('已能定位使命列表,请封闭京东从头运转!')
quit()
}
if (anchor.indexInParent() < 3) {
anchor = anchor.parent()
}
// let taskListButton
let taskListButton = anchor.parent()
// console.log(tmp)
// for (let i = 0; i < tmp.length; i++) {
// if (tmp.bounds().centerX() == anchor.bounds().centerX() && tmp.bounds().centerY() == anchor.bounds().centerY()) {
// console.log(1)
// taskListButton = tmp[i + 1].child(1)
// if (!taskListButton.clickable()) {
// try {
// taskListButton = taskListButton.child(0)
// } catch (err) {
// console.log('不成面击')
// taskListButton = null
// }
// }
// break
// }
// }
if (!taskListButton || !taskListButton.clickable()) {
console.log('没法找到使命列表控件,请参照硬件内乱的阐明改换web内乱核。')
quit()
}
taskListButton.click()
console.log('等候使命列表')
if (!findTextDescMatchesTimeout(/每做一次使命就能够拆一个快递箱哦~/, 5000)) {
console.log('仿佛出能翻开使命列表,重试')
taskListButton.click()
}
if (!findTextDescMatchesTimeout(/每做一次使命就能够拆一个快递箱哦~/, 10000)) {
console.log('仿佛出能翻开使命列表,退出!')
console.log('假如曾经翻开而已检测到,请参照硬件内乱的阐明改换web内乱核。')
quit()
}
}
// 封闭使命列表
function closeTaskList() {
console.log('封闭使命列表')
let anchor = text('每做一次使命就能够拆一个快递箱哦~').findOne(5000)
if (!anchor) {
console.log('没法找到使命嘉奖标识')
return false
}
anchor = anchor.parent()
let closeBtn = anchor.child(anchor.childCount() - 2) // tbs
if (!closeBtn.clickable()) {
closeBtn = anchor.child(anchor.childCount() - 1) // webview
}
return closeBtn.click()
}
// 从头翻开使命列表
function reopenTaskList() {
sleep(3000)
closeTaskList()
sleep(3000)
openTaskList()
sleep(5000)
}
// 获得已完成使命,按照数字标识,返回使命按钮、使命引见、使命数目(数组)
function getTaskByText() {
let tButton = null,
tText = null,
tCount = 0,
tTitle = null
console.log('寻觅已完成使命...')
let anchor = textMatches(/^(来完成|来挨卡)$/).findOnce()
if (anchor) { // 假如找没有到使命,间接返回
let tasks = anchor.parent().parent().parent().children()
tasks.pop()
for (let i = 0; i < tasks.length; i += 5) {
let task = tasks.slice(i, i + 5)
try {
tTitle = task[1].text()
let r = task[2].text().match(/(\d*)\/(\d*)/)
if (!r) continue
tCount = (r[2] - r[1])
console.log(tTitle, tCount)
button = task[4]
if (!button.child(0).child(0).text().match(/来完成|来支付|来挨卡/)) continue
// log(tasks)
if (tCount) { // 假如数字相加没有为0,证实出完成
tText = task[3].text()
if (!autoJoin && tText.match(/胜利进会/)) continue
if (tTitle.match(/下单|小法式|裂变/)) continue
tButton = button
break
}
} catch (err) {
console.log(err)
}
}
} else {
console.log('使命提醒已找到')
}
return [tButton, tText, tCount, tTitle]
}
// 返回使命列表并查抄能否胜利,没有胜利重试一次,带有延时
function backToList() {
sleep(500)
back()
for (let i = 0; i < 5; i++) { // 测验考试返回3次
if (!findTextDescMatchesTimeout(/每做一次使命就能够拆一个快递箱哦~/, 5000)) {
console.log('返回失利,重试返回')
sleep(2000)
back()
continue
} else {
break
}
}
sleep(3000)
}
// 阅读n秒的使命
function timeTask() {
console.log('等候阅读使命完成...')
let c = 0
while (c < 40) { // 0.5 * 40 = 20 秒,避免逝世轮回
if ((textMatches(/得到.*?快递箱/).exists() || descMatches(/得到.*?快递箱/).exists())) // 等候已完成呈现
break
if ((textMatches(/已阅读/).exists() || descMatches(/已阅读/).exists())) { // 失利
console.log('上限,返回革新使命列表')
return false
}
if ((textMatches(/已 浏 览/).exists() || descMatches(/已 浏 览/).exists())) { // 失利
console.log('上限,返回革新使命列表')
return false
}
if (textMatches(/.*滑动阅读.*[^可]得.*/).exists()) {
console.log('停止模仿滑动')
swipe_flag = 1
swipe(device.width / 2, device.height - 200, device.width / 2 + 20, device.height - 500, 500)
c++
}
// 弹窗处置
let pop = text('晋级开卡会员发好礼')
if (pop.exists()) {
pop.findOnce().parent().parent().child(2).click()
console.log('封闭会员弹窗')
}
sleep(500)
c++
}
if (c > 39) {
console.log('已检测到使命完成标识。')
return false
}
console.log('已完成,筹办返回')
return true
}
// 进会使命
function joinTask() {
let check = textMatches(/.*确认受权即赞成.*|.*我的特权.*|.*立刻开卡.*|.*解锁局部会员祸利.*/).findOne(8000)
if (!check) {
console.log('没法找到进会按钮,断定为曾经进会')
return true
} else if (check.text().match(/我的特权/)) {
console.log('曾经进会,返回')
return true
} else {
sleep(2000)
if (check.text().match(/.*立刻开卡.*|.*解锁局部会员祸利.*|受权解锁/)) {
if (check.text() == '受权疑息,解锁局部会员祸利') {
check = text('来晋级').findOnce()
if (!check) {
console.log('此范例没法找到晋级按钮,进会失利')
return false
}
}
let btn = check.bounds()
console.log('行将面击开卡/解锁祸利/晋级,主动躲藏掌握台')
sleep(500)
console.hide()
sleep(500)
click(btn.centerX(), btn.centerY())
sleep(500)
console.show()
sleep(5000)
check = textMatches(/.*确认受权即赞成.*/).boundsInside(0, 0, device.width, device.height).findOne(8000)
}
if (!check) {
console.log('没法找到进会按钮弹窗,减载失利')
return false
}
if (check.indexInParent() == 2) {
check = check.parent().child(1)
} else {
let anchor = textContains('*****').findOnce()
check = anchor.parent().child(anchor.indexInParent() + 2)
if (!check.bounds().top >= anchor.bounds().bottom) {
console.log('利用第两种办法获得控件')
let check1 = anchor.parent().children().findOne(filter(function (w) {
if (w.className().match(/ImageView/) && w.bounds().top >= anchor.bounds().bottom) {
return true
} else {
return false
}
}))
if (!check1) {
console.log('第两种办法也没法确认受权勾选框,失利。返回。')
return false
} else {
check = check1
console.log('胜利,持续')
}
}
}
console.log("终极[确认受权]前里选项框坐标为:", check.bounds());
let x = check.bounds().centerX()
let y = check.bounds().centerY()
console.log('检测能否有遮挡')
let float = className('android.widget.ImageView')
.filter(function (w) {
let b = w.bounds()
return b.left <= x && b.right >= x && b.top <= y && b.bottom >= y && b.centerX() != x && b.centerY() != y
}).findOnce()
if (float) {
console.log('有浮窗遮挡,测验考试移除')
if (device.sdkInt >= 24) {
gesture(1000, [float.bounds().centerX(), float.bounds().centerY()], [float.bounds().centerX(), y + float.bounds().height()])
console.log('曾经停止移开操纵,假如失利请反应')
} else {
console.log('安卓版本低,没法主动移开浮窗,进会使命失利。最少需求安卓7.0。')
return false
}
} else {
console.log('已发明遮挡的浮窗,持续勾选')
}
console.log('行将勾选受权,主动躲藏掌握台')
sleep(500)
console.hide()
sleep(1000)
click(x, y)
sleep(500)
console.show()
console.log('筹办面击进会按钮')
let j = textMatches(/^确认受权(并参加店肆会员)*$|.*立刻开通.*/).findOne(5000)
if (!j) {
console.log('没法找到进会按钮,失利')
return false
}
click(j.bounds().centerX(), j.bounds().centerY())
sleep(1000)
console.log('进会完成,返回')
return true
}
}
// 阅读商品战减购的使命,cart参数为能否减购的flag
function itemTask(cart) {
console.log('等候进进商品列表...')
if (!findTextDescMatchesTimeout('/.*当前页.*/',20000)) {
console.log('已能进进商品列表。')
console.log(textContains('.jpg!q70').findOnce());
return false
}
sleep(2000)
let items = textContains('.jpg!q70').find()
for (let i = 0; i < items.length; i++) {
console.log('阅读')
let tmp = items.parent().parent()
tmp.child(tmp.childCount() - 1).click()
sleep(5000)
console.log('返回')
back()
sleep(5000)
let r = textContains('当前页').findOnce()
if (!r) {
back()
sleep(5000)
}
if (i >= 4 - 1) {
break
}
}
return true
}
// 逛店使命 TODO: 618版本
function shopTask() {
console.log('等候进进店肆列表...')
console.log(textContains('互动种草').findOne(10000));
let banner = textContains('喜好').findOne(10000)
if (!banner) {
console.log('已能进进店肆列表。返回。')
return false
}
let c = banner.text().match(/(\d)\/(\d*)/)
if (!c) {
c = 4 // 停止4次
} else {
c = c[2] - c[1]
}
sleep(2000)
console.log('停止', c, '次')
let like = text('喜好').boundsInside(1, 0, device.width, device.height).findOnce()
if (!like) {
console.log('已能找到喜好按钮。返回。')
return false
}
let bound = [like.bounds().centerX(), like.bounds().centerY()]
console.log('喜好按钮位于', bound)
for (let i = 0; i < c; i++) {
click(bound[0], bound[1])
console.log('阅读店肆页')
sleep(8000)
console.log('返回')
back()
sleep(5000)
let r = textContains('喜好').findOnce()
if (!r) {
back()
sleep(5000)
}
}
return true
}
// 观光使命
function viewTask() {
console.log('停止观光使命')
sleep(5000)
console.log('观光使命间接返回')
return true
}
// 品牌墙使命 TODO: 年货节版本
function wallTask() {
console.log('停止品牌墙使命')
sleep(3000)
for (let i of [2, 3, 4, 5, 6]) { // 选5个
console.log('翻开一个')
textContains('!q70').boundsInside(100, 100, device.width, device.height).findOnce(i).click()
sleep(5000)
console.log('间接返回')
back()
let r = textContains('!q70').findOne(8000)
if (!r) back()
sleep(3000)
}
console.log('品牌墙完成后从头翻开使命列表')
sleep(3000)
openTaskList()
return true
}
// 单个使命的function,主动进进使命、主动返回使命列表,返回boolean
// TODO: 年货节
function doTask(tButton, tText, tTitle) {
let clickFlag = tButton.click()
let tFlag
if (tButton.text() == '来支付') {
tFlag = clickFlag // 挨卡面击一次便可
return tFlag
}
if (tText.match(/品牌墙/) || tTitle.match(/品牌墙/)) {
if (tTitle.match(/阅读更多权益/)) {
console.log('简朴品牌墙使命,等候10s')
sleep(10000)
return true
}
tFlag = wallTask()
return tFlag // 品牌墙无需backToList,提早返回
} else if (tText.match(/阅读并存眷.*s|阅读.*s/)) {
console.log('停止', tText)
tFlag = timeTask()
} else if (tText.match(/乏计阅读/)) {
console.log('停止乏计阅读使命')
if (tText.match(/减购/)) {
tFlag = itemTask(true)
} else {
tFlag = itemTask(false)
}
} else if (tText.match(/进会/)) {
console.log('停止进会使命')
tFlag = joinTask()
} else if (tText.match(/阅读可得.*|阅读并存眷|早会|到场/)) {
if (tTitle.match(/种草乡/)) {
tFlag = shopTask()
} else {
tFlag = viewTask()
}
} else if (tText.match(/挨卡|尾页/)) {
tFlag = clickFlag // 挨卡面击一次便可
return tFlag
} else if (tText.match(/组队/)) {
console.log('等候组队使命')
sleep(3000)
if (findTextDescMatchesTimeout(/.*每做一次使命.*/, 1000)) {
console.log('当前仍正在使命列表,阐明曾经完成使命且支付嘉奖,返回')
return true
} else {
if (textContains('步队快递箱').findOne(10000)) {
console.log('进进到组队页里,返回')
backToList()
console.log('等候支付嘉奖')
sleep(2000)
tFlag = tButton.click()
sleep(2000)
return tFlag
} else {
console.log('已能进进组队')
if (findTextDescMatchesTimeout(/.*每做一次使命.*/, 1000)) {
console.log('当前仍正在使命列表,返回')
return true
} else {
console.log('组队使命已检测到页里标识,视为已完成')
tFlag = false
}
}
}
} else {
console.log('已知使命范例,默许为阅读使命', tText)
tFlag = timeTask()
}
backToList()
return tFlag
}
function closePop(){
let anchor = text('已放进尾页>记载').findOne(5000);
if(anchor){
anchor = anchor.parent()
let closeBtn = anchor.child(anchor.childCount() - 2) // tbs
if (!closeBtn.clickable()) {
closeBtn = anchor.child(anchor.childCount() - 1) // webview
}
return closeBtn.click()
}
console.log('已查询到弹窗按钮')
return false
}
function signTask() {
console.log('测验考试封闭弹窗')
let anchor = textMatches(/\+\d*爆仗/).findOnce();
for (let i = 0; i < 5 && anchor; i++) {
try {
let tmp = anchor.parent().parent().child(0)
if (!tmp.clickable()) {
tmp = anchor.parent().parent().parent().child(0)
}
tmp.click()
console.log('封闭')
sleep(1000)
anchor = textMatches(/\+\d*爆仗/).findOnce()
} catch (err) {
pass
}
}
anchor = text('记载').findOne(5000)
if (!anchor) {
console.log('已能定位,签到失利')
quit()
}
let sign
if (anchor.indexInParent() < 3) {
anchor = anchor.parent()
}
sign = anchor.parent().child(10)
if (!sign.clickable()) {
sign = anchor.parent().child(11)
}
sign.click()
sleep(3000)
anchor = text('提示我天天签到').findOne(5000)
if (!anchor) {
console.log('已找到签到按钮')
return false
}
anchor = anchor.parent().parent()
sign = anchor.child(anchor.childCount() - 2)
console.log('面击签到')
return sign.click()
}
// 支付金币
function havestCoin() {
console.log('筹办支付主动积聚的金币')
let h = textMatches(/.*面击支付.*|.*后存谦.*/).findOne(5000)
if (h) {
h.click()
console.log('支付胜利')
sleep(8000)
} else { console.log('已找到金币控件,支付失利') }
}
let startCoin = null
// 齐局try catch,应对没法显现报错
try {
if (autoOpen) {
openAndInto()
console.log('等候举动页里减载')
if (!findTextDescMatchesTimeout(/.*拆快递.*/, 8000)) {
console.log('已能进进举动,请从头运转!')
quit()
}
console.log('胜利进进举动,背下滑动一段以包管控件局部呈现')
sleep(2000)
scrollDown();
openTaskList();
} else {
alert('请封闭弹窗后立即脚动翻开京东App进进举动页里,并翻开使命列表', '限时30秒')
console.log('请脚动翻开京东App进进举动页里,并翻开使命列表')
if (!findTextDescMatchesTimeout(/每做一次使命.*|攻略/, 8000)) {
console.log('已能进进举动,请从头运转!')
quit()
}
console.log('胜利进进举动')
}
sleep(5000)
try {
console.log('获得初初快递箱数目')
startCoin = getCoin()
console.log('当前共有' + startCoin + '快递箱')
} catch (err) {
console.log('获得快递箱失利,跳过', err)
}
// 完成一切使命的轮回
while (true) {
let [taskButton, taskText, taskCount, taskTitle] = getTaskByText()
if (!taskButton) {
console.log('支付白包嘉奖')
let anchor = textContains('/再拆.*个快递有时机得白包/').findOnce()
textContains('来支付').find().forEach(function (e, i) {
console.log('支付第' + (i + 1) + '个乏计嘉奖')
e.click()
sleep(2000)
})
let endCoin = null
try {
console.log('获得完毕快递箱数目')
endCoin = getCoin()
console.log('当前共有' + endCoin + '快递箱')
} catch (err) {
console.log('获得快递箱失利,跳过', err)
}
console.log('出有可主动完成的使命了,退出。')
console.log('互动使命、下单使命需求脚动完成。')
if (startCoin && endCoin) {
console.log('本次运转得到' + (endCoin - startCoin) + '快递箱')
} else {
console.log('本次运转得到快递箱难以估计,详细缘故原由请翻阅日记。')
}
alert('使命已完成', '别记了正在剧本主页支付白包!')
quit()
}
if (taskText.match(/品牌墙/) || taskTitle.match(/种草乡/)) { // 品牌墙0/3只需求一次完成
taskCount = 1
}
// 按照taskCount停止使命,一类使命一同完成,完成后革新使命列表
console.log('停止' + taskCount + '次“' + taskText + '”类使命')
for (let i = 0; i < taskCount; i++) {
console.log('第' + (i + 1) + '次')
let taskFlag = doTask(taskButton, taskText, taskTitle)
if (text('已放进尾页>记载').exists()) {
console.log('封闭弹窗')
closePop()
sleep(3000)
}
if (taskFlag) {
console.log('完成,停止下一个使命')
} else {
console.log('使命失利,测验考试从头翻开使命列表获得使命')
break // 间接退出,无需正在此挪用reopen
}
}
console.log('从头翻开使命列表获得使命')
reopenTaskList()
}
} catch (err) {
device.cancelKeepingAwake()
if (err.toString() != 'JavaException: com.stardust.autojs.runtime.exception.ScriptInterruptedException: null') {
console.error(err)
startCoin && console.log('本次使命开端时有' + startCoin + '快递箱')
}
}
【回复下载】:请于二十四小时内删除本程序/源码,本程序/源码仅供交流学习使用!程序/源码转载于网络!
通知十一群627570069
通知十群741328236
通知三群822201037
通知八群835756660
通知四群833343732
通知九群833384899
通知七群489922240
|
|