diff --git a/zq/zq.js b/zq/zq.js index eab47bc..079e09e 100644 --- a/zq/zq.js +++ b/zq/zq.js @@ -8,6 +8,7 @@ function start () { console.info("启动中青看点"); } console.show(); + viewTask(); } /** @@ -32,7 +33,7 @@ function randomClickObject (obj) { function getById (maxIndex, name) { for (let index = 0; index < maxIndex; index++) { - console.verbose(index, name); + // console.verbose(index, name); var t = id(name).findOnce(); if (t != undefined) return t; @@ -42,33 +43,41 @@ function getById (maxIndex, name) { return null; } -for (var i = 1; i < 500; i++) { - sleep(1000); - console.log("下滑!") - gesture(400, [520, 1550], [520, 450]); - sleep(1000); - var youth = id("ah5").className("android.widget.TextView").findOnce(0) - || id("a03").className("android.widget.LinearLayout").findOnce(0) - || id("ail").className("android.widget.TextView").findOnce(0); +function viewTask () { + for (var i = 1; i < 500; i++) { + sleep(1000); + console.log("下滑!") + gesture(400, [520, 1550], [520, 450]); + sleep(1000); + var y1 = id("ah5").className("android.widget.TextView").findOnce(1); + var y2 = id("a03").className("android.widget.LinearLayout").findOnce(1); + var y3 = id("ah5").className("android.widget.TextView").findOnce(0); + var y4 = id("a03").className("android.widget.LinearLayout").findOnce(0); + var y5 = id("ail").className("android.widget.TextView").findOnce(0); - sleep(200); + // console.log("y1=", (y1 == undefined), "y2=", (y2 == undefined), "y3=", (y3 == undefined), "y4=", (y4 == undefined), "y5=", (y5 == undefined)) + var youth = y1 || y2 || y3 || y4 || y5; - if (youth == undefined) { - console.log(i, "未找到!") - continue; - } - try { - console.log(i, youth.text()); - randomClickObject(youth); - // var youok = youth.bounds(); - // var a = youok.centerX(); - // var b = youok.centerY(); - // click(a, b); - sleep(1000); - var taskBtn = getById(2, 'cn.youth.news:id/x8'); - if (taskBtn == undefined) - back(); - } catch (error) { + sleep(200); + + if (youth == undefined) { + console.log(i, "未找到!") + continue; + } + + try { + console.log(i, youth.text()); + randomClickObject(youth); + // var youok = youth.bounds(); + // var a = youok.centerX(); + // var b = youok.centerY(); + // click(a, b); + sleep(1000); + var taskBtn = getById(4, 'cn.youth.news:id/x8'); + if (taskBtn == undefined) + back(); + } catch (error) { + } } } \ No newline at end of file diff --git a/zq/zqkkz.js b/zq/zqkkz.js index 09a3e53..aaa75b9 100644 --- a/zq/zqkkz.js +++ b/zq/zqkkz.js @@ -1,6 +1,8 @@ var allTasks = ['温暖生活', '实时剧情', '朵朵浪花', '闪光热点', '阳光生活', '热点天下', '资讯播报']; let taskText = ''; +// 美好生活 debug + start(); function start () { @@ -145,16 +147,17 @@ function viewTask (task) { closeAd(); - var link = boundsInside(10, 300, device.width, device.height).packageName('cn.youth.news').className('android.view.View').clickable().findOnce() - || boundsInside(10, 300, device.width, device.height).packageName('cn.youth.news').className('android.widget.Image').clickable().findOnce(); - + var l1 = boundsInside(10, 300, device.width, device.height).packageName('cn.youth.news').className('android.view.View').clickable().findOnce(); + var l2 = boundsInside(10, 300, device.width, device.height).packageName('cn.youth.news').className('android.widget.Image').clickable().findOnce(); + var link = l1 || l2; if (link == undefined) { console.log(' ', i, '未找到连接'); } else { let linkText = link.text() || link.contentDescription || ""; linkText = linkText.length > 8 ? linkText.substring(0, 8) : linkText; - console.log(' ', i, "link ", linkText.length, " ", linkText); + // console.log(' ', i, "link ", linkText.length, " ", linkText); + console.log(' ', i, "link ", linkText); if (linkText.indexOf && linkText.indexOf('广告') > -1) { continue; diff --git a/zq/zqllz.js b/zq/zqllz.js new file mode 100644 index 0000000..fd284ea --- /dev/null +++ b/zq/zqllz.js @@ -0,0 +1,153 @@ +start(); + +function start () { + auto.waitFor() + var appName = "cn.youth.news"; + if (launch(appName)) { + console.info("启动中青看点"); + } + console.show(); + llz(); + exit(); +} + +//浏览赚 +function llz () { + console.clear(); + + if (text('看看赚').findOnce() == undefined) { + console.log('未在看看赚页面,后退'); + back(); + } + + var goBtn = text('浏览赚').findOnce(); + if (goBtn == undefined) { + console.warn('未找到 浏览赚 进入按钮,结束'); + return; + } + + randomClickObject(goBtn); + + sleep(3000); + + //等待页面出现 + if (text('去白拿').findOne(18 * 1000) == undefined) { + console.warn('未找到 浏览赚 的任务'); + return; + } + + //任务列表 + var items = text('去白拿').find(); + if (items == undefined || items.length == 0) { + console.warn('未找到 浏览赚 的任务'); + return; + } + + console.warn("开始 浏览赚 任务", items.length); + for (let index = 0; index < items.length; index++) { + + if (text('去白拿').findOnce() == undefined) { + console.warn(" ", index, "未在 去白拿 页面,后退"); + back(); + sleep(2000); + } + + var item = text('去白拿').findOnce(index); + if (item == undefined) { + console.warn(" ", index, "未找到"); + sleep(500); + continue; + } + var taskText = item.parent().child(item.indexInParent() - 2).text(); + + if (taskText == '热闻漫谈') { + console.warn(" ", index, "任务 ", taskText, '跳过'); + continue; + } + + console.warn(" ", index, "任务 ", taskText); + + randomClickObject(item); + + sleep(2000); + + console.log(" ", index, "后退") + + back() + sleep(2000); + + // if (textContains('去白拿').findOne() == undefined) { + + // } + } + console.warn("结束'去搜索'任务"); +} + +function getById (maxIndex, name) { + for (let index = 0; index < maxIndex; index++) { + console.verbose(index, name); + var t = id(name).findOnce(); + if (t != undefined) + return t; + sleep(500); + } + + return null; +} + + +function closeAd () { + var closeBtn = id('big_pic_close_btn').findOnce(); + if (closeBtn != undefined) { + console.log("点击广告关闭按钮"); + randomClickObject(closeBtn); + sleep(1300); + } + + closeBtn = id('btn-close').findOnce(); + if (closeBtn != undefined) { + console.log("点击广告关闭按钮"); + randomClickObject(closeBtn); + sleep(1300); + } + + closeBtn = idContains('gdt_template').findOnce(); + if (closeBtn != undefined) { + let rect = closeBtn.bounds(); + console.log("点击广告右上角按钮"); + randomClick(rect.right - 30, rect.top + 30); + sleep(1300); + } +} +/** + * 点击 + * @param {横坐标} x + * @param {纵坐标} y + */ +function randomClick (x, y) { + var rx = 0;// random(0, 5); + var ry = 0;//random(0, 5); + + click(x + rx, y + ry); + return true; +} + +/** + * 点击 + * @param {横坐标} x + * @param {纵坐标} y + */ +function randomClickObject (obj) { + var rx = 0;// random(0, 5); + var ry = 0;// random(0, 5); + + if (obj && obj.click) { + obj.click(); + } + + var rct = obj.bounds(); + click(rct.centerX() + rx, rct.centerY() + ry); + click(rct.centerX() + rx, rct.centerY() + ry); + click(rct.centerX() + rx, rct.centerY() + ry); + return true; +} \ No newline at end of file diff --git a/zq/zqssz.js b/zq/zqssz.js index 166e16d..b895c0f 100644 --- a/zq/zqssz.js +++ b/zq/zqssz.js @@ -58,16 +58,15 @@ function ssz () { back(); } - var goBtn = text('搜索赚').clickable().findOnce(); + var goBtn = text('搜索赚').findOnce(); if (goBtn == undefined) { console.warn('未找到搜索赚进入按钮,结束'); return; } randomClickObject(goBtn); - // goBtn.click(); - sleep(3000); + sleep(3000); //等待页面出现 if (text('去搜索').findOne(18 * 1000) == undefined) { @@ -76,7 +75,7 @@ function ssz () { } //任务列表 - var items = text('去搜索').clickable().find(); + var items = text('去搜索').find(); if (items == undefined || items.length == 0) { console.warn('未找到去搜索的任务'); // back(); @@ -86,31 +85,64 @@ function ssz () { console.warn("开始'去搜索'任务"); for (let index = 0; index < items.length; index++) { - var item = text('去搜索').clickable().findOnce(index); + if (text('去搜索').findOnce() == undefined) { + console.warn(" ", index, "未在 去搜索 页面,后退"); + back(); + sleep(2000); + } + + var item = text('去搜索').findOnce(index); if (item == undefined) { console.warn(" ", index, "未找到"); + sleep(500); continue; } - console.warn(" ", index, "去搜索任务 ", item.parent().child(1).text()); + console.warn(" ", index, "去搜索任务 ", item.parent().child(0).text()); randomClickObject(item); - if (text('step3').findOne(18 * 1000) != undefined) { + sleep(2000); + + if (textContains('今日热词').findOne(5 * 1000) != undefined) { sszViewTask(); } + else { + console.warn(" ", index, "未找到定位对象 今日热词 结束"); + } } + + console.warn("结束'去搜索'任务"); + } function sszViewTask () { + console.log(" 开始sszViewTask"); for (var i = 0; i < 12; i++) { - var task = className('android.view.View').clickable().filter(function (v) { - return v.text().length > 3; + //定位对象 + var pObject = textContains('今日热词').findOne(5 * 1000); + if (pObject == undefined) { + console.log(" ", i, "未找到定位对象 今日热词"); + back(); + console.log(" ", i, '后退'); + } + + let minY = 0 + try { + minY = pObject.bounds().bottom + 5; + } catch (error) { + console.log(" ", i, pObject); + continue; + } + + var task = className('android.view.View').filter(function (v) { + return v.text().length > 3 && v.bounds().bottom > minY; }).findOnce(); if (task == undefined) { console.log(" ", i, "未找到"); + sleep(500); continue; } @@ -118,14 +150,18 @@ function sszViewTask () { randomClickObject(task); sleep(1000); - if (text('step3').findOnce() == undefined) { + if (textContains('今日热词').findOnce(3 * 1000) == undefined) { + console.log(" ", i, '后退'); back(); sleep(2000); } + else { + console.warn("在 今日热词 不后退"); + } } //退回到主界面 - if (text('step3').findOnce() != undefined) { + if (textContains('今日热词').findOnce(3 * 1000) != undefined) { back(); sleep(2000); }