3 Star 0 Fork 0

asst_tech/gdt_hb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
去嗨皮.js 3.73 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");
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
}
// 点击控件坐标,控件的clickbale为false的时候
function 点击控件(x) {
var weight = x.bounds()
click(weight.centerX(), weight.centerY())
}
// 随机向上滑动
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());
}
function task() {
var 跳过广告 = text("跳过广告").findOne(15000);
if(跳过广告){
click(跳过广告.bounds().centerX(),跳过广告.bounds().centerY());
sleep(2000)
}
var 行程 = text("行程").find(30000)[1]; //webView中存在 多个行程 log(text("行程").find().size())
if(行程){
click(行程.bounds().centerX(),行程.bounds().centerY())
utils.updateAppProgress(10);
sleep(5000)
var 精彩推荐 = text("精彩推荐").findOne(50000).parent().children();
for(var idx = 0; idx<精彩推荐.size() ; idx ++){
var element = 精彩推荐[idx];
if(element.indexInParent() <5) continue ;
log("indexInParent:" + element.indexInParent())
element.click();
sleep(5000);
if(text("已完成今日签到").findOne(1000)){
toastLog("已完成今日签到")
break ;
}
var 签到 = text("签到").findOne(10000);
if(签到){
var finalActivity = currentActivity()
签到.click();
toastLog("当前是广告界面")
utils.waitAdvert(finalActivity);
if((idx+1) * 30 < 100){
utils.updateAppProgress((idx+1) * 30);
}
}
back();
sleep(2000)
};
}
}
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