Skip to content

Commit

Permalink
Ad
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsterNone committed Nov 3, 2023
1 parent 5ea7c18 commit 3f5a09f
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 65 deletions.
27 changes: 16 additions & 11 deletions jd_hb.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const VERSION = '20231111-M'
const VERSION = '20231111-AD'

if (!auto.service) {
toast('无障碍服务未启动!退出!')
Expand Down Expand Up @@ -121,18 +121,18 @@ function openAndInto() {

// 打开任务列表
function openTaskList() {
let anchor = textMatches(/11111|今日机会[\s\S]*/).findOne(10000)
let anchor = textMatches(/(活动时间:|今日机会)[\s\S]*/).findOne(10000)
if (!anchor) {
console.log('无法找到弹窗标识1,退出')
quit()
}
if (anchor.text() == '11111') {
if (anchor.text().match(/活动时间:[\s\S]*/)) {
console.log('点击打开任务列表1')
let tmp = anchor.parent().parent()
tmp.child(tmp.childCount() - 1).click()
}

anchor = text('立即领取').findOne(10000)
anchor = textMatches(/立即领取|查看进度/).findOne(10000)
if (!anchor) {
console.log('无法找到弹窗标识2,退出')
quit()
Expand Down Expand Up @@ -191,7 +191,7 @@ function reopenTaskList() {
console.log('重新打开任务列表失败,退出')
quit()
}
sleep(5000)
sleep(1000)
}

// --------------------------------------------
Expand Down Expand Up @@ -250,13 +250,8 @@ try {
console.log('任务列表已打开,开始任务')

const tasks = findTimeout(textMatches(/去完成|已完成/), 5000)
if (!tasks) {
console.log('未找到任务,退出')
quit()
}
for (let task of tasks) {
if (task.text() == '已完成') continue
console.log(task)

// press(task.bounds().centerX(), task.bounds().centerY(), 1500)
console.log('尝试进入任务')
Expand All @@ -281,8 +276,18 @@ try {
backToList()
// reopenTaskList()
}
// let share = text('去分享').findOne(3000)
// if (share) {
// console.log('进行分享任务')
// task.click()
// if (textContains('分享好友一起').findOne(3000)) {
// click(200, 300)
// } else {
// console.log('未找到分享弹窗,失败')
// }
// }
console.log('任务已经全部完成,退出')
alert('记得手动完成分享任务并领取打卡红包!')
alert('记得手动分享领取打卡红包并抽盲盒!')
} catch (err) {
device.cancelKeepingAwake()
if (err.toString() != 'JavaException: com.stardust.autojs.runtime.exception.ScriptInterruptedException: null') {
Expand Down
9 changes: 7 additions & 2 deletions start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const VERSION = '20231111-N'
const VERSION = '20231111-AD'

if (!auto.service) {
toast('无障碍服务未启动!退出!')
Expand Down Expand Up @@ -154,7 +154,7 @@ try {
return findTask()
}
console.log(taskName, '"' + content + '"')
if (!(taskName.match(/首页|提醒|开通|捕鱼|续费|乐园|斗地主|消消|流浪猫|开88|扔喵币|占领|邀请|登录|组队|参与|施肥|浇水|特价版|小鸡|消除|穿搭|森林|点淘|人生|我的淘宝|庄园|支付宝|点击人物|省钱卡|年卡|积分|答题|分享|订阅|连连消|月月有余|守护/))) {
if (!(taskName.match(/首页|提醒|开通|捕鱼|续费|乐园|斗地主|消消|流浪猫|开88|扔喵币|占领|邀请|登录|组队|参与|施肥|浇水|特价版|小鸡|消除|穿搭|森林|点淘|人生|我的淘宝|庄园|支付宝|点击人物|省钱卡|年卡|积分|答题|分享|订阅|连连消|月月有余|守护|大作战/))) {
// 应对content为空的情况
if (content) {
if (content.match(/浏览|点击|小游戏/)) {
Expand Down Expand Up @@ -231,6 +231,11 @@ try {
console.log('异常退出。')
quit()
}
if (textMatches(/.*版本.*低.*/).exists()) {
alert('触发淘宝版本问题', '避免死循环,退出')
console.log('异常退出。')
quit()
}
if (textContains('互动奖励').exists() ||
descContains('互动奖励').exists()) {
console.log('跳过互动任务')
Expand Down
123 changes: 71 additions & 52 deletions tb_huichang.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const VERSION = '20231111-M'
const VERSION = '20231111-AD'

if (!auto.service) {
toast('无障碍服务未启动!退出!')
Expand Down Expand Up @@ -116,7 +116,7 @@ try {

// 打开任务列表
function openTaskList() {
let c = idContains('node_2_icon').findOne(5000)
let c = idMatches(/node_\d_icon/).findOne(5000)
if (c) {
console.log('使用默认方法尝试打开任务列表')
c.click()
Expand Down Expand Up @@ -190,7 +190,7 @@ try {
// return findTask()
// }
console.log(taskName)
if (!(taskName.match(/天猫超市/))) {
if (!(taskName.match(/天猫超市|下单|施肥/))) {
return [taskName, jumpButtons[i]]
}
}
Expand Down Expand Up @@ -248,16 +248,73 @@ try {
return true
}

function itemTask() {
console.log('等待页面')
if (!textContains('精选热卖').findOne(8000)) {
throw '商品页面未加载'
}

let n = 0
while (true) {
let done = idContains('J_wf_node_2_time').findOne(5000)
if (!done) {
console.log('浏览商品任务完成,返回')
return
}
done = parseInt(done.text(), 10)

if (n < done) n = done
console.log('循环完成任务,已点击', done, '个')
let buttons = textMatches(/.*q75.*/).find()
if (buttons.empty()) {
throw '无法找到商品,任务失败'
}
console.log(n, buttons.length)
for (let i = 0; i < 10 && n + 1 > buttons.length; i++) {
console.log('商品数量不足,', n + 1, '向下翻页')
scrollDown()
sleep(2000)
scrollDown()
sleep(2000)
buttons = textMatches(/.*q75.*/).find()
console.log(buttons.length)
}

for (let i = 0; i < buttons.length; i++) {
console.log('点击第', i + 1, '个')
sleep(2000)
buttons[i].click()
console.log('等待加载')
if (textMatches(/加入购物车|粉丝福利购/).findOne(10000) || currentActivity() == 'com.taobao.android.detail.wrapper.activity.DetailActivity') {
console.log('商品打开成功,返回')
back()
if (!textContains('精选热卖').findOne(10000)) {
console.log('似乎没有返回,二次尝试')
back()
}
} else {
throw '商品页未能加载'
}
n++
done = idContains('J_wf_node_2_time').findOne(5000)
if (!done) {
console.log('浏览商品任务完成,返回')
return
}
}
}
}

// TODO:
function backToList() {
console.log('返回上级')
if (idContains('node_2_icon').exists()) {
if (idMatches(/node_\d_icon/).exists()) {
console.log('已在任务列表')
return
}
back()
for (let i = 0; i < 3; i++) {
if (!idContains('node_2_icon').findOne(5000)) {
if (!idMatches(/node_\d_icon/).findOne(5000)) {
console.log('似乎没有返回,二次尝试')
back()
} else {
Expand All @@ -281,7 +338,7 @@ try {
} else {
console.log('请在30秒内打开淘宝做任务赢红包活动页 88¥ CZ3457 yRhaW1EFDJB¥ https://m.tb.cn/h.5SjTGhB')
}
if (!idContains('node_2_icon').findOne(30000)) {
if (!idMatches(/node_\d_icon/).findOne(30000)) {
console.log('未能检测到任务页,退出')
quit()
}
Expand Down Expand Up @@ -334,54 +391,11 @@ try {
console.log('进行' + jumpButton[0] + '任务')
sleep(2000)

if (jumpButton[0].match(/商品/)) {
if (jumpButton[0].match(/个商品/)) {
jumpButton[1].click()
sleep(2000)
let count = jumpButton[0].match(/浏览(\d*)个/)[1]
console.log('等待页面')
if (!textContains('精选热卖').findOne(8000)) {
throw '商品页面未加载'
}
try {
count -= idContains('J_wf_node_2_time').findOne(5000).text()
} catch (err) {
console.log('获取数量失败,使用默认值', err)
}
console.log('点击', count, '个商品')
let buttons = textContains('q75').find()
if (!buttons) {
throw '无法找到商品,任务失败'
}
for (let i = 0; i < 10 && count > buttons.length; i++) {
console.log('商品数量不足,向下翻页', buttons.length)
scrollDown()
sleep(2000)
scrollDown()
sleep(2000)
buttons = textContains('q75').find()
console.log(buttons.length)
}
if (count > buttons.length) {
console.log('商品数量不足,分次完成')
count = buttons.length
}

for (let i = 0; i < count; i++) {
console.log('点击第', i + 1, '个')
sleep(2000)
buttons[i].click()
console.log('等待加载')
if (textMatches(/加入购物车|粉丝福利购/).findOne(10000) || currentActivity() == 'com.taobao.android.detail.wrapper.activity.DetailActivity') {
console.log('商品打开成功,返回')
back()
if (!textContains('精选热卖').findOne(10000)) {
console.log('似乎没有返回,二次尝试')
back()
}
} else {
throw '商品页未能加载'
}
}
console.log('使用新版大循环方法完成')
itemTask()
// sleep(1000)
backToList()
} else if (jumpButton[0].match(/搜索/)) {
Expand All @@ -408,6 +422,11 @@ try {
} else if (jumpButton[0].match(/为你推荐|主会场/)) {
jumpButton[1].click()
liulan()
} else if (jumpButton[0].match(/消消乐|羊毛|淘金币/)) {
jumpButton[1].click()
console.log('参观任务,自动返回')
sleep(2000)
backToList()
} else {
jumpButton[1].click()
liulan()
Expand Down

0 comments on commit 3f5a09f

Please sign in to comment.