很长一段时间在忙
而且部分脚本源码价值过高不便于分享
今晚给大家带来一款薅羊毛脚本合集的源码
免得大家以为我失踪了
希望大家喜欢
脚本合集仅供参考借鉴线程以及界面
部分功能由于时间问题呢没有去写
望体谅!
AutoJsPro,JavaScript收徒!
有技术问题需要请教可联系我:
微信:LGD-Lang
QQ:1340468168
"ui";
var 本地 = storages.create("造雾社区-游阅集合卡密")
var x = device.width
var y = device.height
if (本地.get("账号") && 本地.get("密码")) {
toast("欢迎再次用本软件")
if (验证(本地.get("账号"), 本地.get("密码")) == "失败") {
登录()//卡密验证界面
} else {
主界面()//脚本主线程
}
} else {
toast("欢迎使用本软件")
登录()//卡密验证界面
}function 登录() {
ui.layout(
<vertical gravity="center" bg="#708090">
<card w="*" h="auto" margin="20" cardCornerRadius="15dp" cardBackgroundColor="#b0c4de"
cardElevation="15dp" gravity="bottom" foreground="?selectableItemBackground">
<vertical>
<linear margin="40 10 40 10">
<img w="50" h="50" src="@drawable/ic_account_circle_black_48dp"/>
<ImageView/>
<input id="账号" w="*" h="50" hint="请输入账号"/>
</linear>
<linear margin="40 10 40 10">
<img w="50" h="50" src="@drawable/ic_lock_outline_black_48dp"/>
<ImageView/>
<input id="密码" w="*" h="50" hint="请输入密码" inputType="textVisiblePassword"/>
</linear>
<linear gravity="center">
<horizontal>
<button id="登录" w="250" h="*" text="登录" size="16" style="Widget.AppCompat.Button.Colored"/>
</horizontal>
</linear>
<linear gravity="center">
<horizontal>
<button id="购买账号" w="250" h="*" text="购买账号" size="16" style="Widget.AppCompat.Button.Colored"/>
</horizontal>
</linear>
<linear gravity="center" margin="0 0 0 20">
<horizontal>
<button id="联系作者" w="250" h="*" text="联系作者" size="16" style="Widget.AppCompat.Button.Colored"/>
</horizontal>
</linear>
</vertical>
</card>
</vertical>
);ui.登录.on("click", () => {
if (!ui.账号.text() && !ui.密码.text()) {
toast("请先输入账号密码")
} else {
验证(ui.账号.text(), ui.密码.text())
}
})ui.购买账号.on("click", () => {
toast("请联系作者购买")
app.startActivity({
action: "android.intent.action.VIEW",
data: "mqq://im/chat?chat_type=wpa&version=1&src_type=web&uin=1340468168",
packageName: "com.tencent.mobileqq",
})
})ui.联系作者.on("click", () => {
app.startActivity({
action: "android.intent.action.VIEW",
data: "mqq://im/chat?chat_type=wpa&version=1&src_type=web&uin=1340468168",
packageName: "com.tencent.mobileqq",
})
})
}function 验证(账号, 密码) {
let APP = "10003"
let url = "http://ilscis.xyxdie.com/api.php?act=user_logon&app=" + APP;
let res = http.post(url, {
"account": 账号, //卡密
"password": 密码,
"markcode": device.getAndroidId(),
"t": Date.parse(new Date()), //时间戳
"sign": "",
});let json = JSON.parse(res.body.string());
if (json.code == "200") {
toast("登录成功")
本地.put("账号", 账号)
本地.put("密码", 密码)
主界面()
return "成功"
} else {
toast("登录失败\n原因:" + json.msg)
return "失败"
}
}
function 主界面() {
//#region UI
var rootUrl = "http://ilscripts.xyxd.ltd/";
var storaySign = "258697304@qq.com";
var woolStorage = storages.create(storaySign); //创建本地存储
//视频类
var 视频类APP集合 = new Array("快手极速版", "抖音极速版");
//综合类
var 综合类APP集合 = new Array();
var 游戏类APP集合 = new Array();
//五日签到页面var appArray = [];
concatArray(concatArray(concatArray(appArray, 综合类APP集合), 游戏类APP集合), 视频类APP集合);
var havedVideoChecked = new Map(); //已经被选择的小视频集合
var havedTaskChecked = new Map(); //已经被选择的综合类集合
var havedyxChecked = new Map(); //已经被选择的游戏类集合
var videoAndStoryThread = null;
var videoSignThread = null;
var videoItems = []; //小视频集合
var taskItems = []; //综合类集合ui.layout(
<frame>
<img src="file://res/背景图.jpg" h="{{y}}px" alpha='0.9' />
<vertical>
<appbar gravity="center" bg="#000000" h="250px">
<text text="造雾社区-游阅集合" textColor="white" gravity="center" textSize="15dp"/>
<tabs id="tabs"/>
</appbar>
<viewpager id="主菜单" >
<frame>
<scroll>
<vertical gravity="center">
<list id="videoList">
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
<horizontal gravity="center_vertical">
<horizontal h="auto" w="0" layout_weight="1">
<text id="appIndex" text="{{this.AppIndex}}." inputType="number" padding="8 8 8 8" w="50" gravity="center" />
<text id="appName" text="{{this.AppName}}" textColor="#222222" textSize="16sp" maxLines="1" />
</horizontal>
<checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" />
</horizontal>
</card>
</card>
</list>
{/* 占位符 */}
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
</card>
</card>
</vertical>
</scroll>
<horizontal gravity="right|bottom">
<button style="Widget.AppCompat.Button.Colored" id="allCheck1" text="全选已装" padding="12dp" w="auto" />
<button style="Widget.AppCompat.Button.Colored" id="woolVideo" text="启动" padding="12dp" w="auto" />
</horizontal>
</frame>
<frame>
<scroll>
<vertical gravity="center">
<list id="taskList">
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
<horizontal gravity="center_vertical">
<horizontal h="auto" w="0" layout_weight="1">
<text id="appIndex" text="{{this.AppIndex}}." inputType="number" padding="8 8 8 8" w="50" gravity="center" />
<text id="appName" text="{{this.AppName}}" textColor="#222222" textSize="16sp" maxLines="1" />
</horizontal>
<checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" />
</horizontal>
</card>
</card>
</list>
{/* 占位符 */}
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
</card>
</card>
</vertical>
</scroll>
<horizontal gravity="right|bottom">
<button style="Widget.AppCompat.Button.Colored" id="allCheck2" text="全选已装" padding="12dp" w="auto" />
<button style="Widget.AppCompat.Button.Colored" id="execTask" text="启动" padding="12dp" w="auto" />
</horizontal>
</frame>
<frame>
<scroll>
<vertical gravity="center">
<list id="yxList">
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
<horizontal gravity="center_vertical">
<horizontal h="auto" w="0" layout_weight="1">
<text id="appIndex" text="{{this.AppIndex}}." inputType="number" padding="8 8 8 8" w="50" gravity="center" />
<text id="appName" text="{{this.AppName}}" textColor="#222222" textSize="16sp" maxLines="1" />
</horizontal>
<checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" />
</horizontal>
</card>
</card>
</list>
{/* 占位符 */}
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
</card>
</card>
</vertical>
</scroll>
<horizontal gravity="right|bottom">
<button style="Widget.AppCompat.Button.Colored" id="allCheck3" text="全选已装" padding="12dp" w="auto" />
<button style="Widget.AppCompat.Button.Colored" id="execTask" text="启动" padding="12dp" w="auto" />
</horizontal>
</frame>
<frame>
<scroll>
<vertical gravity="center">
<list id="xzList">
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
<horizontal gravity="center_vertical">
<horizontal h="auto" w="0" layout_weight="1">
<text id="appIndex" text="{{this.AppIndex}}." inputType="number" padding="8 8 8 8" w="50" gravity="center" />
<text id="appName" text="{{this.AppName}}" textColor="#222222" textSize="16sp" maxLines="1" />
</horizontal>
<checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" />
</horizontal>
</card>
</card>
</list>
{/* 占位符 */}
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
</card>
</card>
</vertical>
</scroll>
<horizontal gravity="right|bottom">
<button style="Widget.AppCompat.Button.Colored" id="allCheck" text="下载选中" padding="12dp" w="auto" />
</horizontal>
</frame>
<frame>
<scroll>
<vertical>
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
<Switch id="wza" text="开启无障碍权限" checked="{{auto.service != null}}" textColor="#222222" padding="8 8 8 8" textSize="15sp" />
</card>
</card>
<card w="*" h="40" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="36" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
<Switch id="xfc" text="开启悬浮窗权限" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="15sp" textColor="#222222" />
</card>
</card>
<card w="*" h="auto" cardBackgroundColor="#000000" margin="1 1 1 1" cardElevation="1dp" gravity="center_vertical" alpha="0.6" cardCornerRadius="3dp">
<card w="*" h="auto" cardCornerRadius="2dp" margin="2" cardElevation="1dp" gravity="center_vertical" alpha="1" cardCornerRadius="1">
<text text="视频类配置" gravity="center" textColor="red" />
</card>
</card>
</vertical>
</scroll>
</frame>
</viewpager>
</vertical>
</frame>
);//设置滑动页面的标题
ui.主菜单.setTitles(["视频类", "综合类", "游戏类", "下载软件", "脚本配置"]);
//让滑动页面和标签栏联动
ui.tabs.setupWithViewPager(ui.主菜单);initializeUI()
/**
* 全选事件
*/
ui.allCheck1.click(function() {
let newVideoItems = [];
for (let i = 0; i < videoItems.length; i++) {
if (getPackageName(videoItems[i].AppName)) {
var row = {
AppName: videoItems[i].AppName,
AppIndex: videoItems[i].AppIndex,
done: true,
};
} else {
var row = {
AppName: videoItems[i].AppName,
AppIndex: videoItems[i].AppIndex,
done: true,
};
}
newVideoItems.push(row);
}
videoItems = newVideoItems;
ui.videoList.setDataSource(videoItems);
});ui.allCheck2.click(function() {
let newtaskItems = [];
for (let i = 0; i < taskItems.length; i++) {
if (getPackageName(taskItems[i].AppName)) {
log(getPackageName(taskItems[i].AppName))
var row = {
AppName: taskItems[i].AppName,
AppIndex: taskItems[i].AppIndex,
done: true,
};
} else {
var row = {
AppName: taskItems[i].AppName,
AppIndex: taskItems[i].AppIndex,
done: false,
};
}
newtaskItems.push(row);
}
taskItems = newtaskItems;
ui.taskList.setDataSource(taskItems);
});ui.allCheck3.click(function() {
let newVideoItems = [];
havedVideoChecked = new Map();
for (let i = 0; i < videoItems.length; i++) {
havedVideoChecked.put(videoItems[i].AppName, videoItems[i].AppIndex);
let row = {
AppName: videoItems[i].AppName,
AppIndex: videoItems[i].AppIndex,
done: true,
};
newVideoItems.push(row);
}
videoItems = newVideoItems;
ui.videoList.setDataSource(videoItems);
});
/**
* 视频线程
*/
ui.woolVideo.click(function() {
var appArray = mapSort(havedVideoChecked);
woolEvent(appArray);
});
/**
* 一键签到
*//*
界面配置
*/
function initializeUI() {
Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
}//视频类界面配置
for (let i = 0; i < 视频类APP集合.length; i++) {
let appName = 视频类APP集合[i];
let row = {
AppName: 视频类APP集合[i],
AppIndex: (i + 1),
done: false,
};
videoItems.push(row);
}
ui.videoList.setDataSource(videoItems);
//小视频绑定check事件
ui.videoList.on("item_bind", function(itemView, itemHolder) {
itemView.done.on("check", function(checked) {
let item = itemHolder.item;
item.done = checked;
let appName = item.AppName;
let appIndex = itemView.appIndex.getText();
item.AppIndex = appIndex;
if (checked) {
havedVideoChecked.put(appName, appIndex);
} else {
havedVideoChecked.remove(appName);
}
});
});
ui.videoList.on("item_click", function(item, i, itemView, listView) {
itemView.done.checked = !itemView.done.checked;
});//综合类界面配置
let compositeArray = [];
//concatArray(综合类APP集合);
concatArray(compositeArray, 综合类APP集合);
for (let i = 0; i < compositeArray.length; i++) {
let row = {
AppName: compositeArray[i],
AppIndex: (i + 1),
done: false
};
taskItems.push(row);
}
ui.taskList.setDataSource(taskItems);
//综合类check事件
ui.taskList.on("item_bind", function(itemView, itemHolder) {
itemView.done.on("check", function(checked) {
let item = itemHolder.item;
item.done = checked;
let appName = item.AppName;
let appIndex = itemView.appIndex.getText();
item.AppIndex = appIndex;
if (checked) {
havedTaskChecked.put(appName, appIndex);
} else {
havedTaskChecked.remove(appName);
}
});
});//游戏类界面配置
var yxItems = [];
let 游戏Array = [];
//concatArray(游戏类APP集合);
concatArray(游戏Array, 游戏类APP集合);
for (let i = 0; i < 游戏Array.length; i++) {
let signColor = "#FF0000";
let row = {
SignColor: signColor,
AppName: 游戏Array[i],
AppIndex: (i + 1),
done: false
};
yxItems.push(row);
}
ui.yxList.setDataSource(yxItems);
//游戏类check事件
ui.yxList.on("item_bind", function(itemView, itemHolder) {
itemView.done.on("check", function(checked) {
let item = itemHolder.item;
item.done = checked;
let appName = item.AppName;
let appIndex = itemView.appIndex.getText();
item.AppIndex = appIndex;
if (checked) {
havedyxChecked.put(appName, appIndex);
} else {
havedyxChecked.remove(appName);
}
});
});//软件下载界面配置
var xzItems = [];
let 下载Array = [];
//concatArray(游戏类APP集合);
concatArray(concatArray(concatArray(下载Array, 视频类APP集合), 综合类APP集合), 游戏类APP集合)
for (let i = 0; i < 下载Array.length; i++) {
let row = {
AppName: 下载Array[i],
AppIndex: (i + 1),
done: false
};
xzItems.push(row);
}
ui.xzList.setDataSource(xzItems);
//软件下载check事件
ui.xzList.on("item_bind", function(itemView, itemHolder) {
itemView.done.on("check", function(checked) {
let item = itemHolder.item;
item.done = checked;
let appName = item.AppName;
let appIndex = itemView.appIndex.getText();
item.AppIndex = appIndex;
if (checked) {
havedTaskChecked.put(appName, appIndex);
} else {
havedTaskChecked.remove(appName);
}
});
});
/*
var curTime = new Date();
var closeDateTime = curTime.getFullYear() + "-" + (curTime.getMonth() + 1) + "-" + (curTime.getDate() + 1) + " " + "6:00"
ui.txtCloseDateTime.setText(closeDateTime);var items = [{
AppName: "1、抖音极速版",
AppCode: ""
},
{
AppName: "2、快手极速版",
AppCode: ""
},
{
AppName: "小米应用商店该有的都有",
AppCode: "http://app.mi.com"
},
];
ui.recommandList.setDataSource(items);
activity.setSupportActionBar(ui.toolbar);
*/
// 用户勾选无障碍服务的选项时,跳转到页面让用户去开启 android.permission.SYSTEM_ALERT_WINDOW
ui.xfc.click(function() {
floaty.requestPermission();
})
ui.xfc.checked = floaty.checkPermission()
ui.wza.on("check", function(checked) {
toast("请打开无障碍权限")
if (checked && auto.service == null) {
app.startActivity({
action: "android.settings.ACCESSIBILITY_SETTINGS"
});
};
if (!checked && auto.service != null) {
auto.service.disableSelf();
};
});
// 当用户回到本界面时,resume事件会被触发
ui.emitter.on("resume", function() {
// 此时根据无障碍服务的开启情况,同步开关的状态
ui.wza.checked = auto.service != null;
});
}
}
/**
* 链接的数组并返回新数组
* @param {原始数组}} compositeArray
* @param {被链接的数组} concatArray
*/
function concatArray(compositeArray, concatArray) {
for (var element in concatArray) {
if (typeof(concatArray[element]) == "function") {
continue;
}
compositeArray.push(concatArray[element]);
}
return compositeArray;
}/**
* JS构建Map
*/
function Map() {
var obj = {};
this.put = function(key, value) {
obj[key] = value; //把键值绑定到obj对象上
}
//size方法,获取Map容器的个数
this.size = function() {
var count = 0;
for (var attr in obj) {
count++;
}
return count;
}
//get方法,根据key获取value的值
this.get = function(key) {
if (obj[key] || obj[key] === 0 || obj[key] === false) {
return obj[key]
} else {
return null;
}
}
//remove方法,删除方法
this.remove = function(key) {
if (obj[key] || obj[key] === 0 || obj[key] === false) {
delete obj[key]
}
}
//each方法,遍历方法
this.eachMap = function(callBack) {
for (var attr in obj) {
callBack(attr, obj[attr])
}
}
}function woolEvent(集合) {
threads.start(function() {
if (!ui.xfc.checked || !ui.wza.checked) {
alert("请先给予以下权限:\n无障碍权限\n悬浮窗权限\n再尝试启动脚本!!!");
return;
}
if (集合.length == 0) {
alert("请选择薅羊毛的App!!!");
return;
} else {
控制台()
前台保活()
}
for (i = 0; i < 集合.length; i++) {
if (集合[i] == "快手极速版") {
if (getVersion("快手极速版") == "10.4.41.3607") {
putLog("运行快手极速版")
launchApp("快手极速版")
putLog("休眠10秒")
sleep(10000)
putLog("检测弹窗")
ks弹窗()
ks弹窗()
ks广告任务()
ks直播任务()
ks挂机任务(30)
} else {
putLog("快手极速版版本错误")
}
} else if (集合[i] == "抖音极速版") {
if (getVersion("抖音极速版") == "20.9.0") {
putLog("运行抖音极速版")
launchApp("抖音极速版")
putLog("休眠10秒")
sleep(10000)
putLog("检测弹窗")
dy弹窗()
dy广告任务()
dy直播任务()
dy挂机任务(30)} else {
putLog("抖音极速版版本错误")
}
}
}
})
}
/**
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ===抖音封装===抖音封装===抖音封装===抖音封装====================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
**//*
**
*抖音挂机任务
**
*/
function dy挂机任务(Time) {
while (true) {
var ss = desc("搜索").find()
var 消息 = desc("创建群聊").find()
if (筛选(ss) && !筛选(消息)) {
putLog("已经进入视频界面")
break
} else {
var sy = text("首页").find()
if (筛选(sy)) {
putLog("首页")
sj延迟()
控件坐标点击(sy[返回(sy)], "中心")
} else {
sj延迟()
var sy = text("首页").find()
}
}
sj延迟()
}
engines.execScriptFile("dyjsb/gjfb.js")
//5秒后关闭线程
sleep(Time * 60000);
结束其他脚本()
}/*
**
*抖音开宝箱
**
*/
function dy开宝箱() {
var bx = text("开宝箱得金币").find()
if (筛选(bx)) {
putLog("开宝箱")
控件坐标点击(bx[返回(bx)], "中心")
sleep(2000)
while (true) {
var sp = desc("看广告视频再赚").find()
if (筛选(sp)) {
putLog("看视频")
控件坐标点击(sp[返回(sp)], "中心")
sleep(2000)
}
if (dy广告检测()) {
dy广告()
return;
}
}
}
}/*
**
*抖音进入广告检测
**
*/
function dy广告检测() {
var jc1 = desc("广告").find()
var jc2 = desc("领取成功").find()
if (筛选(jc1)) {
putLog("已进入广告")
return true;
}
if (筛选(jc2)) {
putLog("已进入广告")
return true;
}
}/*
**
*抖音直播任务
**
*/
function dy直播任务() {
while (true) {
var zb = 1
while (true) {
var rwzx = text("看广告赚金币").find()
if (rwzx[0]) {
putLog("已经进入任务中心")
break
} else {
dy弹窗()
var zq = desc("赚钱,按钮").find()
if (筛选(zq)) {
putLog("赚钱")
控件坐标点击(zq[返回(zq)], "中心")
dy弹窗()
} else {
var zq = desc("赚钱,按钮").find()
}
}
}
while (true) {
dy开宝箱()
sj延迟()
var lfl = text("去逛街").find()
if (筛选(lfl)) {
putLog("去逛街")
sj延迟()
控件坐标点击(lfl[返回(lfl)], "中心")
}
var jc = desc("点击进入直播").find()
if (筛选(jc)) {
putLog("已进入直播选择界面")
break
}
sj延迟()
}var zt = className("android.widget.TextView").depth(7).drawingOrder(1).id("com.ss.android.ugc.aweme.lite:id/mu").find()
if (zt[0]) {
for (i = 0; i < zt.length; i++) {
if (zt[i].text()) {
if (zt[i].text().indexOf("秒") >= 0) {
putLog("观看直播" + zt[i].text())
engines.execScriptFile("dyjsb/zbj.js")
//5秒后关闭线程
sleep(Number(zt[0].text()) * 1000);
结束其他脚本()
back()
break
} else if (zt[i].text().indexOf(":") >= 0) {
sj延迟()
back()
sj延迟()
back()
var sj = Number(zt[i].text().split(":")) + 1
putLog("挂机等待" + sj + "分钟")
dy挂机任务(sj)
while (true) {
var rwzx = text("看广告赚金币").find()
if (rwzx[0]) {
putLog("已经进入任务中心")
break
} else {
dy弹窗()
var zq = desc("赚钱,按钮").find()
if (筛选(zq)) {
putLog("赚钱")
控件坐标点击(zq[返回(zq)], "中心")
dy弹窗()
} else {
var zq = desc("赚钱,按钮").find()
}
}
}
while (true) {
dy开宝箱()
sj延迟()
var lfl = text("去逛街").find()
if (筛选(lfl)) {
putLog("去逛街")
sj延迟()
控件坐标点击(lfl[返回(lfl)], "中心")
}
var jc = desc("点击进入直播").find()
if (筛选(jc)) {
putLog("已进入直播选择界面")
break
}
sj延迟()
}
}
}
}
}
}
}/*
**
*抖音直播间弹窗
**
*/
function dy直播弹窗() {
var tc1 = text("立即关注").find()
if (筛选(tc1)) {
putLog("关闭关注弹窗")
back()
}
var tc2 = text("退出直播间").find()
if (筛选(tc2)) {
putLog("退出直播间")
控件坐标点击(tc2[返回(tc2)], "中心")
}
var tc3 = text("退出直播间3").find()
if (筛选(tc3)) {
putLog("退出")
控件坐标点击(tc3[返回(tc3)], "中心")
}
}/*
**
*抖音广告任务
**
*/
function dy广告任务() {
while (true) {
var gg = 1
while (true) {
var rwzx = text("看广告赚金币").find()
if (rwzx[0]) {
putLog("已经进入任务中心")
break
} else {
dy弹窗()
var zq = desc("赚钱,按钮").find()
if (筛选(zq)) {
putLog("赚钱")
控件坐标点击(zq[返回(zq)], "中心")
dy弹窗()
} else {
var zq = desc("赚钱,按钮").find()
}
}
}
while (true) {
dy弹窗()
dy开宝箱()
var lfl = className("com.lynx.tasm.behavior.ui.view.UIView").desc("去领取").find()
var mtzl = text("明天再来").find()
if (筛选(lfl)) {
putLog("去领取")
sj延迟()
控件坐标点击(lfl[返回(lfl)], "中心")
} else if (筛选(mtzl)) {
putLog("广告任务已看完")
gg = 0
break
} else if (dy广告判断()) {
dy广告等待()
while (true) {
var rwzx = text("看广告赚金币").find()
if (筛选(rwzx)) {
putLog("已经进入任务中心")
break
} else {
dy弹窗()
var zq = desc("赚钱,按钮").find()
if (筛选(zq)) {
putLog("赚钱")
sj延迟()
控件坐标点击(zq[返回(zq)], "中心")
sj延迟()
dy弹窗()
} else {
sj延迟()
var zq = desc("赚钱,按钮").find()
}
}
}
} else {
下滑()
sj延迟()
}
if (dy广告检测()) {
putLog("已进入广告")
break
}
sj延迟()
}
if (gg == 1) {
dy广告()
} else {
break
}
}
}/*
**
*抖音广告关闭
**
*/
function dy广告() {
sj延迟()
while (true) {
var ggwc = desc("领取成功").find()
if (筛选(ggwc)) {
var gb1 = desc("领取成功").find()
if (筛选(gb1)) {
putLog("关闭广告1")
控件坐标点击(gb1[返回(gb1)], "中心")
sj延迟()
}
}
var zkyg = desc("领取奖励").find()
if (筛选(zkyg)) {
putLog("领取奖励")
控件坐标点击(zkyg[返回(zkyg)], "中心")
sj延迟()
}
var zkyg = desc("继续观看").find()
if (筛选(zkyg)) {
putLog("误触\n继续观看")
控件坐标点击(zkyg[返回(zkyg)], "中心")
sj延迟()
}
sj延迟()
var rwzx = desc("看广告赚金币").find()
if (筛选(rwzx)) {
putLog("广告结束")
return
}
}
}/*
**
*抖音弹窗
**
*/
function dy弹窗() {
var qd = className("com.lynx.tasm.behavior.ui.text.FlattenUIText").depth(18).find()
if (筛选(qd)) {
for (i = 0; i < qd.length; i++) {
if (qd[i].desc().indexOf("立即签到 +") >= 0) {
putLog("签到")
控件坐标点击(qd[i], "中心")
}
}
sleep(3000)
var ksp = desc("看广告视频再赚").find()
if (筛选(ksp)) {
putLog("看视频")
控件坐标点击(ksp[返回(ksp)], "中心")
dy广告()
}
}var tc1 = text("我知道了").find()
if (筛选(tc1)) {
putLog("关闭,dy弹窗样式1")
控件坐标点击(tc1[返回(tc1)], "中心")
}
var tc2 = text("拒绝").find()
if (筛选(tc2)) {
putLog("关闭,dy弹窗样式2")
控件坐标点击(tc2[返回(tc2)], "中心")
}
var tc3jc = desc("快乐红包").find()
if (tc3jc[0]) {
var tc3 = className("com.lynx.tasm.ui.image.UIImage").depth(8).drawingOrder(1).indexInParent(15).find()
if (筛选(tc3)) {
控件坐标点击(tc3[返回(tc3)], "中心")
}
}
}/*
**
*抖音广告等待判断
**
*/
function dy广告判断() {
var dd = className("com.lynx.tasm.behavior.ui.text.FlattenUIText").depth(18).find()
if (dd[0]) {
for (i = 0; i <= dd.length - 1; i++) {
if (dd[i].desc().indexOf(":") >= 0) {
return true;
} else if (i == dd.length - 1) {
return false;
}
}
} else {
return false;
}
}/*
**
*抖音广告等待挂机
**
*/
function dy广告等待() {
var dd = className("com.lynx.tasm.behavior.ui.text.FlattenUIText").depth(18).find()
if (dd[0]) {
for (i = 0; i <= dd.length - 1; i++) {
if (dd[i].desc().indexOf(":") >= 0 && dd[i].desc().indexOf("天") < 0) {
var sj = Number(dd[i].desc().split(":")[0]) + 1
putLog("挂机等待" + sj + "分钟")
back()
dy挂机任务(sj)
return;
}
}
}
}
/**
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ===快手封装===快手封装===快手封装===快手封装====================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
**//*
**
*快手挂机任务
**
*/
function ks挂机任务(Time) {
while (true) {
var ss = id("com.kuaishou.nebula:id/thanos_home_top_search").find()
if (筛选(ss)) {
putLog("已经进入视频界面")
break
} else {
var sy = desc("首页").find()
if (筛选(sy)) {
putLog("首页")
sj延迟()
控件点击(sy[返回(sy)])
} else {
sj延迟()
var sy = desc("首页").find()
}
}
sj延迟()
}
engines.execScriptFile("ksjsb/gjfb.js")
//5秒后关闭线程
sleep(Time * 60000);
结束其他脚本()
}/*
**
*快手开宝箱
**
*/
function ks开宝箱() {
var bx = text("开宝箱得金币").find()
if (筛选(bx)) {
putLog("开宝箱")
控件坐标点击(bx[返回(bx)], "中心")
}
sleep(2000)
var sp = text("看视频最高得").find()
if (筛选(sp)) {
putLog("看视频")
控件坐标点击(sp[返回(sp)], "中心")
sleep(2000)
while (true) {
if (ks广告检测()) {
ks广告()
return;
}
}
}
}/*
**
*快手进入广告检测
**
*/
function ks广告检测() {
var jc = className("android.widget.TextView").depth(10).find()
var jc2 = text("已成功领取奖励").find()
if (筛选(jc2)) {
putLog("已进入广告")
return true;
}
if (jc[0]) {
for (i = 0; i <= jc.length - 1; i++) {
if (jc[i].text()) {
if (jc[i].text().indexOf("s后") >= 0 || jc[i].text().indexOf("秒后") >= 0 || jc[i].text().indexOf("可领取奖励") >= 0) {
putLog("已进入广告")
return true;
} else if (i == jc.length - 1) {
putLog("未进入广告")
return false;
}
} else if (i == jc.length - 1) {
putLog("未进入广告")
return false;
}
}
}
}/*
**
*快手直播任务
**
*/
function ks直播任务() {
while (true) {
var zb = 1
while (true) {
ks弹窗()
var rwzx = text("我的金币").find()
if (筛选(rwzx)) {
putLog("已经进入任务中心")
break
} else {
var qzq = desc("去赚钱").find()
if (筛选(qzq)) {
putLog("去赚钱")
sj延迟()
控件点击(qzq[返回(qzq)])
ks弹窗()
} else {
sj延迟()
var qzq = desc("去赚钱").find()
}
}
sj延迟()
}
while (true) {
ks开宝箱()
sj延迟()
var lfl = text("领福利").find()
if (lfl[0]) {
putLog("领福利")
sj延迟()
控件点击(lfl[0])
}
var jc = id("com.kuaishou.nebula:id/progress_display").find()
if (筛选(jc)) {
putLog("已进入直播选择界面")
break
}
sj延迟()
}
while (true) {
var cs = id("com.kuaishou.nebula:id/progress_display").find()
if (筛选(cs)) {
if (cs[返回(cs)].text() != "10/10") {
putLog("剩余直播奖励次数" + cs[返回(cs)].text())
while (true) {
var zbj1 = className("android.widget.FrameLayout").depth(8).drawingOrder(1).indexInParent(0).find()
var zbj2 = className("android.widget.FrameLayout").depth(2).drawingOrder(1).indexInParent(0).find()
if (筛选(zbj1)) {
putLog("点击直播间1")
控件坐标点击(zbj1[返回(zbj1)], "中心")
}
if (筛选(zbj2)) {
putLog("点击直播间2")
控件坐标点击(zbj2[返回(zbj2)], "中心")
}
var jc = id("com.kuaishou.nebula:id/progress_display").find()
if (!筛选(jc)) {
putLog("已进入直播间")
break
}
}
break
} else {
putLog("今日已无直播奖励次数")
zb = 0
back()
break
}
}
}
if (zb == 0) {
break
} else {
ks直播弹窗()
putLog("观看直播")
sleep(random(18, 23) * 1000)
while (true) {
sj延迟()
var jc = id("com.kuaishou.nebula:id/progress_display").find()
var jc1 = text("去赚钱").find()
var jc2 = text("看直播领金币").find()
if (筛选(jc)) {
back()
putLog("已退出直播界面")
break
} else if (筛选(jc1)) {
back()
putLog("已退出直播界面")
break
} else if (筛选(jc2)) {
sj延迟()
back()
back()
putLog("已退出直播界面")
break
} else {
putLog("尝试退出直播界面")
ks直播弹窗()
sj延迟()
back()
sj延迟()
}
}
}
}
}/*
**
*快手直播间弹窗
**
*/
function ks直播弹窗() {
var tc1 = text("立即关注").find()
if (筛选(tc1)) {
putLog("关闭关注弹窗")
back()
}
var tc2 = text("退出直播间").find()
if (筛选(tc2)) {
putLog("退出直播间")
控件坐标点击(tc2[返回(tc2)], "中心")
}
var tc3 = text("退出直播间3").find()
if (筛选(tc3)) {
putLog("退出")
控件坐标点击(tc3[返回(tc3)], "中心")
}
}/*
**
*快手广告任务
**
*/
function ks广告任务() {
while (true) {
var gg = 1
while (true) {
var rwzx = text("我的金币").find()
if (筛选(rwzx)) {
putLog("已经进入任务中心")
break
} else {
ks弹窗()
var qzq = desc("去赚钱").find()
if (筛选(qzq)) {
putLog("去赚钱")
sj延迟()
控件点击(qzq[返回(qzq)])
sj延迟()
ks弹窗()
} else {
sj延迟()
var qzq = desc("去赚钱").find()
}
}
sj延迟()
}
while (true) {
sj延迟()
ks弹窗()
sj延迟()
ks开宝箱()
sj延迟()
var lfl = text("福利").find()
if (lfl[0]) {
putLog("福利")
sj延迟()
控件点击(lfl[0])
} else {
var mtzl = text("明天再来").find()
if (mtzl[0]) {
putLog("广告任务已看完")
gg = 0
break
}
}
sleep(3000)
if (ks广告检测()) {
putLog("已进入广告")
break
}
sj延迟()
}
if (gg == 1) {
ks广告()
} else {
break
}
}
}/*
**
*快手广告关闭
**
*/
function ks广告() {
while (true) {
var ggwc = text("已成功领取奖励").find()
if (筛选(ggwc)) {
var gb1 = id("com.kuaishou.nebula.neo_video:id/video_countdown_end_icon").find()
if (筛选(gb1)) {
putLog("关闭广告1")
sj延迟()
控件坐标点击(gb1[返回(gb1)], "中心")
}
var gb2 = id("video_countdown_end_icon").find()
if (筛选(gb2)) {
putLog("关闭广告2")
sj延迟()
控件坐标点击(gb2[返回(gb2)], "中心")
}
var gb3 = id("countdown_info_container").find()
if (筛选(gb3)) {
putLog("关闭广告3")
sj延迟()
控件坐标点击(gb3[返回(gb3)], "中心")
}
}
var zkyg = text("再看一个").find()
if (筛选(zkyg)) {
putLog("再看一个")
sj延迟()
控件坐标点击(zkyg[返回(zkyg)], "中心")
}
var zkyg = id("again_dialog_ensure_text").find()
if (筛选(zkyg)) {
putLog("再看一个")
sj延迟()
控件坐标点击(zkyg[返回(zkyg)], "中心")
}
var qwcrw = text("去完成任务").find()
if (筛选(qwcrw)) {
var fq = text("放弃奖励").find()
if (筛选(fq)) {
putLog("放弃奖励")
sj延迟()
控件坐标点击(fq[返回(fq)], "中心")
}
}
sj延迟()
var rwzx = text("任务中心").find()
var qzq = text("去赚钱").find()
if (筛选(rwzx) || 筛选(qzq)) {
putLog("广告结束")
return
}
}
}/*
**
*快手弹窗
**
*/
function ks弹窗() {
var qd = text("立即签到").find()
if (筛选(qd)) {
putLog("签到")
控件坐标点击(qd[返回(qd)], "中心")
sj延迟()
var qzq = text("去赚钱").find()
if (筛选(qzq)) {
putLog("关闭签到界面")
控件坐标点击(qzq[返回(qzq)], "中心")
sj延迟()
}
}
var tc1jc1 = text("限时奖励").find()
var tc1jc2 = text("去赚钱").find()
if (!筛选(tc1jc1) && !筛选(tc1jc2)) {
var tc1 = className("android.view.View").clickable(true).depth(17).drawingOrder(0).indexInParent(0).find()
if (筛选(tc1)) {
putLog("关闭,ks弹窗样式1")
控件坐标点击(tc1[返回(tc1)], "中心")
}
}
var tc2 = className("android.widget.ImageView").clickable(true).depth(5).drawingOrder(1).indexInParent(1).find()
if (筛选(tc2)) {
putLog("关闭,ks弹窗样式2")
控件坐标点击(tc2[返回(tc2)], "中心")
}
var tc3 = id("com.kuaishou.nebula:id/click_double").text("点击翻倍").find()
if (筛选(tc3)) {
putLog("关闭,ks弹窗样式3")
控件坐标点击(tc3[返回(tc3)], "中心")
}
var tc4 = id("com.kuaishou.nebula:id/close").find()
if (筛选(tc4)) {
putLog("关闭,ks弹窗样式4")
控件坐标点击(tc4[返回(tc4)], "中心")
}
sj延迟()
var tc5 = text("限时等级奖励").find()
if (筛选(tc5)) {
putLog("误入界面,返回")
back()
}
}/**
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ===通用函数===通用函数===通用函数===通用函数====================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
* ================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
**/
function sj延迟() {
sleep(random(750, 1000))
}function 筛选(控件集合) {
if (控件集合.length != 0) {
let x = device.width
let y = device.height
for (i = 0; i <= 控件集合.length - 1; i++) {
let x1 = 控件集合[i].bounds().left
let x2 = 控件集合[i].bounds().right
let y1 = 控件集合[i].bounds().top
let y2 = 控件集合[i].bounds().bottom
if (x1 >= 0 && x1 <= x && x2 >= 0 && x2 <= x && y1 >= 0 && y1 <= y && y2 >= 0 && y2 <= y) {
return true;
} else {
if (i == 控件集合.length - 1) {
return false;
}
}
}
} else {
return false;
}
}function 下滑() {
putLog("下滑")
swipe(500, 900, 500, 200, 400)
sj延迟()
}function 返回(控件集合) {
if (控件集合.length != 0) {
let x = device.width
let y = device.height
for (i = 0; i <= 控件集合.length - 1; i++) {
let x1 = 控件集合[i].bounds().left
let x2 = 控件集合[i].bounds().right
let y1 = 控件集合[i].bounds().top
let y2 = 控件集合[i].bounds().bottom
if (x1 >= 0 && x1 <= x && x2 >= 0 && x2 <= x && y1 >= 0 && y1 <= y && y2 >= 0 && y2 <= y) {
return i;
} else {
if (i == 控件集合.length - 1) {
return 0;
}
}
}
} else {
return 0;
}
}function 控件坐标点击(控件, 点击范围) {
if (控件) {
if (点击范围 == "中心") { //点击控件中心
var x1 = 控件.bounds().left + 控件.bounds().right
var y1 = 控件.bounds().top + 控件.bounds().bottom
click(x1 / 2, y1 / 2)
putLog("点击控件坐标(" + x1 / 2 + "," + y1 / 2 + ")")
} else if (点击范围 == "随机") { //点击随机范围
var x2 = random(控件.bounds().left, 控件.bounds().right)
var y2 = random(控件.bounds().top, 控件.bounds().bottom)
click(x2, y2)
putLog("点击控件坐标(" + x2 + "," + y2 + ")")
} else { //未知范围
putLog("请明确范围类型")
}
} else {
putLog("控件点击出错,联系作者反馈")
}
}function 控件点击(控件) {
控件.click()
}function 结束其他脚本() {
var 当前引擎 = engines.myEngine()
var 所有引擎 = engines.all()
var 引擎数量 = 所有引擎.length
for (var i = 0; i < 引擎数量; i++) {
var 引擎 = 所有引擎[i]
if (引擎 != 当前引擎) {
引擎.forceStop()
}
}
}function 点击父控件(控件) {
控件.parent().click()
}function getVersion(AppName) {
let package_name = app.getPackageName(AppName)
let pkgs = context.getPackageManager().getInstalledPackages(0).toArray();
for (let i in pkgs) {
if (pkgs[i].packageName.toString() === package_name) {
return pkgs[i].versionName;
}
}
}function 前台保活() {
let KeepAliveService = {
start: function(idStr, nameStr) {
try {
idStr = idStr || "";
let channel_id = idStr + ".foreground";
let channel_name = nameStr + " 前台服务通知";
let content_title = nameStr + " 正在运行中";
let content_text = "此为前台保活,请勿手动移除该通知";
let ticker = nameStr + "已启动";
let manager = context.getSystemService(android.app.Service.NOTIFICATION_SERVICE);
let notification;
let icon = context.getResources().getIdentifier("ic_3d_rotation_black_48dp", "drawable", context.getPackageName());
if (device.sdkInt >= 26) {
let channel = new android.app.NotificationChannel(channel_id, channel_name, android.app.NotificationManager.IMPORTANCE_DEFAULT);
channel.enableLights(true);
channel.setLightColor(0xff0000);
channel.setShowBadge(false);
manager.createNotificationChannel(channel);
notification = new android.app.Notification.Builder(context, channel_id).setContentTitle(content_title).setContentText(content_text).setWhen(new Date().getTime()).setSmallIcon(icon).setTicker(ticker).setOngoing(true).build();
} else {
notification = new android.app.Notification.Builder(context).setContentTitle(content_title).setContentText(content_text).setWhen(new Date().getTime()).setSmallIcon(icon).setTicker(ticker).build();
}
manager.notify(1, notification);
} catch (error) {
putLog("前台保活服务启动失败:" + error);
putLog("保活服务启动失败,不影响辅助的正常运行,继续挂机即可.");
}
},
stop: function() {
let manager = context.getSystemService(android.app.Service.NOTIFICATION_SERVICE);
manager.cancelAll();
},
};
KeepAliveService.start("test", "造雾社区-游阅集合");
}function 控制台() {
var w;
var runTime = (function() {
var startTime = new Date().getTime();
return function() {
//账号(账号计数);
var endTime = new Date().getTime();
var spendTime = Math.floor((endTime - startTime) / 1000);
let mok = util.format('%d', spendTime);
return (
parseInt(mok / 60 / 60) +
'时 ' +
(parseInt(mok / 60) % 60) +
'分 ' +
(mok % 60) +
'秒----造雾社区-游阅集合' +
' 当前电量:' +
device.getBattery() +
'%');
};
})();threads.start(function() {
cumtomUI();
setInterval(function() {
let mok = runTime();
if (mok) {
try {
if (mok) ui.run(() => w.时间.text(mok));
} catch (error) {}
}
}, 1000);
});function cumtomUI() {
let resource = context.getResources();
w = floaty.rawWindow(
<relative>
<frame bg="#44ffcc00" w="*" h="{{device.height/2}}">
<vertical w="*">
<card id="indx2" w="*" margin="0 0 0 1" h="auto" background="#000000" cardCornerRadius="3" cardElevation="2dp" gravity="left" >
<horizontal gravity="left" w="*">
<text w="auto" h="auto" textSize="10" margin="8 0 0 0" textColor="#ffffff" text="已运行:"/>
<text w="auto" h="auto" textSize="10" margin="8 0 20 0" id="时间" textColor="#00ffd8" text="0时 0分 0秒" />
</horizontal>
</card>
<View w="*" h="2px" bg="#c0c0c0" />
<com.stardust.autojs.core.console.ConsoleView id="console" background="#7f000000" h="*" />
</vertical>
</frame>
</relative>
);
w.setTouchable(false);
w.setPosition(0, device.height / 2); //设置悬浮窗位置
w.setSize(device.width, device.height / 3); //设置悬浮窗大小
w.console.setConsole(runtime.console);
let c = new android.util.SparseArray();
let Log = android.util.Log;
c.put(
Log.VERBOSE,
new java.lang.Integer(colors.parseColor('#dfc0c0c0'))
);
c.put(Log.DEBUG, new java.lang.Integer(colors.parseColor('#ffffffff')));
c.put(Log.INFO, new java.lang.Integer(colors.parseColor('#ff64dd17')));
c.put(Log.WARN, new java.lang.Integer(colors.parseColor('#ff2962ff')));
c.put(Log.ERROR, new java.lang.Integer(colors.parseColor('#ffd50000')));
c.put(
Log.ASSERT,
new java.lang.Integer(colors.parseColor('#ffff534e'))
);
// w.console.setColors(c);
try {
ui.run(function() {
input_container = w.console.findViewById(
getResourceID('input_container', 'id')
);
input_container.attr('visibility', 'gone');
});} catch (error) {}
function getResourceID(name, defType) {
return resource.getIdentifier(
name,
defType,
context.getPackageName()
);
}
setInterval(() => {}, 1000);
}
}/**
* 自定义打印函数
* @param {文本} txt 需要打印的文本内容
*/
function putLog(txt) {
let type = random(0, 3); //默认随机打印颜色
let colBox = {
0: 'log',
1: 'verbose',
2: 'info',
3: 'error'
};
toast(txt)
console[colBox[type]](' ' + txt);
}/**
* map排序(核心是冒泡有点笨)
*/
function mapSort(mapTask) {
var arr = [];
var result = [];
mapTask.eachMap(function(key, value) {
arr.push(parseInt(value));
result.push(key);
});
var len = arr.length;
for (var i = 0; i < len - 1; i++) {
for (var j = 0; j < len - 1 - i; j++) {
// 相邻元素两两对比,元素交换,大的元素交换到后面
if (arr[j] > arr[j + 1]) {
var temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
//value交换key也得换
var keyTemp = result[j + 1];
result[j + 1] = result[j];
result[j] = keyTemp;
}
}
}
return result; //返回数组
}