3 Star 0 Fork 0

asst_tech/gdt_hb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
掌上宝短视频.js 10.26 KB
一键复制 编辑 原始数据 按行查看 历史
落尘 提交于 2020-11-08 01:41 . 脚本修改,为测试兼容utils.js
if(files.cwd().endsWith("脚本")){
let _require = require;
require = function(path){
if(path.startsWith("./")){
path = path.replace("./","");
}
path = files.cwd() + "/gdt_hb/" + path;
return _require(path);
}
}
auto.waitFor()
var utils = require("./utils.js");
var storage = storages.create("xiangxiangyuedu");
var time = random(2000, 3000)
function launchAppEnhance(app_name) {
let thread = threads.start(function () {
toastLog("检查是否有打开权限!")
while (true) {
var allow = text("允许").findOne(5000)
if (allow) {
sleep(1000)
toastLog("发现允许授权!")
allow.click()
sleep(1000)
thread.interrupt()
break
}
}
})
sleep(1000)
var result = launchApp(app_name)
sleep(3000)
thread.interrupt()
return result
}
function 观看咨询() {
var 进度 = id("ocpv_progress").findOne(2000);
while (进度 == null) {
swip_up();
进度 = id("ocpv_progress").findOne(2000);
}
while (id("ocpv_progress").findOne(2000) != null) {
sleep(2000);
}
}
// 随机向上滑动
function swip_up() {
var w = device.width
var h = device.height
function bezier_curves(cp, t) {
cx = 3.0 * (cp[1].x - cp[0].x);
bx = 3.0 * (cp[2].x - cp[1].x) - cx;
ax = cp[3].x - cp[0].x - cx - bx;
cy = 3.0 * (cp[1].y - cp[0].y);
by = 3.0 * (cp[2].y - cp[1].y) - cy;
ay = cp[3].y - cp[0].y - cy - by;
tSquared = t * t;
tCubed = tSquared * t;
result = { "x": 0, "y": 0 };
result.x = (ax * tCubed) + (bx * tSquared) + (cx * t) + cp[0].x;
result.y = (ay * tCubed) + (by * tSquared) + (cy * t) + cp[0].y;
return result;
};
function sml_move(qx, qy, zx, zy, time) {
//仿真随机带曲线滑动: qx, qy, zx, zy, time 代表起点x,起点y,终点x,终点y,过程耗时单位毫秒
var xxy = [time];
var point = [
{ "x": qx, "y": qy },
{ "x": random(qx - 100, qx + 100), "y": random(qy, qy + 50) },
{ "x": random(zx - 100, zx + 100), "y": random(zy, zy + 50) },
{ "x": zx, "y": zy }
];
for (let i = 0; i < 1; i += 0.08) {
xxyy = [parseInt(bezier_curves(point, i).x), parseInt(bezier_curves(point, i).y)]
xxy.push(xxyy);
}
gesture.apply(null, xxy);
}
sml_move(w / 2, h * 0.8 + h * random() * 0.1, w / 2, h * 0.15, 200 + 600 * random());
}
// 点击控件坐标,控件的clickbale为false的时候
function 点击控件(x) {
var weight = x.bounds()
click(weight.centerX(), weight.centerY())
}
function 广告() {
let try_count = 13, close_btn = null;
while (!close_btn) {
if (try_count <= 0) {
break
}
sleep(1000)
var otherPage = className('android.view.View').depth(6).drawingOrder(1).findOne(1000)
if (otherPage) {
otherPage.click();
}
// 直到找到关闭按钮
close_btn = idContains("ad_close").findOne(1000) ||
className('android.widget.ImageView').clickable().depth(5).drawingOrder(2).findOne(1000)
if (close_btn) {
close_btn.click()
sleep(time)
break
} else {
try {
var closeBtn = className('android.widget.RelativeLayout').depth(4).drawingOrder(7).findOne(1000)
if (closeBtn) {
点击控件(closeBtn)
break
}
} catch (error) {
}
try {
取消 = text("取消").findOne(500)
if (取消) {
点击控件(取消)
}
} catch (error) { }
try {
关闭 = text("关闭").findOne(500)
if (关闭) {
点击控件(关闭)
}
} catch (error) { }
try {//支付宝
if (currentPackage() != 'com.bogokjvideo.videoline') {
toastLog('估计是进入支付宝页面了')
sleep(2000)
back()
sleep(2000)
继续 = textStartsWith("继续").findOne(1000)
if (继续) {
点击控件(继续)
}
var 每日任务 = text('每日任务').findOne(3000)
if (每日任务) {
break
}
}
} catch (error) { }
}
try_count--
sleep(2000)
}
}
//九宫格
function viewSudokuVideoAndBack() {
var i = 1;
waitForActivity("com.bogokjvideo.video.ui.TaskTopicActivity", 200);
while (text("看视频").findOne(2000) != null) {
var finalActivity = currentActivity();
text("看视频").findOne(2000).click();
toastLog("观看第" + i + "个激励视频");
utils.waitActivityChange();
utils.waitAdvert(finalActivity);
toastLog("观看第" + i + "个激励视频结束");
sleep(2000);
toastLog("点击我知道了");
var 我知道了 = text("我知道了").findOne(60000);
我知道了 && 我知道了.click();
console.log("点击: img_task_close");
sleep(2000);
var close_1 = id("img_task_close").findOne(60000)
if (close_1) {
utils.realClick(close_1);
}
waitForActivity("com.bogokjvideo.video.ui.TaskTopicActivity", 200);
sleep(2000);
i++
}
back();
}
function task() {
let thread = threads.start(function () {
while (true) {
var ad = id("home_ad_close_btn").findOne(500)
ad && ad.click();
var close = id("tt_insert_dislike_icon_img").findOne(500)
close && close.click();
var 取消 = id("md_buttonDefaultNegative").findOne(500);
取消 && 取消.click();
var ad_close = className("android.view.View").clickable().depth(9).drawingOrder(0).findOne(500);
if (ad_close) {
back();
}
var close_1 = id("img_task_close").findOne(500)
if (close_1) {
click(close_1.bounds().centerX(), close_1.bounds().centerY());
}
}
})
toastLog("开始刷10个视频 让进度条出现");
for(var i = 0; i < 10; i++){
swip_up();
sleep(random(5000,6000));
}
toastLog("刷完10个视频");
utils.updateAppProgress(20);
var finalActivity = currentActivity();
while (true) {
console.log("继续滑动");
if(!id("progress_bar_time").findOne(2000)){
//进度条已消失
break;
}
swip_up();
sleep(random(6000, 7500));
var 完成 = text("完成").findOne(1000);
if (完成) {
sleep(1000);
完成.click();
break;
}
//判断进度条是否存在
}
//关闭广告
utils.waitAdvert(finalActivity);
sleep(2000);
//TODO 领取龙珠
images.findImage()
back();
sleep(1000);
toastLog("进行签到");
var 签到按钮 = id("qiandao_btn").findOne();
签到按钮.click();
toastLog("等待广告");
utils.waitAdvert();
toastLog("广告关闭成功");
sleep(2000);
toastLog("点击我知道了");
var 我知道了 = text("我知道了").findOne(6000);
我知道了 && 我知道了.click();
sleep(2000);
toastLog("进行第一个任务:激励视频");
var 激励视频 = text('激励视频').findOne(1000)
if (激励视频) {
var 去完成 = 激励视频.parent().parent().findOne(text('去完成'))
if(去完成){
//判断是否是九宫格
var progress = id("ad_look_num").findOne(2000);
if(progress){
progress = progress.text().split("/");
progress = {
cur:parseInt(progress[0]),
max:parseInt(progress[1])
}
if(progress.max == 9){
finalActivity = currentActivity();
//九宫格模式
去完成.click();
sleep(2000);
viewSudokuVideoAndBack(finalActivity);
}else{
//不是九宫格模式
var point = {
x:去完成.bounds().centerX(),
y:去完成.bounds().centerY()
}
for (var i = 0; i < (progress.max - progress.cur); i++) {
click(point.x, point.y);
utils.waitAdvert();
var 我知道了 = text("我知道了").findOne(10000);
sleep(1000);
我知道了 && 我知道了.click();
sleep(2000);
}
utils.updateAppProgress(40);
}
}else{
//获取不到进度
}
}
toastLog("完成第一个任务:激励视频");
}
sleep(2000);
var 新闻资讯 = text('新闻资讯').findOne(1000)
toastLog("进行第二个任务:新闻资讯");
if (新闻资讯) {
var parent = 新闻资讯.parent().parent();
var 去完成 = parent.findOne(text('去完成'))
while (去完成) {
去完成.click();
sleep(2000);
观看咨询();
id("iv_back").findOne().click();
var 我知道了 = text("我知道了").findOne(10000);
我知道了 && 我知道了.click();
sleep(2000);
去完成 = parent.findOne(text('去完成'))
}
}
toastLog("完成第二个任务:新闻资讯");
utils.updateAppProgress(60);
sleep(2000);
toastLog("进行第三个任务:广告任务");
var 广告任务 = text('广告任务').findOne(1000)
if (广告任务) {
var 去完成 = 广告任务.parent().parent().findOne(text('去完成'))
if(去完成){
//判断是否是九宫格
var progress = id("ad_look_num").findOne(2000);
if(progress){
progress = progress.text().split("/");
progress = {
cur:parseInt(progress[0]),
max:parseInt(progress[1])
}
finalActivity = currentActivity();
if(progress.max == 9){
//九宫格
去完成.click();
sleep(2000);
viewSudokuVideoAndBack(finalActivity);
}else{
var point = {
x:去完成.bounds().centerX(),
y:去完成.bounds().centerY()
}
for (var i = 0; i < (progress.max - progress.cur); i++) {
click(point.x, point.y);
utils.waitAdvert();
var 我知道了 = text("我知道了").findOne(10000);
sleep(1000);
我知道了 && 我知道了.click();
sleep(2000);
}
}
}else{
//获取不到进度
}
}
toastLog("完成第三个任务:广告任务");
utils.updateAppProgress(80);
}
thread.interrupt();
}
function main() {
let open_app = launchAppEnhance("掌上宝短视频");
if (open_app) {
task()
}
else {
toastLog("掌上宝短视频打开失败,请确认是否安装并授权打开!");
}
}
try {
main();
utils.updateAppProgress(100);
} catch (error) {
toastLog(error);
}
storage.put("script_running_status", "end");
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/asst_tech/gdt_hb.git
git@gitee.com:asst_tech/gdt_hb.git
asst_tech
gdt_hb
gdt_hb
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385