This commit is contained in:
hmz 2026-11-02 16:01:25 +08:00
commit 46d0879124
3 changed files with 1584 additions and 459 deletions

View File

@ -2,37 +2,29 @@
// 快手极速版:无障碍文字 + 手机本地 OCR;不保存或上传图片,不访问媒体音量。 // 快手极速版:无障碍文字 + 手机本地 OCR;不保存或上传图片,不访问媒体音量。
var CONFIG = { var CONFIG = {
version: "2026-10-30-kuaishou-26-ten-second-cadence", version: "2026-10-23-kuaishou-6",
packageName: "com.kuaishou.nebula", packageName: "com.kuaishou.nebula",
pollMs: 1200, pollMs: 1200,
recognitionTimeoutMs: 30000, recognitionTimeoutMs: 15000,
capturePermissionTimeoutMs: 60000, capturePermissionTimeoutMs: 60000,
captureRecoveryLimit: 2, captureRecoveryLimit: 2,
useLocalOcr: true, useLocalOcr: true,
roundTimeoutMs: 300000, roundTimeoutMs: 300000,
taskSearchScrolls: 24, taskSearchScrolls: 24,
noProgressLimit: 3, noProgressLimit: 3,
videoCalibrationMs: 120000,
videoSwipeIntervalMs: 10000,
videoSwipeDurationMs: 350,
videoSettleMs: 250,
videoCoinsPerPacket: 1,
videoEstimateMargin: 1.10,
logPath: "/sdcard/Download/kuaishou-daily-run.log", logPath: "/sdcard/Download/kuaishou-daily-run.log",
pageTextPath: "/sdcard/Download/kuaishou-daily-page.json", pageTextPath: "/sdcard/Download/kuaishou-daily-page.json"
flipResultPath: "/sdcard/Download/kuaishou-flip-result.json"
}; };
var localOcrEnabled = false; var localOcrEnabled = false;
var captureQueue = null, captureWorker = null, captureRecoveries = 0; var captureQueue = null, captureWorker = null, captureRecoveries = 0;
var rejection = null, rewardSerial = 0, currentRoundRewardCoins = null; var rejection = null, rewardSerial = 0;
var flipFlowActive = false;
var continuousCardReading = false;
var STAGES = [ var STAGES = [
{name: "翻卡赢金币", title: /^翻卡赢金币$/, kind: "flip"},
{name: "连续看视频阶段奖励", kind: "continuousVideo"},
{name: "看广告得金币", title: /^看广告[得赚]金币$/, kind: "ad", stopAtCoins: 20}, {name: "看广告得金币", title: /^看广告[得赚]金币$/, kind: "ad", stopAtCoins: 20},
{name: "到饭点领饭补", title: /^到饭点领饭补$/, kind: "meal"},
{name: "明日0点领金币", title: /^(?:明日0点领金币|预约领金币)$/, kind: "reserve"}, {name: "明日0点领金币", title: /^(?:明日0点领金币|预约领金币)$/, kind: "reserve"},
{name: "搜索看广告", title: /^搜索看广告$/, kind: "search"}, {name: "搜索看广告", title: /^搜索看广告$/, kind: "search"},
{name: "逛街领金币", title: /^逛街[领赚]金币$/, kind: "street"},
{name: "翻卡赢金币", title: /^翻卡赢金币$/, kind: "flip"},
{name: "逛快手商城赚金币", title: /^逛(?:快手|开售)商城[赚领]金币$/, kind: "mall", products: 6} {name: "逛快手商城赚金币", title: /^逛(?:快手|开售)商城[赚领]金币$/, kind: "mall", products: 6}
]; ];
@ -189,7 +181,7 @@ function captureCall(name, timeoutMs, action) {
if (done === null) { if (done === null) {
captureWorker.interrupt(); captureWorker.interrupt();
captureWorker.join(1500); captureWorker.join(1500);
var timeout = new Error(name + "超时,页面读取或截图通道不可用"); var timeout = new Error(name + "超时,截图通道不可用");
timeout.unsafeWorker = true; timeout.unsafeWorker = true;
throw timeout; throw timeout;
} }
@ -256,14 +248,6 @@ function first(page, pattern, predicate) {
} }
return null; return null;
} }
// 只取明确到账文案,不能把“最高1金币”、余额或任务说明当成本轮收益。
function recordRewardCoins(value) {
var match = /^(?:已成功领取|成功领取|恭喜获得|已获得|获得|领取成功[::]?)(\d+(?:,\d{3})*)金币$/.exec(compact(value));
if (!match) return;
var amount = Number(match[1].replace(/,/g, ""));
if (currentRoundRewardCoins !== 1) currentRoundRewardCoins = amount;
}
function checkRejection(page) { function checkRejection(page) {
var item = first(page, /设备异常|账号异常|操作异常|存在风险|风险行为|领取失败|操作过于频繁|操作频繁|任务失败/); var item = first(page, /设备异常|账号异常|操作异常|存在风险|风险行为|领取失败|操作过于频繁|操作频繁|任务失败/);
if (rejection || item) throw new Error("[NO_RETRY] 平台拒绝:" + (rejection || item.text)); if (rejection || item) throw new Error("[NO_RETRY] 平台拒绝:" + (rejection || item.text));
@ -277,28 +261,18 @@ function readSnapshot() {
foreground = foregroundPackage(); foreground = foregroundPackage();
} }
if (foreground !== CONFIG.packageName) throw new Error("页面离开快手极速版(" + foreground + "),停止本轮操作"); if (foreground !== CONFIG.packageName) throw new Error("页面离开快手极速版(" + foreground + "),停止本轮操作");
// 一次读取目标应用节点,避免分别按文字、描述、ID重复扫描整棵窗口树。 var items = [], selectors = [textMatches(".+"), descMatches(".+"),
// vivo 上切页期间重复全窗口查询可能累积超过识别期限。 idMatches(".*:id/(?:video_countdown|video_countdown_end_icon|.*close.*)")];
var items = []; for (var s = 0; s < selectors.length; s++) {
var nodes = packageName(CONFIG.packageName).find(); var nodes = selectors[s].find();
for (var i = 0; i < nodes.size(); i++) { for (var i = 0; i < nodes.size(); i++) {
var node = nodes.get(i), box = rectOf(node.bounds()); var node = nodes.get(i), box = rectOf(node.bounds());
if (!box || !node.visibleToUser()) continue; var resourceId = String(node.id() || "");
var resourceId = String(node.id() || ""), enabled = node.enabled(); var value = compact(s === 1 ? node.desc() : node.text());
var values = [compact(node.text()), compact(node.desc())]; if (!value && s === 2) value = "@" + resourceId.split("/").pop();
if (!values[0] && /:id\/(?:video_countdown|video_countdown_end_icon|.*close.*|live_simple_play_content_view|live_simple_play_swipe_text)$/.test(resourceId)) { // 排除原生数字滚动器、越界/倒置节点与导航栏下方的伪任务。
values.push("@" + resourceId.split("/").pop()); if (box && value && value.length < 120 && node.visibleToUser()) {
} items.push({text: value, rect: box, node: node, id: resourceId, enabled: node.enabled()});
if (!values[0] && !values[1] && node.clickable() && enabled &&
box.right-box.left>device.width*.12 && box.right-box.left<device.width*.32 &&
box.bottom-box.top>device.height*.018 && box.bottom-box.top<device.height*.065 &&
box.top>device.height*.25 && box.bottom<device.height*.80) {
// 保留图片小按钮;仅在翻卡标题、位数标签及相对位置均匹配后才会使用。
values.push("@flip_card_button");
}
for (var v = 0; v < values.length; v++) {
if (values[v] && values[v].length < 120) {
items.push({text: values[v], rect: box, node: node, id: resourceId, enabled: enabled});
} }
} }
} }
@ -324,18 +298,13 @@ function readSnapshot() {
files.write(CONFIG.pageTextPath, JSON.stringify(unique.map(function (item) { files.write(CONFIG.pageTextPath, JSON.stringify(unique.map(function (item) {
return {text: item.text, rect: item.rect, id: item.id, enabled: item.enabled}; return {text: item.text, rect: item.rect, id: item.id, enabled: item.enabled};
}))); })));
unique.forEach(function (item) {recordRewardCoins(item.text);});
checkRejection(unique); checkRejection(unique);
return unique; return unique;
} }
function snapshot() { return readPage("识别快手页面"); } function snapshot() { return readPage("识别快手页面"); }
function needsLocalOcr(page) { function needsLocalOcr(page) {
if((flipFlowActive || continuousCardReading) && !isAd(page)) return true;
// 翻卡的百位/千位底部按钮是图片,原生树只有已翻数字及“重翻十位”。
// 不能因看到了翻卡标题就认定所有按钮已完整暴露。
if (isFlipPage(page) || flipSettlement(page)) return true;
// 这些实机页面已完整暴露任务文字,重复做全屏 OCR 会拖慢倒计时滑动。 // 这些实机页面已完整暴露任务文字,重复做全屏 OCR 会拖慢倒计时滑动。
if (streetProgress(page) || streetComplete(page) || isMallList(page) || isProductDetail(page)) return false; if (streetProgress(page) || streetComplete(page) || isFlipPage(page) || flipSettlement(page) || isMallList(page) || isProductDetail(page)) return false;
if (page.some(function (item) {return /:id\/video_countdown$/.test(item.id || "");}) || if (page.some(function (item) {return /:id\/video_countdown$/.test(item.id || "");}) ||
page.some(function (item) {return /:id\/reward_merchant_text$/.test(item.id || "");}) || page.some(function (item) {return /:id\/reward_merchant_text$/.test(item.id || "");}) ||
first(page, /^close_view$/)) return false; first(page, /^close_view$/)) return false;
@ -348,18 +317,7 @@ function clickItem(item) {
if (foregroundPackage() !== CONFIG.packageName) throw new Error("点击前已离开快手"); if (foregroundPackage() !== CONFIG.packageName) throw new Error("点击前已离开快手");
var ok = false; var ok = false;
if (item.node) { if (item.node) {
try { try { if (item.node.clickable()) ok = item.node.click(); } catch (ignore) {}
if (item.node.clickable()) ok = item.node.click();
else {
var parent = item.node.parent(), bounds = parent && rectOf(parent.bounds());
// 只向上一层点击紧贴文字的小按钮,不能点击整行任务或整页容器。
if (bounds && parent.enabled() && parent.clickable() &&
bounds.left <= item.rect.left && bounds.right >= item.rect.right &&
bounds.top <= item.rect.top && bounds.bottom >= item.rect.bottom &&
bounds.right - bounds.left < device.width * 0.5 &&
bounds.bottom - bounds.top < device.height * 0.12) ok = parent.click();
}
} catch (ignore) {}
} }
if (!ok) ok = press(Math.round((item.rect.left + item.rect.right) / 2), if (!ok) ok = press(Math.round((item.rect.left + item.rect.right) / 2),
Math.round((item.rect.top + item.rect.bottom) / 2), 80); Math.round((item.rect.top + item.rect.bottom) / 2), 80);
@ -393,7 +351,7 @@ function isAd(page) {
!!first(page, /^广告$/, function (item) {return item.rect.top < device.height * 0.20;}); !!first(page, /^广告$/, function (item) {return item.rect.top < device.height * 0.20;});
} }
function adReward(page) { function adReward(page) {
return !!first(page, /^(?:已成功领取(?:奖励|\d+(?:,\d{3})*金币)|奖励已到账|已获得奖励|奖励领取成功|已领取奖励)$/, return !!first(page, /^(?:已成功领取奖励|奖励已到账|已获得奖励|奖励领取成功|已领取奖励)$/,
function (item) {return item.rect.top < device.height * 0.25;}); function (item) {return item.rect.top < device.height * 0.25;});
} }
function adClose(page) { function adClose(page) {
@ -423,44 +381,9 @@ function modalClose(page) {
}); });
} }
function isLiveRoom(page) { function isLiveRoom(page) {
if (isAd(page) || isTaskCenter(page) || bottomNavigation(page, /^首页$/)) return false; if (isAd(page) || isTaskCenter(page)) return false;
// 真直播间的关闭图标没有文字;不能只依赖“说点什么/更多直播”的 OCR。
if (liveRoomClose(page)) return true;
return !!first(page, /说点什么|直播回放/) && !!first(page, /更多直播|\d+观看/); return !!first(page, /说点什么|直播回放/) && !!first(page, /更多直播|\d+观看/);
} }
function liveRoomClose(page) {
return first(page, /./, function (item) {
return /:id\/live_close$/.test(item.id || "") && item.enabled !== false &&
item.rect.left > device.width * 0.65 && item.rect.bottom < device.height * 0.25;
});
}
function liveLeaveConfirmation(page) {
if (!first(page, /(?:退出|离开|继续观看).*直播|直播.*(?:退出|离开)/)) return null;
return first(page, /^(?:退出直播间?|离开直播间?|确认退出|确定退出|仍要退出|退出|离开|确定)$/);
}
function exitLiveRoom(page) {
if (!isLiveRoom(page)) return page;
writeRunLog("LIVE EXIT: 误入直播间,优先点击直播关闭按钮");
for (var attempt = 0; attempt < 4; attempt++) {
// 广告和首页预览有自己的处理规则,退出后不继续追点旧关闭坐标。
if (isAd(page) || isTaskCenter(page) || bottomNavigation(page, /^首页$/)) {
writeRunLog("LIVE EXIT OK: 已离开直播间,继续原任务");
return page;
}
var confirm = liveLeaveConfirmation(page), close = liveRoomClose(page);
if (confirm) tapFresh(confirm, liveLeaveConfirmation);
else if (close) tapFresh(close, function (fresh) {
return isLiveRoom(fresh) ? liveRoomClose(fresh) : null;
});
else {back(); sleep(CONFIG.pollMs);}
page = snapshot();
}
if (isAd(page) || isTaskCenter(page) || bottomNavigation(page, /^首页$/)) {
writeRunLog("LIVE EXIT OK: 已离开直播间,继续原任务");
return page;
}
throw new Error("误入直播间后4次退出仍未回到首页或任务页,保留现场");
}
function dismissModal(page) { function dismissModal(page) {
var close = modalClose(page); var close = modalClose(page);
if (!close) return false; if (!close) return false;
@ -477,7 +400,6 @@ function ensureTaskCenter() {
continue; continue;
} }
if (isAd(page)) throw new Error("奖励广告仍在进行,不用返回键提前退出"); if (isAd(page)) throw new Error("奖励广告仍在进行,不用返回键提前退出");
if (isLiveRoom(page)) {exitLiveRoom(page); continue;}
if (dismissModal(page)) continue; if (dismissModal(page)) continue;
var leave = first(page, /^(?:仍要退出|确认退出|坚持退出)$/); var leave = first(page, /^(?:仍要退出|确认退出|坚持退出)$/);
if (leave && first(page, /今日还剩\d+次.*机会|继续赚金币|继续賺金币/)) { if (leave && first(page, /今日还剩\d+次.*机会|继续赚金币|继续賺金币/)) {
@ -540,15 +462,6 @@ function rowsOnPage(page, pattern) {
rows.push({title: title, label: label, action: action, detail: detail, rows.push({title: title, label: label, action: action, detail: detail,
quota: progress, unavailable: unavailable}); quota: progress, unavailable: unavailable});
}); });
// 未结算翻卡卡片的标题是图片,原生列表只暴露倒计时、已翻位数和“继续翻”。
if(pattern.test("翻卡赢金币") && !rows.some(function(r){return r.title==="翻卡赢金币";}) && isTaskCenter(page)) {
var resume=first(page,/^继续翻$/,function(i){return i.enabled!==false && i.rect.left>device.width*.72 &&
i.rect.top>device.height*.095 && i.rect.bottom<device.height*.90;});
var expiry=resume && first(page,/^\d{1,2}[::]\d{2}[::]\d{2}[||]?倒计时结束后失效$/,function(i){
return i.rect.left<device.width*.70 && Math.abs(i.rect.top-resume.rect.top)<device.height*.05;
});
if(expiry) rows.push({title:"翻卡赢金币",label:expiry,action:resume,detail:expiry.text,quota:null,unavailable:false});
}
return rows; return rows;
} }
function scrollList(down) { function scrollList(down) {
@ -590,12 +503,8 @@ function scanTask(pattern, excluded) {
return null; return null;
} }
function locateTask(pattern, excluded) { function locateTask(pattern, excluded) {
var previous=flipFlowActive;
if(pattern.test("翻卡赢金币")) flipFlowActive=true;
try {
var row = scanTask(pattern, excluded); var row = scanTask(pattern, excluded);
return row || scanTask(pattern, excluded); return row || scanTask(pattern, excluded);
} finally {flipFlowActive=previous;}
} }
function exactTitle(title) { return {test: function (value) {return value === title;}}; } function exactTitle(title) { return {test: function (value) {return value === title;}}; }
function prepareRow(row) { function prepareRow(row) {
@ -692,7 +601,6 @@ function browseStreet() {
var swipeDown = true, settlingAt = null, lastSeconds = null; var swipeDown = true, settlingAt = null, lastSeconds = null;
while (Date.now() < deadline) { while (Date.now() < deadline) {
var page = snapshot(), progress = streetProgress(page); var page = snapshot(), progress = streetProgress(page);
if (currentRoundRewardCoins === 1) return {rewardSeen: true, reason: "单次收益仅1金币"};
if (streetComplete(page)) return {taskDone: true, reason: "页面显示金币已领完"}; if (streetComplete(page)) return {taskDone: true, reason: "页面显示金币已领完"};
if (progress) { if (progress) {
if (!previous || progress.done > previous.done) { if (!previous || progress.done > previous.done) {
@ -774,81 +682,15 @@ function browseStreet() {
throw new Error("逛街连续5分钟没有领取次数进展,尚未领完10次"); throw new Error("逛街连续5分钟没有领取次数进展,尚未领完10次");
} }
function isFlipPage(page) { function isFlipPage(page) {
return !!first(page, /^翻卡赢金币$/) && !!first(page, /看广告翻|个视频可翻|不翻了[,,]?直接领|点击翻|立即翻|重翻[千百十个]位|^[千百十个]位$/); return !!first(page, /^翻卡赢金币$/) && !!first(page, /看广告翻|个视频可翻|不翻了[,,]?直接领|点击翻|立即翻/);
}
function flipPositions(page) {
var heading=first(page,/^翻卡赢金币$/),positions=[];
if(!heading) return positions;
["个位","十位","百位","千位"].forEach(function(name){
var label=first(page,{test:function(text){return text===name || (name==="千位"&&/^[包锁]千位$/.test(text));}},function(i){
return i.rect.top>heading.rect.bottom && i.rect.bottom<Math.min(device.height*.75,heading.rect.bottom+device.height*.25);
});
if(!label) return;
var center=(label.rect.left+label.rect.right)/2;
var digit=first(page,/^\d$/,function(i){return i.rect.top>=label.rect.top-device.height*.12 &&
i.rect.top<label.rect.top && Math.abs((i.rect.left+i.rect.right)/2-center)<device.width*.08;});
positions.push({name:name,label:label,digit:digit&&digit.text});
});
return positions;
}
function flipUnlockProgress(page) {
if(!isFlipPage(page)) return null;
var counter=first(page,/^看[((]\d+\/\d+[))]个视频可翻$/);
return counter&&quota(counter.text);
}
function flipTaskDay() {
var now=new Date();return now.getFullYear()+"-"+("0"+(now.getMonth()+1)).slice(-2)+"-"+("0"+now.getDate()).slice(-2);
}
function saveFlipDone(reason) {
var state={version:1,day:flipTaskDay(),done:true,reason:reason,updatedAt:new Date().toISOString()};
var temp=CONFIG.flipResultPath+".tmp";
files.write(temp,JSON.stringify(state,null,2));
if(!new java.io.File(temp).renameTo(new java.io.File(CONFIG.flipResultPath))) throw new Error("翻卡已领取,但无法保存完成记录");
}
function flipDoneToday() {
if(!files.exists(CONFIG.flipResultPath)) return false;
var state;
try{state=JSON.parse(files.read(CONFIG.flipResultPath));}catch(error){writeRunLog("FLIP STATE RECHECK: 完成记录损坏,重新确认入口");return false;}
return !!(state&&state.version===1&&state.day===flipTaskDay()&&state.done===true);
}
function flipDecision(page) {
if(isAd(page)) return null;
var heading=first(page,/^翻卡赢金币$/),positions=flipPositions(page);
var pending=positions.filter(function(p){return p.digit===null;});
// 明确的看视频解锁弹层先于其背后的卡片按钮。
var unlock=heading && first(page,/^(?:看广告翻[千百十个]位|(?:再)?看(?:完)?(?:\d+个?|\d+次|一个|一次)?(?:视频|广告)(?:[,,]?可)?(?:解锁|翻|翻开|开启)(?:卡|[千百十个]位)?|解锁[千百十个]位)(?:[((]\d+\/\d+[))])?$/,function(i){
return i.enabled!==false && i.rect.top>heading.rect.bottom && i.rect.bottom<device.height*.88;
});
if(unlock) return {kind:"unlock",button:unlock};
// 按个、十、百、千补足尚未翻开的位数,只点卡片底部按钮,不点标签或可选重翻。
if(heading && pending.length) {
var next=pending[0],center=(next.label.rect.left+next.label.rect.right)/2;
var bottom=first(page,/^(?:@flip_card_button|(?:点击|立即|免费)?翻(?:卡|[千百十个]位)?)$/,function(i){
return i.enabled!==false && i.rect.top>=next.label.rect.top &&
i.rect.bottom<=next.label.rect.bottom+device.height*.075 &&
Math.abs((i.rect.left+i.rect.right)/2-center)<device.width*.10 &&
i.rect.right-i.rect.left<device.width*.40;
});
if(bottom) return {kind:"flip",position:next.name,button:bottom};
}
if(pending.length) return null;
var legacy=heading && first(page,/^(?:点击|立即|免费)?翻(?:卡|[千百十个]位)$/,function(i){
return i.enabled!==false && i.rect.top>heading.rect.bottom && i.rect.bottom<device.height*.88;
});
if(legacy) return {kind:"flip",button:legacy};
// 未完整识别四位时,只接受明确“翻出N金币”的结算页,不能拿“不翻了”提前结算。
if(!(positions.length===4 && positions.every(function(p){return p.digit!==null;})) && !first(page,/^翻出\d+金币$/)) return null;
var collect=first(page,/^(?:不翻了[,,]?直接领|立即收下|开心收下|收下金币|领取\d+金币|领取金币)$/,function(i){
return i.enabled!==false && i.rect.top>device.height*.35 && i.rect.bottom<device.height*.88;
});
return collect?{kind:"collect",button:collect}:null;
} }
function flipAction(page) { function flipAction(page) {
var decision=flipDecision(page);return decision&&decision.button; return first(page, /^(?:看广告翻[千百十个]位|(?:点击|立即|免费)?翻(?:卡|[千百十个]位)|领取\d+金币|领取金币|开心收下|收下金币)$/,
function (item) {return item.enabled !== false && item.rect.top > device.height * 0.35 && item.rect.bottom < device.height * 0.88;});
} }
function flipSettlement(page) { function flipSettlement(page) {
var decision=first(page,/^翻出\d+金币$/)&&flipDecision(page); return first(page, /^翻出\d+金币$/) && first(page, /^(?:立即收下|开心收下|收下金币|领取金币)$/,
return decision&&decision.kind==="collect"?decision.button:null; function (item) {return item.enabled !== false && item.rect.top > device.height * 0.4 && item.rect.bottom < device.height * 0.88;});
} }
function isMallList(page) { function isMallList(page) {
return !!first(page, /^购物车$/) && !!first(page, /^(?:推荐|直播精选|我的订单)$/) && !isTaskCenter(page); return !!first(page, /^购物车$/) && !!first(page, /^(?:推荐|直播精选|我的订单)$/) && !isTaskCenter(page);
@ -920,49 +762,32 @@ function browseMallProducts(limit) {
return {taskDone: true, productsClicked: clicked, reason: "商城商品浏览完成(按页面剩余数量补足,最多6个)"}; return {taskDone: true, productsClicked: clicked, reason: "商城商品浏览完成(按页面剩余数量补足,最多6个)"};
} }
function executeRound(row, kind, options) { function executeRound(row, kind, options) {
var previous=flipFlowActive;
if(kind==="flip") flipFlowActive=true;
try{
var outcome=executeTaskRound(row,kind,options);
if(kind==="flip" && outcome.taskDone && outcome.flippedAll) saveFlipDone(outcome.reason);
return outcome;
}
finally{flipFlowActive=previous;}
}
function executeTaskRound(row, kind, options) {
options = options || {}; options = options || {};
var flipBeforeBalance=kind==="flip"?coinBalance(snapshot()):null; var fresh = prepareRow(row);
var resumeFlip=kind==="flip" && options.resumeCurrent;
var fresh = resumeFlip?row:prepareRow(row);
if (!fresh || fresh.unavailable) return {changed: !fresh, unavailable: !!fresh}; if (!fresh || fresh.unavailable) return {changed: !fresh, unavailable: !!fresh};
if (!resumeFlip && !fresh.action) { if (!fresh.action) {
if (kind === "meal") return {unavailable: true, reason: "饭补入口不可点击"}; if (kind === "meal") return {unavailable: true, reason: "饭补入口不可点击"};
throw new Error("发现任务标题但没有同一行可用按钮:" + row.title); throw new Error("发现任务标题但没有同一行可用按钮:" + row.title);
} }
var toastStart = rewardSerial; var toastStart = rewardSerial;
if(!resumeFlip) tapFresh(fresh.action); tapFresh(fresh.action);
var deadline = Date.now() + CONFIG.roundTimeoutMs, rewardSeen = false, adSeen = false; var deadline = Date.now() + CONFIG.roundTimeoutMs, rewardSeen = false, adSeen = false;
var adClosed = false, searchClicked = false, entered = false, claims = {}; var adClosed = false, searchClicked = false, entered = false, claims = {};
var firstPageAt = Date.now(), searchAttempts = 0, flipClaimRequested=false,flipProgress=""; var firstPageAt = Date.now();
var finalUnlockExpected=false,finalUnlockClosed=false,flipBalanceDeadline=null;
while (Date.now() < deadline) { while (Date.now() < deadline) {
var page = snapshot(); var page = snapshot();
rewardSeen = rewardSeen || rewardSerial > toastStart; rewardSeen = rewardSeen || rewardSerial > toastStart;
if (adReward(page)) rewardSeen = true; if (adReward(page)) rewardSeen = true;
if (kind === "flip" && flipSettlement(page)) { if (kind === "flip" && flipSettlement(page)) {
if(tapFresh(flipSettlement(page), flipSettlement)) flipClaimRequested=true; tapFresh(flipSettlement(page), flipSettlement);
continue; return {rewardSeen: true};
} }
if (kind === "street" && (streetProgress(page) || streetBadge(page) || streetComplete(page))) return browseStreet(); if (kind === "street" && (streetProgress(page) || streetBadge(page) || streetComplete(page))) return browseStreet();
if (!(kind === "flip" && isFlipPage(page)) && dismissModal(page)) continue; if (!(kind === "flip" && isFlipPage(page)) && dismissModal(page)) continue;
if (isAd(page)) { if (isAd(page)) {
adSeen = true; adSeen = true;
var close = adClose(page); var close = adClose(page);
if (close) {tapFresh(close); adClosed = true; if (close) {tapFresh(close); adClosed = true;}
if(kind==="flip") {
if(finalUnlockExpected) finalUnlockClosed=true;
writeRunLog("FLIP AD CLOSED: 已关闭奖励广告,回到当前卡片继续,不计翻卡已完成");
}}
else sleep(CONFIG.pollMs); else sleep(CONFIG.pollMs);
continue; continue;
} }
@ -970,33 +795,13 @@ function executeTaskRound(row, kind, options) {
return {unavailable: true, rewardSeen: rewardSeen}; return {unavailable: true, rewardSeen: rewardSeen};
} }
if (kind === "flip" && isFlipPage(page)) { if (kind === "flip" && isFlipPage(page)) {
var signature=flipPositions(page).map(function(p){return p.name+":"+p.digit;}).join("|"); var flip = flipAction(page);
var unlockProgress=flipUnlockProgress(page); if (!flip) throw new Error("翻卡页未识别到可用翻卡或领取按钮");
if(unlockProgress) signature+="|解锁视频:"+unlockProgress.done+"/"+unlockProgress.total; tapFresh(flip);
if(signature!==flipProgress){flipProgress=signature;deadline=Date.now()+CONFIG.roundTimeoutMs; adClosed = false; rewardSeen = false;
writeRunLog("FLIP PROGRESS: "+signature);}
var decision=flipDecision(page);
if(!decision){sleep(CONFIG.pollMs);continue;}
if(tapFresh(decision.button,function(p){var latest=flipDecision(p);return latest && latest.kind===decision.kind &&
latest.position===decision.position?latest.button:null;})) {
writeRunLog("FLIP ACTION: "+decision.kind+";"+(decision.position||decision.button.text));
if(decision.kind==="collect") flipClaimRequested=true;
if(decision.kind==="unlock") finalUnlockExpected=!!(unlockProgress && unlockProgress.done+1>=unlockProgress.total);
}
adClosed = false;
if(!flipClaimRequested) rewardSeen = false;
continue; continue;
} }
if (isTaskCenter(page)) { if (isTaskCenter(page)) {
if(kind==="flip" && flipClaimRequested) return {rewardSeen:true,taskDone:true,flippedAll:true,reason:"全部位数翻完,领取后已返回任务中心"};
if(kind==="flip" && finalUnlockClosed && flipBeforeBalance!==null) {
var flipAfterBalance=coinBalance(page);
if(flipAfterBalance!==null && flipAfterBalance>flipBeforeBalance) return {rewardSeen:true,taskDone:true,flippedAll:true,
reason:"千位解锁次数完成并自动结算,余额增加"+(flipAfterBalance-flipBeforeBalance)+"金币"};
if(flipBalanceDeadline===null) flipBalanceDeadline=Date.now()+15000;
if(Date.now()<flipBalanceDeadline){sleep(CONFIG.pollMs);continue;}
}
if(kind==="flip" && (adSeen || entered)) return {changed:true,reason:"翻卡未结算便返回任务中心,重新进入继续"};
if (entered || adSeen || Date.now() - firstPageAt > 8000) return {rewardSeen: rewardSeen}; if (entered || adSeen || Date.now() - firstPageAt > 8000) return {rewardSeen: rewardSeen};
sleep(CONFIG.pollMs); sleep(CONFIG.pollMs);
continue; continue;
@ -1004,11 +809,10 @@ function executeTaskRound(row, kind, options) {
entered = true; entered = true;
if (isLiveRoom(page)) { if (isLiveRoom(page)) {
writeRunLog("ROUND LIVE REDIRECT: 进入直播推广页,返回任务中心;不计为完成"); writeRunLog("ROUND LIVE REDIRECT: 进入直播推广页,返回任务中心;不计为完成");
exitLiveRoom(page);
return {rewardSeen: rewardSeen}; return {rewardSeen: rewardSeen};
} }
// 续看弹窗关闭后本轮结束,由主循环重找任务,防止跨任务串行。 // 续看弹窗关闭后本轮结束,由主循环重找任务,防止跨任务串行。
if (adClosed && kind!=="flip") return {rewardSeen: rewardSeen}; if (adClosed) return {rewardSeen: rewardSeen};
if (kind === "mall" && isMallList(page)) return browseMallProducts(options.products || 6); if (kind === "mall" && isMallList(page)) return browseMallProducts(options.products || 6);
if (kind === "reserve") { if (kind === "reserve") {
if (first(page, /预约成功|已预约/)) return {taskDone: true, reason: "明日0点领金币已预约"}; if (first(page, /预约成功|已预约/)) return {taskDone: true, reason: "明日0点领金币已预约"};
@ -1031,27 +835,18 @@ function executeTaskRound(row, kind, options) {
} }
if (kind === "search" && !searchClicked) { if (kind === "search" && !searchClicked) {
var search = prescribedSearch(page); var search = prescribedSearch(page);
if (search) { if (search) {tapFresh(search); searchClicked = true; sleep(1500); continue;}
if (++searchAttempts > 3) throw new Error("搜词按钮连续3次未进入搜索结果,保留异常,不空等5分钟");
tapFresh(search); sleep(1500);
var searchAfter = snapshot();
searchClicked = !prescribedSearch(searchAfter);
writeRunLog("SEARCH TRANSITION: 第" + searchAttempts + "次;" +
(searchClicked ? "已离开选词列表" : "仍在选词列表,重新识别按钮后重试"));
continue;
}
} }
var completion = first(page, /^(?:任务完成|浏览完成|恭喜获得\d+金币|已获得\d+金币|金币已到账|领取成功|奖励已到账)$/); var completion = first(page, /^(?:任务完成|浏览完成|恭喜获得\d+金币|已获得\d+金币|金币已到账|领取成功|奖励已到账)$/);
if (completion) rewardSeen = true; if (completion) rewardSeen = true;
var claim = first(page, /^(?:领取\d+金币|领取金币|领取奖励|点击领取|开心收下|收下金币)$/, var claim = first(page, /^(?:领取\d+金币|领取金币|领取奖励|点击领取|开心收下|收下金币)$/,
function (item) {return item.rect.top > device.height * 0.3 && item.rect.bottom < device.height * 0.93;}); function (item) {return item.rect.top > device.height * 0.3 && item.rect.bottom < device.height * 0.93;});
// 仅在任务/结算页面领取,广告推广的同名字样不触发。 // 仅在任务/结算页面领取,广告推广的同名字样不触发。
if (claim && !isAd(page) && (kind!=="flip" || flipClaimRequested) && (completion || first(page, /浏览.*(?:完成|金币)|搜索.*(?:完成|金币)|恭喜|任务奖励/))) { if (claim && !isAd(page) && (completion || first(page, /浏览.*(?:完成|金币)|搜索.*(?:完成|金币)|恭喜|任务奖励/))) {
var key = claim.text + ":" + Math.round(claim.rect.top / 50); var key = claim.text + ":" + Math.round(claim.rect.top / 50);
if (!claims[key]) {claims[key] = true; tapFresh(claim); continue;} if (!claims[key]) {claims[key] = true; tapFresh(claim); continue;}
} }
if (rewardSeen && (kind!=="flip" || flipClaimRequested)) return kind==="flip"? if (rewardSeen) return {rewardSeen: true};
{rewardSeen:true,taskDone:true,flippedAll:true,reason:"全部位数翻完并确认领取"}:{rewardSeen:true};
if ((kind === "street" || kind === "search") && timedBrowse(page)) { if ((kind === "street" || kind === "search") && timedBrowse(page)) {
// 浏览计时期间交替上下滑,直到页面实际完成;不把“15秒”说明当作已结束。 // 浏览计时期间交替上下滑,直到页面实际完成;不把“15秒”说明当作已结束。
var x = device.width * 0.42, down = Math.floor((Date.now() - firstPageAt) / 12000) % 2 === 0; var x = device.width * 0.42, down = Math.floor((Date.now() - firstPageAt) / 12000) % 2 === 0;
@ -1070,12 +865,11 @@ function drainTask(initial, kind, options) {
var row = locateTask(pattern); var row = locateTask(pattern);
if (!row) return {title: title, rounds: rounds, reason: "入口连续两次完整扫描未找到"}; if (!row) return {title: title, rounds: rounds, reason: "入口连续两次完整扫描未找到"};
if (row.unavailable) return {title: title, rounds: rounds, reason: "任务已完成或次数用完"}; if (row.unavailable) return {title: title, rounds: rounds, reason: "任务已完成或次数用完"};
var beforeBalance = coinBalance(snapshot()); var beforeBalance = options.stopAtCoins !== undefined ? coinBalance(snapshot()) : null;
currentRoundRewardCoins = null;
var outcome; var outcome;
try { try {
// 翻卡可能要多次广告解锁下一位;按位数进展重置超时,不让外层固定5分钟截断。 // 逛街在同页连续领取10次,按领取进展重置超时,不套用整项5分钟上限。
outcome = kind === "street" || kind === "flip" ? executeRound(row, kind, options) : outcome = kind === "street" ? executeRound(row, kind, options) :
boundedCall(title + "单轮", CONFIG.roundTimeoutMs + 20000, function () {return executeRound(row, kind, options);}); boundedCall(title + "单轮", CONFIG.roundTimeoutMs + 20000, function () {return executeRound(row, kind, options);});
} catch (error) { } catch (error) {
if (error.unsafeWorker || error.captureFatal || /\[NO_RETRY\]/.test(String(error))) throw error; if (error.unsafeWorker || error.captureFatal || /\[NO_RETRY\]/.test(String(error))) throw error;
@ -1083,16 +877,12 @@ function drainTask(initial, kind, options) {
outcome = {error: String(error)}; outcome = {error: String(error)};
} }
ensureTaskCenter(); ensureTaskCenter();
if (currentRoundRewardCoins === 1) {
writeRunLog("ONE COIN STOP: " + title + ";单次实际收益1金币,退出当前流程,继续下一流程");
return {title: title, rounds: rounds + 1, lastRewardCoins: 1, reason: "单次实际收益1金币,结束当前流程"};
}
if (outcome.taskDone) return {title: title, rounds: rounds, productsClicked: outcome.productsClicked, reason: outcome.reason}; if (outcome.taskDone) return {title: title, rounds: rounds, productsClicked: outcome.productsClicked, reason: outcome.reason};
var after = locateTask(pattern); var after = locateTask(pattern);
if (resultAdvanced(row, after, outcome.rewardSeen)) { if (resultAdvanced(row, after, outcome.rewardSeen)) {
rounds++; noProgress = 0; rounds++; noProgress = 0;
writeRunLog("ROUND CONFIRMED: " + title + ";已确认=" + rounds); writeRunLog("ROUND CONFIRMED: " + title + ";已确认=" + rounds);
{ if (options.stopAtCoins !== undefined) {
var afterBalance = coinBalance(snapshot()), balanceDeadline = Date.now() + 6000; var afterBalance = coinBalance(snapshot()), balanceDeadline = Date.now() + 6000;
while (beforeBalance !== null && (afterBalance === null || afterBalance === beforeBalance) && Date.now() < balanceDeadline) { while (beforeBalance !== null && (afterBalance === null || afterBalance === beforeBalance) && Date.now() < balanceDeadline) {
sleep(CONFIG.pollMs); sleep(CONFIG.pollMs);
@ -1100,10 +890,9 @@ function drainTask(initial, kind, options) {
} }
var earned = beforeBalance !== null && afterBalance !== null && afterBalance > beforeBalance ? afterBalance - beforeBalance : null; var earned = beforeBalance !== null && afterBalance !== null && afterBalance > beforeBalance ? afterBalance - beforeBalance : null;
writeRunLog("ROUND COINS: " + title + ";本轮实际金币=" + earned); writeRunLog("ROUND COINS: " + title + ";本轮实际金币=" + earned);
if (earned === null && options.stopAtCoins !== undefined) return {title: title, rounds: rounds, incomplete: true, reason: "未确认本轮实际金币,暂停该项以免越过奖励阈值"}; if (earned === null) return {title: title, rounds: rounds, incomplete: true, reason: "未确认本轮实际金币,暂停该项以免越过奖励阈值"};
var stopAt = options.stopAtCoins !== undefined ? options.stopAtCoins : 1; if (earned <= options.stopAtCoins) return {title: title, rounds: rounds, lastRewardCoins: earned,
if (earned !== null && earned <= stopAt) return {title: title, rounds: rounds, lastRewardCoins: earned, reason: "本轮实际金币≤" + options.stopAtCoins + ",结束当前流程"};
reason: "本轮实际金币≤" + stopAt + ",结束当前流程"};
} }
} else if (!outcome.changed && !outcome.unavailable && after && !after.unavailable) { } else if (!outcome.changed && !outcome.unavailable && after && !after.unavailable) {
noProgress++; noProgress++;
@ -1117,191 +906,10 @@ function drainTask(initial, kind, options) {
incomplete: true, reason: "连续3轮未确认进展,保留异常,不冒充任务已完成"}; incomplete: true, reason: "连续3轮未确认进展,保留异常,不冒充任务已完成"};
} }
} }
function continuousVideoCard(page) { function runStages() {
var heading = first(page, /^连续看视频\d+天/, function(item) {
return item.rect.left < device.width * 0.3 && item.rect.top < device.height * 0.55;
});
if (!heading) return null;
var region = page.filter(function(item) {
return item.rect.top >= heading.rect.bottom && item.rect.bottom < heading.rect.bottom + device.height * 0.24;
});
var claim = first(region, /^(?:领金币|一键领取)$/);
var watch = first(region, /^(?:去看视频|看视频|继续看视频)$/);
// OPPO实际文案为“已攒6112/7886金币,继续看视频可开启”,不是单独的页码式数字。
var progressItem = first(region, /^(?:已攒|已累计|已获得|已赚|已完成)?\d+(?:,\d{3})*\/\d+(?:,\d{3})*(?:金币|$)/);
var progress = progressItem && quota(progressItem.text.replace(/,/g, ""));
if (progress && (!progress.total || progress.done > progress.total)) progress = null;
var status = first(region, /(?:\d+金币待领取|已领\d+金币)/);
var done = !claim && !!first(region, /今日(?:奖励|金币|任务)?已(?:全部)?(?:领完|领取完|完成)|今日奖励已全部领取|明日再来|明天再来/);
return {claim:claim, watch:watch, progress:progress, done:done,
remainingCoins:progress ? progress.total - progress.done : null,
signature:(progress ? progress.done + "/" + progress.total : "") + "|" + (status ? status.text : "")};
}
function locateContinuousVideoCard() {
var previous=continuousCardReading;continuousCardReading=true;
try{return readContinuousVideoCard();}finally{continuousCardReading=previous;}
}
function readContinuousVideoCard() {
ensureTaskCenter();
for (var i=0;i<=CONFIG.taskSearchScrolls;i++) {
var page=snapshot();
if (dismissModal(page)) continue;
var card=continuousVideoCard(page);
if (card) return card;
if(i<CONFIG.taskSearchScrolls) scrollList(false);
}
throw new Error("连续看视频奖励卡片未找到,不能认定全部领取完成");
}
function skippableContinuousFeedCard(page) {
if (!bottomNavigation(page,/^首页$/)) return false;
return !!first(page,/^(?:上滑继续观看视频|点击进入直播间|查看图片详情|图文)$/) || page.some(function(item) {
// OPPO 直播预览的进入提示会随动画隐藏,保留稳定内容控件和底部标题作为证据。
return /:id\/(?:live_simple_play_swipe_text|live_simple_play_content_view|live_preview_bottom_caption|pic_text)$/.test(item.id || "");
});
}
function isContinuousVideoFeed(page) {
if (isAd(page) || isTaskCenter(page) || isLiveRoom(page) ||
!bottomNavigation(page, /^首页$/) || skippableContinuousFeedCard(page)) return false;
var nativeFeed = page.some(function (item) {return /:id\/like_button$/.test(item.id || "");}) &&
page.some(function (item) {return /:id\/user_name_text_view(?:_new)?$/.test(item.id || "");});
return !!first(page, /^(?:暂停视频|播放视频)$/) || nativeFeed;
}
function watchContinuousVideoSegment(durationMs) {
durationMs = durationMs === undefined ? CONFIG.videoCalibrationMs : durationMs;
if (!isFinite(durationMs) || durationMs <= 0) throw new Error("连续观看时长必须是有效正数");
var watchedMs = 0, pendingWatchMs = 0, pendingWatchSince = 0, lastVideoAt = Date.now();
while (true) {
var readStartedAt = Date.now();
var page = snapshot();
var pageReadMs = Date.now() - readStartedAt;
if (isTaskCenter(page)) return {watchedMs:watchedMs, reason:"taskCenter"};
if (Date.now() - lastVideoAt > CONFIG.roundTimeoutMs)
throw new Error("连续5分钟未确认正常视频观看,保留现场,不当作任务完成");
if (isAd(page)) {pendingWatchMs = 0; finishExistingAd(); continue;}
if (isLiveRoom(page)) {
exitLiveRoom(page);
pendingWatchMs = 0;
continue;
}
if (dismissModal(page)) {pendingWatchMs = 0; continue;}
if (skippableContinuousFeedCard(page)) {
pendingWatchMs = 0;
writeRunLog("CONTINUOUS VIDEO: 上滑跳过兴趣选择、直播预览或图文卡片,继续观看");
} else {
if (!isContinuousVideoFeed(page)) throw new Error("连续看视频未进入已识别的视频播放页,保留现场");
lastVideoAt = Date.now();
if (pendingWatchMs) {
// 只有等待前后都确认是普通视频才累计观看,直播/广告/预览不抵扣计划时长。
watchedMs += Math.min(durationMs - watchedMs, Date.now() - pendingWatchSince);
pendingWatchMs = 0;
if (watchedMs >= durationMs) {
writeRunLog("CONTINUOUS VIDEO BATCH END: 已连续观看" + Math.round(watchedMs / 1000) + "秒,返回任务页领奖");
return {watchedMs:watchedMs, reason:"duration"};
}
} else {
pendingWatchMs = Math.min(CONFIG.videoSwipeIntervalMs, durationMs - watchedMs);
pendingWatchSince = readStartedAt;
writeRunLog("CONTINUOUS VIDEO WATCH: 普通视频,已看" + Math.round(watchedMs / 1000) +
"/" + Math.ceil(durationMs / 1000) + "秒;等待后重新识别页面");
// 首读期间视频也在播放,并预留同量补读时间,让实际切换接近10秒。
var remainingWait = pendingWatchMs - (Date.now() - pendingWatchSince) - pageReadMs;
if (remainingWait > 0) sleep(remainingWait);
keepScreenAwake();
continue;
}
}
if (!swipe(device.width * 0.4, device.height * 0.74, device.width * 0.4, device.height * 0.3, CONFIG.videoSwipeDurationMs))
throw new Error("连续看视频切换失败");
writeRunLog("CONTINUOUS VIDEO SWIPE: 已切换下一视频");
sleep(CONFIG.videoSettleMs);
}
}
function continuousVideoWatchPlan(card, msPerCoin) {
if (!card.progress || card.remainingCoins === null) throw new Error("未读到连续看视频剩余金币,不能估算观看时间");
if (card.remainingCoins <= 0) throw new Error("视频进度已满但未出现领奖入口,不能继续盲刷");
var durationMs = msPerCoin ? Math.max(1, Math.round(card.remainingCoins * msPerCoin * CONFIG.videoEstimateMargin)) : CONFIG.videoCalibrationMs;
if (!isFinite(durationMs) || durationMs <= 0) throw new Error("观看时间估算无效");
return {durationMs:durationMs, remainingCoins:card.remainingCoins,
packets:Math.ceil(card.remainingCoins / CONFIG.videoCoinsPerPacket), calibration:!msPerCoin};
}
function waitContinuousVideoReceipt() {
// vivo 弹窗动画期间原生树和截图可能仍是上一帧,不能单次读取就判定失败。
var deadline=Date.now()+15000;
do {
var page=snapshot();
if(first(page,/^任务完成奖励$/)) return page;
sleep(CONFIG.pollMs);
} while(Date.now()<deadline);
throw new Error("连续看视频领取后等待15秒仍未确认奖励到账弹窗,保留现场");
}
function continuousVideoStep() {
var lastSignature=null, claims=0, msPerCoin=null, sample=null, noProgress=0;
while(true) {
var card=locateContinuousVideoCard();
if(card.signature!==lastSignature) {lastSignature=card.signature;
writeRunLog("CONTINUOUS VIDEO PROGRESS: "+card.signature);}
if (sample) {
var gain = card.progress && card.progress.total === sample.before.total ? card.progress.done - sample.before.done : null;
if (gain > 0 && sample.watchedMs > 0) {
var measured = sample.watchedMs / gain;
msPerCoin = msPerCoin ? (msPerCoin + measured) / 2 : measured;
noProgress = 0;
writeRunLog("CONTINUOUS VIDEO RATE: 观看" + Math.round(sample.watchedMs / 1000) + "秒,任务增加" + gain +
"金币;按每红包约" + CONFIG.videoCoinsPerPacket + "金币折算,每红包约" +
(msPerCoin * CONFIG.videoCoinsPerPacket / 1000).toFixed(2) + "秒");
} else if (!card.claim && !card.done && gain === 0) {
noProgress++;
// 进度未增加时重新测算,不沿用已经失效的收益速度。
msPerCoin = null;
writeRunLog("CONTINUOUS VIDEO NO PROGRESS: " + noProgress + "/" + CONFIG.noProgressLimit);
} else noProgress = 0;
sample = null;
}
if(card.done) return {title:"连续看视频阶段奖励",rounds:claims,reason:"今日连续看视频奖励已全部领取"};
if(noProgress>=CONFIG.noProgressLimit) return {title:"连续看视频阶段奖励",rounds:claims,incomplete:true,
reason:"连续3次观看未确认金币进度增加,保留异常,不当作全部领完"};
if(card.claim) {
if (!tapFresh(card.claim,function(page){var current=continuousVideoCard(page);return current&&current.claim;})) continue;
var receipt=waitContinuousVideoReceipt();
claims++;writeRunLog("CONTINUOUS VIDEO CLAIM: 已确认领取第"+claims+"笔,不按1金币阈值退出");
var close=modalClose(receipt);
if(close) tapFresh(close,modalClose);
else throw new Error("连续看视频领奖弹窗没有明确关闭入口");
continue;
}
if(!card.watch) throw new Error("连续看视频尚未确认领完,且未找到观看入口");
var plan = continuousVideoWatchPlan(card, msPerCoin);
writeRunLog("CONTINUOUS VIDEO PLAN: 当前奖励还差" + plan.remainingCoins + "金币,约" + plan.packets + "个红包;" +
(plan.calibration ? "先观看" : "预计连续观看") + Math.ceil(plan.durationMs / 1000) + "秒" +
(plan.calibration ? "测算速度,仅回查一次" : "(含10%余量),到时再回任务页领奖,中途不查收益"));
if (!tapFresh(card.watch,function(page){var current=continuousVideoCard(page);return current&&current.watch;}))
throw new Error("开始连续观看前任务入口变化,未启动观看");
var result = watchContinuousVideoSegment(plan.durationMs);
sample = {before:card.progress, watchedMs:result.watchedMs};
}
}
function runStages(startKind) {
var results = []; var results = [];
var stages = STAGES; STAGES.forEach(function (stage) {
if (startKind) {
var index = STAGES.map(function (stage) {return stage.kind;}).indexOf(String(startKind));
if (index < 0) throw new Error("未知恢复流程:" + startKind);
stages = STAGES.slice(index);
writeRunLog("RESUME STAGE: " + stages[0].name);
}
stages.forEach(function (stage) {
if(stage.kind==="flip" && flipDoneToday()) {
results.push({title:stage.name,taskDone:true,reason:"今天翻卡已确认结算,直接进入下一流程"});
writeRunLog("STAGE SKIP COMPLETED: "+stage.name+";今天已结算,直接进入下一流程");
return;
}
writeRunLog("STAGE START: " + stage.name); writeRunLog("STAGE START: " + stage.name);
if (stage.kind === "continuousVideo") {
var videoResult=continuousVideoStep();results.push(videoResult);
writeRunLog("TASK RESULT: "+JSON.stringify(videoResult));
writeRunLog("STAGE END: "+stage.name);return;
}
var row = locateTask(stage.title); var row = locateTask(stage.title);
if (row) { if (row) {
var result = drainTask(row, stage.kind, stage); var result = drainTask(row, stage.kind, stage);
@ -1317,7 +925,6 @@ function installToastObserver() {
events.onToast(function (event) { events.onToast(function (event) {
if (String(event.getPackageName()) !== CONFIG.packageName) return; if (String(event.getPackageName()) !== CONFIG.packageName) return;
var value = compact(event.getText()); var value = compact(event.getText());
recordRewardCoins(value);
if (/设备异常|账号异常|操作异常|领取失败|操作频繁|操作过于频繁|存在风险/.test(value)) rejection = value; if (/设备异常|账号异常|操作异常|领取失败|操作频繁|操作过于频繁|存在风险/.test(value)) rejection = value;
if (/领取成功|已获得\d+金币|金币已到账|成功领取\d+金币/.test(value)) rewardSerial++; if (/领取成功|已获得\d+金币|金币已到账|成功领取\d+金币/.test(value)) rewardSerial++;
writeRunLog("APP TOAST: " + value); writeRunLog("APP TOAST: " + value);
@ -1330,10 +937,6 @@ function finishExistingAd() {
var deadline = Date.now() + CONFIG.roundTimeoutMs; var deadline = Date.now() + CONFIG.roundTimeoutMs;
while (Date.now() < deadline) { while (Date.now() < deadline) {
page = snapshot(); page = snapshot();
if(isFlipPage(page) || flipSettlement(page)) {
writeRunLog("STARTUP AD CLOSED: 已回到未完成翻卡,交回翻卡流程,不关闭卡片弹窗");
return;
}
if (dismissModal(page)) continue; if (dismissModal(page)) continue;
if (!isAd(page)) { if (!isAd(page)) {
writeRunLog("STARTUP AD CLOSED: 当前广告已退出"); writeRunLog("STARTUP AD CLOSED: 当前广告已退出");
@ -1364,14 +967,8 @@ function runDaily() {
return "INSPECT DONE: 仅保存本机页面文字,未执行任务"; return "INSPECT DONE: 仅保存本机页面文字,未执行任务";
} }
finishExistingAd(); finishExistingAd();
var currentPage=snapshot();
if((!mine.execArgv || !mine.execArgv.startStage || mine.execArgv.startStage==="flip") &&
(isFlipPage(currentPage) || flipSettlement(currentPage))) {
writeRunLog("FLIP RESUME: 当前翻卡尚未结算,先完成现有卡片再回任务中心");
executeRound({title:"翻卡赢金币"},"flip",{resumeCurrent:true});
}
ensureTaskCenter(); ensureTaskCenter();
var results = runStages(mine.execArgv && mine.execArgv.startStage); var results = runStages();
if (results.some(function (result) {return result.incomplete;})) throw new Error("部分任务未确认完成,请查看 TASK RESULT 日志"); if (results.some(function (result) {return result.incomplete;})) throw new Error("部分任务未确认完成,请查看 TASK RESULT 日志");
return "DONE: 快手极速版各类任务已依次执行至不可做或入口消失;" + JSON.stringify(results); return "DONE: 快手极速版各类任务已依次执行至不可做或入口消失;" + JSON.stringify(results);
} }

View File

@ -0,0 +1,27 @@
# 快手 App 日常任务脚本
入口:[kuaishou-main-daily.auto.js](kuaishou-main-daily.auto.js),目标包名 `com.smile.gifmaker`,用于普通快手 App。快手极速版继续使用 `kuaishou_auto/kuaishou-daily.auto.js`,包名为 `com.kuaishou.nebula`。
当前流程:翻卡赢金币 → 看广告得金币 → 明日0点领金币/预约领金币 → 搜索看广告 → 逛快手商城赚金币。按用户最新要求不执行“看视频赚金币”和连续视频阶段。
- 通过底部赚钱导航或左上侧边栏“任务中心”进入任务页。只识别这两个入口,不点“玩游戏送超多金币”行的“去赚钱”。
- 普通版列表滚动后会收起“任务中心”标题,使用顶部固定的金币/现金栏继续识别任务页;余额支持标签和数值分开显示。
- 翻卡保留原有数位和解锁进度;其他任务按当前可执行入口循环,操作失败保留未完成。
- 看广告得金币单轮实际收益≤20金币时结束该项;预约仅执行一次;商城最多补足6个商品。
- 取消明确的“添加桌面微件”浮层。刚点击赚钱入口就被其他应用抢前台时,仅重新打开目标应用复查一次;广告和普通观看中离开应用仍停止。
- “去分享视频可再得金币/确定要离开吗”挽留弹窗点“狠心离开”。任务中心“努力加载中”最多等待30秒,不滑动刷新或反复退出重进;持续加载记为异常,不当作任务消失。
- 日志、最近页面文字和每日翻卡完成记录与极速版分别保存;不上传或保存图片,不改变媒体音量。
手机部署路径:`/sdcard/脚本/快手/kuaishou-main-daily.auto.js`。极速版独立放在`/sdcard/脚本/快手极速版/kuaishou-daily.auto.js`。
手机文字文件:
- `/sdcard/Download/kuaishou-main-daily-run.log`
- `/sdcard/Download/kuaishou-main-daily-page.json`
- `/sdcard/Download/kuaishou-main-flip-result.json`
部署前须在 AutoJs6 应用详情 → 耗电管理核对“允许后台高耗电”已开启。两款快手任务使用同一台手机时应依次运行,避免两个引擎同时操作页面。
2026-11-01:16项针对性检查与两份脚本语法检查通过。已核对AutoJs6设置页“完全允许后台行为”选中;普通版实机通过侧边栏任务中心进入“看广告得金币”,等待真实倒计时并关闭广告和续看浮层,余额1340→1341,按单轮≤20金币结束该项。此期间AutoJs6在后台,任务持续更新日志。
两款手机文件夹已经分开,任务管理器旧极速版路径已迁移,原启用状态及次数保持不变。连接恢复后已同步普通版5(不看普通视频,含加载等待修复),手机与电脑SHA256一致:`a92d0f166f0a124ae5fcda195a3cb3b176eca601fc7ae2cf2d70b7bbc2d333d2`。目前手机依次复测两款脚本,当前运行极速版,避免同时操作页面。实机记录见`../kuaishou_auto/verification/2026-11-01-oppo-stall/`,未声称当天全部任务已经完成。

File diff suppressed because it is too large Load Diff