From 537112d24c171766e25f36e5c373944ff2b2fdfc Mon Sep 17 00:00:00 2001 From: hmz Date: Mon, 26 Oct 2026 16:09:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fanqie_auto/fanqie-daily.auto.js | 115 +++++++++++- fanqie_auto/fanqie-flow.md | 18 ++ .../fixtures/vivo-invite-cash-popup.json | 1 + .../tests/fixtures/vivo-raffle-popup.json | 1 + .../fixtures/vivo-recommendation-popup.json | 1 + fanqie_auto/tests/invite-cash.test.js | 66 +++++++ hongguo_auto/README.md | 2 + hongguo_auto/hongguo-daily.auto.js | 20 ++- hongguo_auto/tests/drama-choice.test.js | 6 + .../tests/fixtures/oppo-drama-choice.json | 1 + kuaishou_auto/kuaishou-daily.auto.js | 167 +++++++++++++++--- kuaishou_auto/repair-notes.md | 17 ++ .../tests/fixtures/vivo-ad-reward.json | 1 + .../tests/fixtures/vivo-continuous-video.json | 1 + .../tests/fixtures/vivo-search-list.json | 1 + kuaishou_auto/tests/native-snapshot.test.js | 54 ++++++ 16 files changed, 444 insertions(+), 28 deletions(-) create mode 100644 fanqie_auto/tests/fixtures/vivo-invite-cash-popup.json create mode 100644 fanqie_auto/tests/fixtures/vivo-raffle-popup.json create mode 100644 fanqie_auto/tests/fixtures/vivo-recommendation-popup.json create mode 100644 fanqie_auto/tests/invite-cash.test.js create mode 100644 hongguo_auto/tests/drama-choice.test.js create mode 100644 hongguo_auto/tests/fixtures/oppo-drama-choice.json create mode 100644 kuaishou_auto/repair-notes.md create mode 100644 kuaishou_auto/tests/fixtures/vivo-ad-reward.json create mode 100644 kuaishou_auto/tests/fixtures/vivo-continuous-video.json create mode 100644 kuaishou_auto/tests/fixtures/vivo-search-list.json create mode 100644 kuaishou_auto/tests/native-snapshot.test.js diff --git a/fanqie_auto/fanqie-daily.auto.js b/fanqie_auto/fanqie-daily.auto.js index 46aa630..9486350 100644 --- a/fanqie_auto/fanqie-daily.auto.js +++ b/fanqie_auto/fanqie-daily.auto.js @@ -4,7 +4,7 @@ // 页面识别:无障碍文字 + 可选的本地 $ocr.detect;图片不上传、不写入日志。 // 签到、翻卡循环、预约/现金签到、红包10连开、出版物阅读与挑战;通用弹窗优先。 var CONFIG = { - version: "2026-10-26-tasks-119-piggybank-digits", + version: "2026-10-26-tasks-123-promo-cross", packageName: "com.dragon.read", rewardThreshold: 500, pollMs: 1200, @@ -847,6 +847,7 @@ function claimReadingChallengeCoins(target) { } function needsCommonHandling(items) { + if (dismissOnlyPromoPopupHeading(items)) return true; if (completedTaskPopupHeading(items)) return true; if (liveExitAction(items)) return true; if (findFlipRewardReceiptHeading(items)) return true; @@ -909,7 +910,52 @@ function readCloseRegion(frame, items, region) { } } +// 仅在已确认推广层的按钮下方识别白色X,要求四条亮色斜臂和暗色间隙。 +function readPromoCross(frame, items, action) { + var unit = device.width / 1080; + function bright(x, y) { + var color = images.pixel(frame, Math.round(x), Math.round(y)); + var r = (color >>> 16) & 255, g = (color >>> 8) & 255, b = color & 255; + return Math.min(r, g, b) > 205 && Math.max(r, g, b) - Math.min(r, g, b) < 30; + } + var top = action.rect.bottom + device.height * 0.03; + var bottom = Math.min(device.height * 0.87, action.rect.bottom + device.height * 0.20); + for (var y = Math.floor(top); y < bottom; y += 2) { + for (var x = Math.floor(device.width * 0.45); x < device.width * 0.55; x += 2) { + if (!bright(x, y)) continue; + var hits = 0; + for (var d = 5; d <= 11; d += 3) { + var offset = d * unit; + if (bright(x-offset,y-offset)) hits++; + if (bright(x+offset,y-offset)) hits++; + if (bright(x-offset,y+offset)) hits++; + if (bright(x+offset,y+offset)) hits++; + } + var gap = 12 * unit; + if (hits < 11 || bright(x-gap,y) || bright(x+gap,y) || + bright(x,y-gap) || bright(x,y+gap)) continue; + items.push({text: "关闭推广弹窗", rect: {left:x-gap,top:y-gap,right:x+gap,bottom:y+gap},node:null}); + writeRunLog("推广白色叉号图形识别:" + x + "," + y); + return; + } + } +} + function readReceiptCloseRegion(frame, items) { + if (dismissOnlyPromoPopupHeading(items) && !findInviteCashPopupClose(items)) { + var promoAction = first(items, /^(?:前[往住]抽奖|查看权益)$/, isCenteredPopupItem); + if (promoAction) { + readPromoCross(frame, items, promoAction); + if (findInviteCashPopupClose(items)) return; + var promoTop = Math.floor(promoAction.rect.bottom + device.height * 0.02); + var promoBottom = Math.min(Math.floor(device.height * 0.90), + Math.floor(promoAction.rect.bottom + device.height * 0.22)); + if (promoTop < promoBottom) readCloseRegion(frame, items, { + left: Math.floor(device.width * 0.42), top: promoTop, + width: Math.floor(device.width * 0.16), height: promoBottom - promoTop + }); + } + } var completed = completedTaskPopupHeading(items); if (completed) { if (!findCompletedTaskPopupClose(items)) { @@ -1011,6 +1057,7 @@ function readSnapshot() { if (frame && typeof frame.recycle === "function") frame.recycle(); } } + appendNativePromoClose(items); appendNativeReceiptClose(items); // 同一按钮可能同时被无障碍和 OCR 识别,合并后优先使用无障碍节点。 var unique = []; @@ -1178,6 +1225,52 @@ function findReceiptEligibleClaim(items) { }); } +function inviteCashPopupHeading(items) { + var heading = first(items, /^送你现金红包$/, isCenteredPopupItem); + return heading && first(items, /^邀请好友立得$/, isCenteredPopupItem) ? heading : null; +} + +function dismissOnlyPromoPopupHeading(items) { + var cash = inviteCashPopupHeading(items); + if (cash) return cash; + var raffle = first(items, /^抽奖[赢贏嘉]好礼$/, isCenteredPopupItem); + if (raffle && first(items, /^前[往住]抽奖$/, isCenteredPopupItem)) return raffle; + var recommendation = first(items, /^小说推荐官$/, isCenteredPopupItem); + return recommendation && first(items, /^赠送好友VIP会员$/, isCenteredPopupItem) && + first(items, /^查看权益$/, isCenteredPopupItem) ? recommendation : null; +} + +function appendNativePromoClose(items) { + if (!dismissOnlyPromoPopupHeading(items) || typeof className !== "function") return; + var benefit = first(items, /^查看权益$/, isCenteredPopupItem); + if (!benefit) return; + var nodes = className("android.widget.ImageView").packageName(CONFIG.packageName).find(); + for (var i = 0; i < nodes.size(); i++) { + var node = nodes.get(i), rect = rectOf(node.bounds()); + var parent = node.parent(), panel = parent ? rectOf(parent.bounds()) : null; + if (!rect || !panel || !node.visibleToUser()) continue; + var width = rect.right - rect.left, height = rect.bottom - rect.top; + var center = (rect.left + rect.right) / 2; + if (center < device.width * 0.4 || center > device.width * 0.6 || + rect.top <= benefit.rect.bottom || rect.bottom >= device.height * 0.9 || + width < device.width * 0.04 || width > device.width * 0.15 || Math.abs(width - height) > width * 0.25 || + panel.right - panel.left > device.width * 0.85 || panel.top >= benefit.rect.top || + Math.abs(panel.bottom - rect.bottom) > device.height * 0.02) continue; + items.push({text: "关闭推广弹窗", rect: rect, node: node}); + } +} + +function findInviteCashPopupClose(items) { + var heading = dismissOnlyPromoPopupHeading(items); + if (!heading) return null; + return first(items, /^(?:关闭|关闭弹窗|关闭窗口|关闭推广弹窗|[xX×✕メ])$/, function (item) { + var center = (item.rect.left + item.rect.right) / 2; + return center > device.width * 0.35 && center < device.width * 0.65 && + item.rect.top > heading.rect.bottom && item.rect.top > device.height * 0.55 && + item.rect.bottom < device.height * 0.9; + }); +} + function completedTaskPopupHeading(items) { return first(items, /^[.,,。!!||]*(?:你|您)?(?:已|已经)完成(?:了)?(?:此|该|本|当前)任务[!!。]*$/, isCenteredPopupItem); } @@ -1459,8 +1552,28 @@ function handleVideosLoop(returnPattern) { var completedCloseAttempts = 0; var offerButtonMissingSince = null; var piggybankMissingSince = null; + var inviteCloseMissingSince = null, inviteCloseAttempts = 0; while (Date.now() < deadline) { var items = snapshot(); + // 邀请现金红包只关闭,不操作现金金额或弹窗背后的任务导航。 + if (dismissOnlyPromoPopupHeading(items)) { + var inviteClose = findInviteCashPopupClose(items); + if (inviteClose) { + if (++inviteCloseAttempts > 3) stopWith("推广弹窗连续三次关闭未响应,保留现场"); + writeRunLog("INVITE CASH CLOSE: 关闭邀请现金、推荐官或抽奖推广弹窗,继续原流程。"); + tap(inviteClose, findInviteCashPopupClose); + } else { + if (inviteCloseMissingSince === null) inviteCloseMissingSince = Date.now(); + if (Date.now() - inviteCloseMissingSince < CONFIG.pageTimeoutMs) { sleep(CONFIG.pollMs); continue; } + writeRunLog("INVITE CASH CLOSE: 叉号暂未识别,返回一次关闭推广弹窗并复查。"); + if (back() === false) stopWith("推广弹窗返回关闭失败,保留现场"); + actionSerial++; sleep(CONFIG.pollMs); + if (dismissOnlyPromoPopupHeading(snapshot())) stopWith("推广弹窗返回后仍存在,保留现场"); + } + stableReturn = 0; + continue; + } + inviteCloseMissingSince = null; inviteCloseAttempts = 0; // 明确已完成的任务弹窗只关闭,不能被高金币、继续观看或背景倒计时抢占。 if (completedTaskPopupHeading(items)) { var completedClose = findCompletedTaskPopupClose(items); diff --git a/fanqie_auto/fanqie-flow.md b/fanqie_auto/fanqie-flow.md index 0384c5a..dde258b 100644 --- a/fanqie_auto/fanqie-flow.md +++ b/fanqie_auto/fanqie-flow.md @@ -514,3 +514,21 @@ tasks-91-awake1(2026-10-24,OPPO):读书挑战金币加入宝箱同类的 版本 `2026-10-26-tasks-119-piggybank-digits`:按对应奖励标签列识别金额,允许单个窄数字,原生字符按位置拼接;text/desc重复节点去重,原生与OCR分别组装、交叉一致才采用,避免重复拼接或选择背景金额。新增现场fixture及5项测试通过,出版物重试6项仍通过。全套92项71通过、21项既有失败,没有新增失败。 OPPO真机10:33:33识别1144并点击看视频领更多,广告倒计时结束后10:34:25关闭“领取成功”页面,10:34:29确认通用处理交还任务。随后启动正式新版。正式文件两端SHA256一致:`c745ff1a2ddb9d1b3ae158168c421bc31aa967a05e568daca38d2b4f24c36e1c`。未声称今日全部业务奖励已领取。 + +## 2026-10-26 vivo邀请现金红包自动关闭 + +版本 `2026-10-26-tasks-120-invite-dismiss`。同时确认“送你现金红包”和“邀请好友立得”后优先关闭中央弹窗,兼容现场OCR将叉号读成“メ”;不点击现金奖励或背景任务。叉号缺失时短暂等待,再返回一次并复查。新增现场文字fixture及4项行为测试,全部通过,语法检查通过。 + +vivo真机13:14:38自动点击中央关闭,13:14:42确认邀请弹窗已消失,随后重新启动正式脚本。`/sdcard/脚本/番茄/fanqie-daily.auto.js` 与根目录同名副本均已同步,SHA256与本机一致:`73e4d28d18c3c74ba5bd2c74d7dea316f3a33bd86299ba4a20f2dd8ec9552bef`。本次未核验整个出版物及后续流程完成。 + +## 2026-10-26 小说推荐官推广弹窗关闭 + +版本 `2026-10-26-tasks-121-promotional-dismiss`。组合确认“小说推荐官”“赠送好友VIP会员”“查看权益”后优先关闭推广层,不点击权益或背景任务。现场返回键不能关闭且OCR漏掉叉号,补充原生ImageView识别:仅取已确认推广弹窗父容器底部、权益按钮下方、中央的方形图标。 + +语法检查及7项针对性测试通过。vivo13:26:18自动点击“关闭推广弹窗”,13:26:21复查确认推广弹窗消失。正式版两个路径已同步,SHA256均为 `9b6f6ff6af1c07bf954c47ffed9dff8655e162d56f1ff20a6a05823bf1152a45`。随后唤醒屏幕、解锁并重新启动正式脚本;未宣称整个业务流程已完成。 + +## 2026-10-26 抽奖推广弹窗关闭 + +版本 `2026-10-26-tasks-123-promo-cross`。新增“抽奖赢好礼/抽奖嘉好礼”与“前往抽奖/前住抽奖”的组合判定,优先关闭推广层。该弹窗原生树没有关闭控件,OCR受背景文字干扰漏掉白色叉号,因此在已确认推广按钮下方的中央区域检查白色X四条斜臂与暗色间隙,再点击识别结果;不点击推广按钮。 + +语法检查及10项针对性测试通过。vivo13:43:01识别白色叉号,13:43:02点击关闭,13:43:05复查确认弹窗消失。两个正式脚本路径均覆盖并校验SHA256:`0d24668c0314f1e82f1e2e78bee9d219a14e378e54bed42d78ea9f5cfd95ae54`。正式脚本重新运行,13:43:49重新进入番茄小说,13:43:58已进入赚钱页并执行签到搜索;未验证整轮任务完成。 diff --git a/fanqie_auto/tests/fixtures/vivo-invite-cash-popup.json b/fanqie_auto/tests/fixtures/vivo-invite-cash-popup.json new file mode 100644 index 0000000..3635f56 --- /dev/null +++ b/fanqie_auto/tests/fixtures/vivo-invite-cash-popup.json @@ -0,0 +1 @@ +[{"text":"121","rect":{"left":405,"top":868,"right":625,"bottom":1070}},{"text":"Q水浒传","rect":{"left":105,"top":144,"right":332,"bottom":193}},{"text":"听经典影视原著","rect":{"left":98,"top":421,"right":561,"bottom":466}},{"text":"列计中典","rect":{"left":73,"top":1244,"right":137,"bottom":1619}},{"text":"听书看剧经典短篇机频知识","rect":{"left":23,"top":285,"right":950,"bottom":346}},{"text":"孙引","rect":{"left":63,"top":1257,"right":160,"bottom":1306}},{"text":"书","rect":{"left":67,"top":1414,"right":161,"bottom":1458}},{"text":"奥藏1","rect":{"left":82,"top":1571,"right":335,"bottom":1619}},{"text":"[珍畫版","rect":{"left":232,"top":1705,"right":333,"bottom":1730}},{"text":"书城","rect":{"left":76,"top":2296,"right":179,"bottom":2345}},{"text":"|全集","rect":{"left":230,"top":1901,"right":338,"bottom":1951}},{"text":"DALECARNEGIE","rect":{"left":223,"top":2179,"right":347,"bottom":2191}},{"text":"人性的弱点","rect":{"left":68,"top":1796,"right":502,"bottom":1885}},{"text":"3番茄小小说","rect":{"left":443,"top":620,"right":644,"bottom":663}},{"text":"送你现金红包","rect":{"left":410,"top":767,"right":671,"bottom":809}},{"text":"AND","rect":{"left":365,"top":2059,"right":406,"bottom":2072}},{"text":"121元","rect":{"left":414,"top":902,"right":672,"bottom":1005}},{"text":"HOWTO","rect":{"left":365,"top":2002,"right":447,"bottom":2016}},{"text":"WIN","rect":{"left":365,"top":2021,"right":404,"bottom":2035}},{"text":"邀请好友立得","rect":{"left":416,"top":1443,"right":660,"bottom":1480}},{"text":"PRIENDs","rect":{"left":365,"top":2031,"right":448,"bottom":2059}},{"text":"短剧","rect":{"left":280,"top":2296,"right":386,"bottom":2345}},{"text":"PEOPLE","rect":{"left":365,"top":2094,"right":441,"bottom":2110}},{"text":"后**提现0.3元","rect":{"left":453,"top":1108,"right":705,"bottom":1143}},{"text":"INFLUENCE","rect":{"left":365,"top":2072,"right":477,"bottom":2093}},{"text":"メ","rect":{"left":522,"top":1720,"right":558,"bottom":1753}},{"text":"R460100","rect":{"left":704,"top":27,"right":974,"bottom":68}},{"text":"|他是浪漫达的時人","rect":{"left":589,"top":2157,"right":694,"bottom":2175}},{"text":"文学","rect":{"left":687,"top":421,"right":782,"bottom":466}},{"text":"赚钱","rect":{"left":478,"top":2294,"right":597,"bottom":2352}},{"text":"KB/S","rect":{"left":754,"top":53,"right":796,"bottom":67}},{"text":"也是奇思想的发明家","rect":{"left":589,"top":2181,"right":710,"bottom":2193}},{"text":"他是特立行的书画大师","rect":{"left":589,"top":2201,"right":723,"bottom":2213}},{"text":"中馬热學活的t货","rect":{"left":589,"top":2216,"right":721,"bottom":2232}},{"text":"88分类","rect":{"left":846,"top":144,"right":998,"bottom":191}},{"text":"书架","rect":{"left":691,"top":2296,"right":796,"bottom":2338}},{"text":"完盟再现苏东坡六十四年跌行起伏的传奇一","rect":{"left":873,"top":1659,"right":891,"bottom":1975}},{"text":"解","rect":{"left":983,"top":557,"right":1000,"bottom":576}},{"text":"苏东坡全传","rect":{"left":901,"top":1657,"right":992,"bottom":2080}},{"text":"我的","rect":{"left":894,"top":2296,"right":1002,"bottom":2345}}] \ No newline at end of file diff --git a/fanqie_auto/tests/fixtures/vivo-raffle-popup.json b/fanqie_auto/tests/fixtures/vivo-raffle-popup.json new file mode 100644 index 0000000..eeaf142 --- /dev/null +++ b/fanqie_auto/tests/fixtures/vivo-raffle-popup.json @@ -0,0 +1 @@ +[{"text":"13:38のD","rect":{"left":61,"top":28,"right":283,"bottom":68}},{"text":"福利中心福利商城番茄柿堂","rect":{"left":72,"top":132,"right":968,"bottom":207}},{"text":"读书挑战賽3655金币","rect":{"left":74,"top":385,"right":584,"bottom":432}},{"text":"完成阅读任务,获得相应金币奖励","rect":{"left":91,"top":450,"right":580,"bottom":481}},{"text":"日","rect":{"left":85,"top":781,"right":137,"bottom":825}},{"text":"|去阅读","rect":{"left":165,"top":234,"right":288,"bottom":270}},{"text":"吃","rect":{"left":80,"top":1278,"right":137,"bottom":1320}},{"text":"|新","rect":{"left":86,"top":1350,"right":133,"bottom":1382}},{"text":"阅读1分钟","rect":{"left":136,"top":546,"right":279,"bottom":576}},{"text":"1589","rect":{"left":184,"top":599,"right":257,"bottom":627}},{"text":"主","rect":{"left":92,"top":1552,"right":116,"bottom":1577}},{"text":"|去听书","rect":{"left":488,"top":236,"right":584,"bottom":267}},{"text":"再看9章","rect":{"left":435,"top":544,"right":583,"bottom":578}},{"text":"1033","rect":{"left":484,"top":599,"right":558,"bottom":626}},{"text":"书城","rect":{"left":77,"top":2297,"right":187,"bottom":2349}},{"text":"短剧","rect":{"left":281,"top":2296,"right":382,"bottom":2345}},{"text":"抽奖嘉好礼","rect":{"left":275,"top":976,"right":802,"bottom":1116}},{"text":"AD","rect":{"left":505,"top":1294,"right":572,"bottom":1347}},{"text":"天天领金币最高484850","rect":{"left":92,"top":1680,"right":631,"bottom":1725}},{"text":"今日签到立即领30全币,做任x最高领","rect":{"left":91,"top":1740,"right":654,"bottom":1779}},{"text":"484820金币","rect":{"left":91,"top":1786,"right":274,"bottom":1815}},{"text":"RAFFLEPRIZES","rect":{"left":501,"top":952,"right":759,"bottom":997}},{"text":"前住抽奖","rect":{"left":428,"top":1457,"right":651,"bottom":1510}},{"text":"金币红包雨●最高2000","rect":{"left":78,"top":1913,"right":588,"bottom":1961}},{"text":"KB/S","rect":{"left":754,"top":53,"right":796,"bottom":67}},{"text":"|新玩法一大波红包来袭,先到先得","rect":{"left":86,"top":1989,"right":604,"bottom":2025}},{"text":"刷视频领取双重奖成最高1514","rect":{"left":77,"top":2125,"right":755,"bottom":2173}},{"text":"累计观看多个视频或观看指定视频,均可获得","rect":{"left":92,"top":2190,"right":748,"bottom":2223}},{"text":"看短剧","rect":{"left":783,"top":236,"right":878,"bottom":267}},{"text":"再看29章节","rect":{"left":737,"top":546,"right":905,"bottom":577}},{"text":"1033","rect":{"left":786,"top":599,"right":859,"bottom":626}},{"text":"升级","rect":{"left":887,"top":128,"right":979,"bottom":167}},{"text":"去阅读","rect":{"left":844,"top":419,"right":940,"bottom":449}},{"text":"賺线|书架","rect":{"left":478,"top":2294,"right":796,"bottom":2352}},{"text":"去领取","rect":{"left":841,"top":1734,"right":938,"bottom":1764}},{"text":"点击领领10","rect":{"left":794,"top":2067,"right":934,"bottom":2097}},{"text":"冒5","rect":{"left":951,"top":1155,"right":1006,"bottom":1180}},{"text":"立即领取","rect":{"left":825,"top":2178,"right":954,"bottom":2210}},{"text":"我的","rect":{"left":897,"top":2296,"right":1002,"bottom":2347}},{"text":"开","rect":{"left":1014,"top":1266,"right":1073,"bottom":1303}}] \ No newline at end of file diff --git a/fanqie_auto/tests/fixtures/vivo-recommendation-popup.json b/fanqie_auto/tests/fixtures/vivo-recommendation-popup.json new file mode 100644 index 0000000..98e0cb2 --- /dev/null +++ b/fanqie_auto/tests/fixtures/vivo-recommendation-popup.json @@ -0,0 +1 @@ +[{"text":"13:229T","rect":{"left":83,"top":29,"right":345,"bottom":71}},{"text":"福利中心福利商城","rect":{"left":74,"top":146,"right":626,"bottom":204}},{"text":"日","rect":{"left":98,"top":784,"right":130,"bottom":824}},{"text":"读书挑战赛3655金币","rect":{"left":91,"top":386,"right":570,"bottom":430}},{"text":"完成阅读任务,获得相应金币奖励","rect":{"left":91,"top":453,"right":581,"bottom":486}},{"text":"阅读1分钟","rect":{"left":135,"top":547,"right":277,"bottom":579}},{"text":"看1","rect":{"left":78,"top":881,"right":160,"bottom":929}},{"text":"00","rect":{"left":123,"top":943,"right":152,"bottom":992}},{"text":"吃","rect":{"left":79,"top":1289,"right":160,"bottom":1332}},{"text":"去阅读","rect":{"left":181,"top":239,"right":276,"bottom":269}},{"text":"新可","rect":{"left":87,"top":1367,"right":153,"bottom":1396}},{"text":"抽1","rect":{"left":77,"top":1500,"right":160,"bottom":1548}},{"text":"恭喜你戍为","rect":{"left":241,"top":664,"right":444,"bottom":703}},{"text":"去听书","rect":{"left":488,"top":237,"right":582,"bottom":268}},{"text":"再看9章节","rect":{"left":435,"top":546,"right":581,"bottom":581}},{"text":"小说推荐官","rect":{"left":243,"top":720,"right":514,"bottom":771}},{"text":"书城","rect":{"left":77,"top":2296,"right":182,"bottom":2343}},{"text":"使用专属特权","rect":{"left":390,"top":882,"right":684,"bottom":931}},{"text":"赠送好友VIP会员","rect":{"left":353,"top":945,"right":724,"bottom":992}},{"text":"VIP会员30天","rect":{"left":280,"top":1335,"right":469,"bottom":1364}},{"text":"你可以获得以下权益","rect":{"left":393,"top":1063,"right":688,"bottom":1094}},{"text":"天夭领金币最高484850","rect":{"left":92,"top":1694,"right":630,"bottom":1740}},{"text":"短剧","rect":{"left":280,"top":2296,"right":386,"bottom":2345}},{"text":"查看权益","rect":{"left":454,"top":1467,"right":626,"bottom":1508}},{"text":"今日签到立即领30金币,個文最高领","rect":{"left":91,"top":1753,"right":656,"bottom":1793}},{"text":"484820金币","rect":{"left":91,"top":1799,"right":274,"bottom":1828}},{"text":"金币红包雨最高2000","rect":{"left":92,"top":1930,"right":575,"bottom":1971}},{"text":"|新玩法一大波红包来袭,先到先得","rect":{"left":102,"top":2005,"right":596,"bottom":2038}},{"text":"N100","rect":{"left":734,"top":29,"right":997,"bottom":69}},{"text":"番前柿業","rect":{"left":695,"top":149,"right":942,"bottom":205}},{"text":"最高金币13万","rect":{"left":601,"top":1334,"right":799,"bottom":1364}},{"text":"13万","rect":{"left":711,"top":1162,"right":766,"bottom":1184}},{"text":"刷视频领取双重奖励最高1514","rect":{"left":77,"top":2137,"right":755,"bottom":2184}},{"text":"累计观看多个视频或观看指定视频,均可获得","rect":{"left":92,"top":2203,"right":748,"bottom":2235}},{"text":"看短剧","rect":{"left":783,"top":239,"right":878,"bottom":270}},{"text":"(升级","rect":{"left":887,"top":130,"right":979,"bottom":166}},{"text":"再看29章节","rect":{"left":736,"top":549,"right":906,"bottom":580}},{"text":"去阅读","rect":{"left":844,"top":422,"right":940,"bottom":452}},{"text":"|再送","rect":{"left":912,"top":1038,"right":1011,"bottom":1075}},{"text":"去领取","rect":{"left":841,"top":1747,"right":938,"bottom":1778}},{"text":"点击领10","rect":{"left":794,"top":2067,"right":934,"bottom":2098}},{"text":"看5","rect":{"left":946,"top":1163,"right":993,"bottom":1191}},{"text":"立即领取","rect":{"left":826,"top":2192,"right":955,"bottom":2223}},{"text":"赚钱架我的","rect":{"left":477,"top":2293,"right":1002,"bottom":2353}}] \ No newline at end of file diff --git a/fanqie_auto/tests/invite-cash.test.js b/fanqie_auto/tests/invite-cash.test.js new file mode 100644 index 0000000..94527f4 --- /dev/null +++ b/fanqie_auto/tests/invite-cash.test.js @@ -0,0 +1,66 @@ +const test=require('node:test'),assert=require('node:assert/strict'); +const fs=require('node:fs'),vm=require('node:vm'),path=require('node:path'); +const source=fs.readFileSync(path.join(__dirname,'../fanqie-daily.auto.js'),'utf8'); +function load(){let now=0;const c=vm.createContext({Date:{now:()=>now},Math,JSON,Error,isFinite}); +vm.runInContext(source.slice(0,source.lastIndexOf('\ntry {\n runDaily();')),c); +c.device={width:1080,height:2400};c.sleep=ms=>now+=ms;c.writeRunLog=()=>{}; +const page=JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/vivo-invite-cash-popup.json'),'utf8'));return {c,page};} +test('vivo邀请现金红包识别メ为中央关闭,优先通用处理',()=>{const {c,page}=load(); +assert.ok(c.inviteCashPopupHeading(page));assert.equal(c.findInviteCashPopupClose(page).text,'メ');assert.equal(c.needsCommonHandling(page),true);}); +test('缺少邀请组合特征不关闭普通现金签到或背景叉号',()=>{const {c,page}=load(); +for(const text of ['送你现金红包','邀请好友立得']){const p=page.filter(i=>i.text!==text);assert.equal(c.inviteCashPopupHeading(p),null);assert.equal(c.findInviteCashPopupClose(p),null);}}); +test('处理邀请弹窗先关闭,不进入背景金币或导航流程',()=>{const {c,page}=load();let current=page,closed=0; +c.snapshot=()=>current;c.tap=(button)=>{assert.equal(button.text,'メ');closed++;current=[];}; +c.completedTaskPopupHeading=()=>{throw Error('背景规则不得先执行');}; +c.sleep=()=>{if(!current.length)throw Error('验证结束');}; +assert.throws(()=>c.handleVideosLoop(/./),/背景规则不得先执行/);assert.equal(closed,1);}); +test('中央关闭坐标约束,不用顶部背景X作为邀请关闭',()=>{const {c,page}=load(); +const p=page.filter(i=>i.text!=='メ');p.push({text:'X',rect:{left:990,right:1030,top:100,bottom:140}}); +assert.equal(c.findInviteCashPopupClose(p),null);}); + +test('vivo小说推荐官推广弹窗只关闭,不点查看权益',()=>{ + const {c}=load();const page=JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/vivo-recommendation-popup.json'),'utf8')); + assert.equal(c.dismissOnlyPromoPopupHeading(page).text,'小说推荐官');assert.equal(c.needsCommonHandling(page),true); + assert.equal(c.findInviteCashPopupClose(page),null,'现场没有可识别关闭叉号,走返回复查'); + for(const text of ['赠送好友VIP会员','查看权益'])assert.equal(c.dismissOnlyPromoPopupHeading(page.filter(x=>x.text!==text)),null); +}); +test('无叉号的推荐官弹窗返回一次关闭,确认消失后交还后续处理',()=>{ + const {c}=load();const page=JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/vivo-recommendation-popup.json'),'utf8')); + let current=page,backs=0;c.snapshot=()=>current;c.back=()=>{backs++;current=[];return true;}; + c.tap=()=>{throw Error('不得点击权益或背景按钮');}; + c.completedTaskPopupHeading=()=>{throw Error('后续处理已接管');}; + assert.throws(()=>c.handleVideosLoop(/./),/后续处理已接管/);assert.equal(backs,1); +}); +test('原生无文字推广关闭图标按弹窗父容器及位置识别,不点击权益',()=>{ + const {c}=load();const page=JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/vivo-recommendation-popup.json'),'utf8')); + const close={bounds:()=>({left:485,top:1726,right:596,bottom:1837}),visibleToUser:()=>true, + parent:()=>({bounds:()=>({left:152,top:563,right:928,bottom:1837})})}; + c.className=name=>{assert.equal(name,'android.widget.ImageView');return {packageName:()=>({find:()=>({size:()=>1,get:()=>close})})};}; + c.appendNativePromoClose(page);assert.equal(c.findInviteCashPopupClose(page).text,'关闭推广弹窗'); + const noHeading=page.filter(x=>x.text!=='小说推荐官'&&x.text!=='关闭推广弹窗');c.appendNativePromoClose(noHeading); + assert.equal(c.findInviteCashPopupClose(noHeading),null); +}); +test('抽奖推广标题与前往按钮同时存在才触发关闭,不把普通抽奖任务当弹窗',()=>{ + const {c}=load();const page=JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/vivo-raffle-popup.json'),'utf8')); + assert.equal(c.dismissOnlyPromoPopupHeading(page).text,'抽奖嘉好礼');assert.equal(c.needsCommonHandling(page),true); + assert.equal(c.dismissOnlyPromoPopupHeading(page.filter(x=>x.text!=='前住抽奖')),null); +}); +test('抽奖推广叉号局部OCR仅扫描操作按钮下方中央区域',()=>{ + const {c}=load();const page=JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/vivo-raffle-popup.json'),'utf8'));let calls=0; + c.readPromoCross=()=>{}; + c.readCloseRegion=(frame,items,region)=>{calls++;assert.ok(region.top>1510);assert.ok(region.left>=1080*.4); + items.push({text:'X',rect:{left:522,top:1740,right:558,bottom:1790}});}; + c.readReceiptCloseRegion({},page);assert.equal(calls,1);assert.equal(c.findInviteCashPopupClose(page).text,'X'); +}); + + test('白色叉号图形检测定位四条斜臂,拒绝实心白块和区域外悬浮叉号',()=>{ + const {c}=load();const action={rect:{bottom:1510}}; + function pixels(cx,cy,solid){return {pixel:(_frame,x,y)=>{ + const dx=x-cx,dy=y-cy;const white=solid?Math.abs(dx)<18&&Math.abs(dy)<18: + Math.abs(dx)<=14&&Math.abs(dy)<=14&&Math.abs(Math.abs(dx)-Math.abs(dy))<=2; + return white?0xffffffff:0xff444444;}};} + for(const [cx,cy,solid,expected] of [[540,1766,false,true],[540,1766,true,false],[990,1766,false,false]]){ + c.images=pixels(cx,cy,solid);const items=[];c.readPromoCross({},items,action); + assert.equal(items.length>0,expected);if(expected){const r=items[0].rect;assert.ok(Math.abs((r.left+r.right)/2-cx)<=2);} + } + }); diff --git a/hongguo_auto/README.md b/hongguo_auto/README.md index 46f309e..cae8c66 100644 --- a/hongguo_auto/README.md +++ b/hongguo_auto/README.md @@ -88,3 +88,5 @@ OPPO 真机 hongguo-12:12:41:16 命中“领午饭补补贴90金币”,12:41 ## 2026-10-22 启动修复(hongguo-13) 每次启动先保持亮屏,将 AutoJs6 切到前台并自动确认系统“整个屏幕”截屏授权,再到目标应用详情执行强行停止和重开。亮屏保持整个流程,退出时释放;截图授权恢复只回到当前应用,不重新关闭应用。管理器原 10 分钟超时会主动结束正常任务,本次 OPPO 已改为 120 分钟。启动与调度验证见 `../task_manager/README.md`。 + +2026-10-26:版本22修复OPPO“恭喜获得追剧奖励”上下排列的双金额弹窗。原规则仅比较同一行,导致漏掉“看视频领3220金币”和“直接领取939金币”,并在弹窗上空滑搜索任务。新增标题与成对中央按钮的组合判定,沿用金额阈值规则(存在>=500时选较大,否则选较小)。3项针对性测试及语法检查通过。OPPO14:40:22实际点击3220金币按钮,广告倒计时结束后14:40:56识别领取成功并关闭广告。正式文件已同步至`/sdcard/脚本/红果/hongguo-daily.auto.js`,电脑与手机SHA256一致:`7012247625511ded2e284a4cbab61b84d9af011c8fe67a60fe9e01cdc8c7ddd4`。 diff --git a/hongguo_auto/hongguo-daily.auto.js b/hongguo_auto/hongguo-daily.auto.js index 93412ea..61198cb 100644 --- a/hongguo_auto/hongguo-daily.auto.js +++ b/hongguo_auto/hongguo-daily.auto.js @@ -4,7 +4,7 @@ // 页面识别:无障碍文字 + 可选的本地 $ocr.detect;图片不上传、不写入日志。 // 福利 → 签到 → 翻卡 → 红包10连开 → 看视频赚海量金币 → 追剧挑战赛;不执行阅读和吃饭补贴。 var CONFIG = { - version: "2026-10-25-hongguo-21-popup-transition", + version: "2026-10-26-hongguo-22-drama-choice", packageName: "com.phoenix.read", rewardThreshold: 500, pollMs: 1200, @@ -816,6 +816,24 @@ function findEmptyRewardPopupClose(items, ignoreCoinClaim) { } function findCoinChoiceClaim(items) { + // 追剧奖励的两个主按钮上下排列,不能按同一行比较。 + var dramaReward = first(items, /^恭喜[获荻]得追剧奖励$/, isCenteredPopupItem); + if (dramaReward) { + var videoClaim = first(items, /^看视频领\d+(?:,\d{3})*金币$/, function (item) { + return isCenteredPopupItem(item) && item.rect.top > dramaReward.rect.bottom; + }); + var directClaim = first(items, /^直接领取\d+(?:,\d{3})*金币$/, function (item) { + return isCenteredPopupItem(item) && videoClaim && item.rect.top > videoClaim.rect.bottom && + item.rect.top - videoClaim.rect.bottom < device.height * 0.12; + }); + if (videoClaim && directClaim) { + var videoAmount = Number(videoClaim.text.replace(/[^\d]/g, "")); + var directAmount = Number(directClaim.text.replace(/[^\d]/g, "")); + return Math.max(videoAmount, directAmount) >= CONFIG.rewardThreshold ? + (videoAmount > directAmount ? videoClaim : directClaim) : + (videoAmount < directAmount ? videoClaim : directClaim); + } + } // 红果惊喜红包把视频金额与按钮分开显示,必须在同一前景层内比较两个选项。 var surprise = first(items, /^额外看剧惊喜红包$/, isCenteredPopupItem); if (surprise) { diff --git a/hongguo_auto/tests/drama-choice.test.js b/hongguo_auto/tests/drama-choice.test.js new file mode 100644 index 0000000..7a6a354 --- /dev/null +++ b/hongguo_auto/tests/drama-choice.test.js @@ -0,0 +1,6 @@ +const test=require('node:test'),assert=require('node:assert/strict'),fs=require('node:fs'),vm=require('node:vm'),path=require('node:path'); +const source=fs.readFileSync(path.join(__dirname,'../hongguo-daily.auto.js'),'utf8'); +function setup(){const c=vm.createContext({});vm.runInContext(source.slice(0,source.lastIndexOf('\ntry {')),c);c.device={width:1080,height:2400};return {c,p:JSON.parse(fs.readFileSync(path.join(__dirname,'fixtures/oppo-drama-choice.json'),'utf8'))};} +test('OPPO上下排列追剧奖励选3220而非939,并触发通用处理',()=>{const {c,p}=setup();assert.equal(c.findCoinChoiceClaim(p).text,'看视频领3220金币');assert.equal(c.needsCommonHandling(p),true);}); +test('缺少追剧弹窗标题或成对按钮不混入背景任务',()=>{const {c,p}=setup();for(const pattern of [/恭喜[获荻]得追剧奖励/,/^直接领取939金币$/,/^看视频领3220金币$/])assert.equal(c.findCoinChoiceClaim(p.filter(x=>!pattern.test(x.text))),null);}); +test('保留500金币阈值规则,两选项都低于阈值选较小',()=>{const {c,p}=setup();p.forEach(x=>{x.text=x.text.replace('3220金币','320金币').replace('939金币','99金币');});assert.equal(c.findCoinChoiceClaim(p).text,'直接领取99金币');}); diff --git a/hongguo_auto/tests/fixtures/oppo-drama-choice.json b/hongguo_auto/tests/fixtures/oppo-drama-choice.json new file mode 100644 index 0000000..3b22538 --- /dev/null +++ b/hongguo_auto/tests/fixtures/oppo-drama-choice.json @@ -0,0 +1 @@ +[{"text":"恭喜获得追剧奖励","rect":{"left":325,"top":697,"right":757,"bottom":772}},{"text":"939","rect":{"left":315,"top":1108,"right":424,"bottom":1179}},{"text":"直接领取","rect":{"left":297,"top":1196,"right":441,"bottom":1238}},{"text":"3220","rect":{"left":650,"top":1108,"right":791,"bottom":1179}},{"text":"看视频领取","rect":{"left":631,"top":1196,"right":811,"bottom":1238},"darkButton":false},{"text":"看视频领3220金币","rect":{"left":340,"top":1370,"right":743,"bottom":1427}},{"text":"直接领取939金币","rect":{"left":354,"top":1500,"right":727,"bottom":1557}},{"text":"common-info-modalbackground","rect":{"left":153,"top":614,"right":928,"bottom":1514}},{"text":"rewardcoin","rect":{"left":228,"top":814,"right":510,"bottom":1096}},{"text":"rewardcoin","rect":{"left":580,"top":814,"right":862,"bottom":1096}},{"text":"doubleinfotransition","rect":{"left":499,"top":998,"right":595,"bottom":1058}},{"text":"关闭","rect":{"left":481,"top":1713,"right":601,"bottom":1833}},{"text":"金币收益>","rect":{"left":68,"top":206,"right":221,"bottom":237}},{"text":"5.1元","rect":{"left":68,"top":289,"right":224,"bottom":356}},{"text":"看短","rect":{"left":54,"top":759,"right":166,"bottom":812}},{"text":"0点自动兑现金(可能存在延迟)","rect":{"left":67,"top":401,"right":521,"bottom":432}},{"text":"看短","rect":{"left":57,"top":897,"right":165,"bottom":943}},{"text":"再機7","rect":{"left":61,"top":965,"right":155,"bottom":1001}},{"text":"待领","rect":{"left":77,"top":1192,"right":159,"bottom":1226}},{"text":"迫剧","rect":{"left":72,"top":1338,"right":152,"bottom":1378}},{"text":"完成通","rect":{"left":62,"top":1407,"right":155,"bottom":1438}},{"text":"看","rect":{"left":116,"top":1512,"right":143,"bottom":1534}},{"text":"日常福利","rect":{"left":78,"top":1743,"right":260,"bottom":1788}},{"text":"首页","rect":{"left":82,"top":2229,"right":168,"bottom":2274}},{"text":"现金收益(元)>","rect":{"left":413,"top":204,"right":626,"bottom":238}},{"text":"今日打卡任务待完成","rect":{"left":273,"top":534,"right":637,"bottom":574}},{"text":"13.59","rect":{"left":423,"top":282,"right":638,"bottom":358}},{"text":"恭喜荻得追剧奖励","rect":{"left":328,"top":709,"right":751,"bottom":759}},{"text":"吃饭补贴","rect":{"left":207,"top":2096,"right":375,"bottom":2137}},{"text":"|吃饭补见O50","rect":{"left":180,"top":2087,"right":501,"bottom":2136}},{"text":"天天顿金币最高63014","rect":{"left":188,"top":1850,"right":715,"bottom":1896}},{"text":"剧场","rect":{"left":288,"top":2229,"right":376,"bottom":2274}},{"text":"X","rect":{"left":529,"top":1758,"right":555,"bottom":1786}},{"text":"今日签到立即领10金币,做任务最高领","rect":{"left":204,"top":1920,"right":762,"bottom":1952}},{"text":"63004金币","rect":{"left":203,"top":1960,"right":365,"bottom":1990}},{"text":"Tm十丁头人Hフ2人工","rect":{"left":204,"top":2164,"right":469,"bottom":2176}},{"text":"商城","rect":{"left":495,"top":2229,"right":586,"bottom":2273}},{"text":"福利","rect":{"left":697,"top":2227,"right":792,"bottom":2277}},{"text":"领810金币","rect":{"left":831,"top":401,"right":985,"bottom":432}},{"text":"去打卡>","rect":{"left":874,"top":562,"right":1004,"bottom":598}},{"text":"取","rect":{"left":919,"top":925,"right":990,"bottom":970}},{"text":"取","rect":{"left":921,"top":1367,"right":985,"bottom":1403}},{"text":"点击领2294","rect":{"left":797,"top":1836,"right":979,"bottom":1866}},{"text":"去领取","rect":{"left":827,"top":1896,"right":970,"bottom":1941}},{"text":"|待领","rect":{"left":974,"top":1190,"right":1034,"bottom":1227}},{"text":"去领取","rect":{"left":826,"top":2119,"right":970,"bottom":2163}},{"text":"11","rect":{"left":997,"top":1061,"right":1023,"bottom":1087}},{"text":"|我的","rect":{"left":908,"top":2218,"right":1010,"bottom":2271}}] \ No newline at end of file diff --git a/kuaishou_auto/kuaishou-daily.auto.js b/kuaishou_auto/kuaishou-daily.auto.js index 7736e33..86a020b 100644 --- a/kuaishou_auto/kuaishou-daily.auto.js +++ b/kuaishou_auto/kuaishou-daily.auto.js @@ -2,10 +2,10 @@ // 快手极速版:无障碍文字 + 手机本地 OCR;不保存或上传图片,不访问媒体音量。 var CONFIG = { - version: "2026-10-23-kuaishou-6", + version: "2026-10-26-kuaishou-11-continuous-video", packageName: "com.kuaishou.nebula", pollMs: 1200, - recognitionTimeoutMs: 15000, + recognitionTimeoutMs: 30000, capturePermissionTimeoutMs: 60000, captureRecoveryLimit: 2, useLocalOcr: true, @@ -17,7 +17,7 @@ var CONFIG = { }; var localOcrEnabled = false; var captureQueue = null, captureWorker = null, captureRecoveries = 0; -var rejection = null, rewardSerial = 0; +var rejection = null, rewardSerial = 0, currentRoundRewardCoins = null; var STAGES = [ {name: "看广告得金币", title: /^看广告[得赚]金币$/, kind: "ad", stopAtCoins: 20}, {name: "到饭点领饭补", title: /^到饭点领饭补$/, kind: "meal"}, @@ -25,7 +25,8 @@ var STAGES = [ {name: "搜索看广告", title: /^搜索看广告$/, kind: "search"}, {name: "逛街领金币", title: /^逛街[领赚]金币$/, kind: "street"}, {name: "翻卡赢金币", title: /^翻卡赢金币$/, kind: "flip"}, - {name: "逛快手商城赚金币", title: /^逛(?:快手|开售)商城[赚领]金币$/, kind: "mall", products: 6} + {name: "逛快手商城赚金币", title: /^逛(?:快手|开售)商城[赚领]金币$/, kind: "mall", products: 6}, + {name: "连续看视频阶段奖励", kind: "continuousVideo"} ]; function writeRunLog(message) { @@ -181,7 +182,7 @@ function captureCall(name, timeoutMs, action) { if (done === null) { captureWorker.interrupt(); captureWorker.join(1500); - var timeout = new Error(name + "超时,截图通道不可用"); + var timeout = new Error(name + "超时,页面读取或截图通道不可用"); timeout.unsafeWorker = true; throw timeout; } @@ -248,6 +249,14 @@ function first(page, pattern, predicate) { } 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) { var item = first(page, /设备异常|账号异常|操作异常|存在风险|风险行为|领取失败|操作过于频繁|操作频繁|任务失败/); if (rejection || item) throw new Error("[NO_RETRY] 平台拒绝:" + (rejection || item.text)); @@ -261,18 +270,21 @@ function readSnapshot() { foreground = foregroundPackage(); } if (foreground !== CONFIG.packageName) throw new Error("页面离开快手极速版(" + foreground + "),停止本轮操作"); - var items = [], selectors = [textMatches(".+"), descMatches(".+"), - idMatches(".*:id/(?:video_countdown|video_countdown_end_icon|.*close.*)")]; - for (var s = 0; s < selectors.length; s++) { - var nodes = selectors[s].find(); - for (var i = 0; i < nodes.size(); i++) { - var node = nodes.get(i), box = rectOf(node.bounds()); - var resourceId = String(node.id() || ""); - var value = compact(s === 1 ? node.desc() : node.text()); - if (!value && s === 2) value = "@" + resourceId.split("/").pop(); - // 排除原生数字滚动器、越界/倒置节点与导航栏下方的伪任务。 - if (box && value && value.length < 120 && node.visibleToUser()) { - items.push({text: value, rect: box, node: node, id: resourceId, enabled: node.enabled()}); + // 一次读取目标应用节点,避免分别按文字、描述、ID重复扫描整棵窗口树。 + // vivo 上切页期间重复全窗口查询可能累积超过识别期限。 + var items = []; + var nodes = packageName(CONFIG.packageName).find(); + for (var i = 0; i < nodes.size(); i++) { + var node = nodes.get(i), box = rectOf(node.bounds()); + if (!box || !node.visibleToUser()) continue; + var resourceId = String(node.id() || ""), enabled = node.enabled(); + var values = [compact(node.text()), compact(node.desc())]; + if (!values[0] && /:id\/(?:video_countdown|video_countdown_end_icon|.*close.*)$/.test(resourceId)) { + values.push("@" + resourceId.split("/").pop()); + } + 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}); } } } @@ -298,6 +310,7 @@ function readSnapshot() { files.write(CONFIG.pageTextPath, JSON.stringify(unique.map(function (item) { return {text: item.text, rect: item.rect, id: item.id, enabled: item.enabled}; }))); + unique.forEach(function (item) {recordRewardCoins(item.text);}); checkRejection(unique); return unique; } @@ -317,7 +330,18 @@ function clickItem(item) { if (foregroundPackage() !== CONFIG.packageName) throw new Error("点击前已离开快手"); var ok = false; if (item.node) { - try { if (item.node.clickable()) ok = item.node.click(); } catch (ignore) {} + try { + 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), Math.round((item.rect.top + item.rect.bottom) / 2), 80); @@ -351,7 +375,7 @@ function isAd(page) { !!first(page, /^广告$/, function (item) {return item.rect.top < device.height * 0.20;}); } function adReward(page) { - return !!first(page, /^(?:已成功领取奖励|奖励已到账|已获得奖励|奖励领取成功|已领取奖励)$/, + return !!first(page, /^(?:已成功领取(?:奖励|\d+(?:,\d{3})*金币)|奖励已到账|已获得奖励|奖励领取成功|已领取奖励)$/, function (item) {return item.rect.top < device.height * 0.25;}); } function adClose(page) { @@ -601,6 +625,7 @@ function browseStreet() { var swipeDown = true, settlingAt = null, lastSeconds = null; while (Date.now() < deadline) { var page = snapshot(), progress = streetProgress(page); + if (currentRoundRewardCoins === 1) return {rewardSeen: true, reason: "单次收益仅1金币"}; if (streetComplete(page)) return {taskDone: true, reason: "页面显示金币已领完"}; if (progress) { if (!previous || progress.done > previous.done) { @@ -773,7 +798,7 @@ function executeRound(row, kind, options) { tapFresh(fresh.action); var deadline = Date.now() + CONFIG.roundTimeoutMs, rewardSeen = false, adSeen = false; var adClosed = false, searchClicked = false, entered = false, claims = {}; - var firstPageAt = Date.now(); + var firstPageAt = Date.now(), searchAttempts = 0; while (Date.now() < deadline) { var page = snapshot(); rewardSeen = rewardSeen || rewardSerial > toastStart; @@ -835,7 +860,15 @@ function executeRound(row, kind, options) { } if (kind === "search" && !searchClicked) { var search = prescribedSearch(page); - if (search) {tapFresh(search); searchClicked = true; sleep(1500); continue;} + if (search) { + 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+金币|金币已到账|领取成功|奖励已到账)$/); if (completion) rewardSeen = true; @@ -865,7 +898,8 @@ function drainTask(initial, kind, options) { var row = locateTask(pattern); if (!row) return {title: title, rounds: rounds, reason: "入口连续两次完整扫描未找到"}; if (row.unavailable) return {title: title, rounds: rounds, reason: "任务已完成或次数用完"}; - var beforeBalance = options.stopAtCoins !== undefined ? coinBalance(snapshot()) : null; + var beforeBalance = coinBalance(snapshot()); + currentRoundRewardCoins = null; var outcome; try { // 逛街在同页连续领取10次,按领取进展重置超时,不套用整项5分钟上限。 @@ -877,12 +911,16 @@ function drainTask(initial, kind, options) { outcome = {error: String(error)}; } 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}; var after = locateTask(pattern); if (resultAdvanced(row, after, outcome.rewardSeen)) { rounds++; noProgress = 0; writeRunLog("ROUND CONFIRMED: " + title + ";已确认=" + rounds); - if (options.stopAtCoins !== undefined) { + { var afterBalance = coinBalance(snapshot()), balanceDeadline = Date.now() + 6000; while (beforeBalance !== null && (afterBalance === null || afterBalance === beforeBalance) && Date.now() < balanceDeadline) { sleep(CONFIG.pollMs); @@ -890,9 +928,10 @@ function drainTask(initial, kind, options) { } var earned = beforeBalance !== null && afterBalance !== null && afterBalance > beforeBalance ? afterBalance - beforeBalance : null; writeRunLog("ROUND COINS: " + title + ";本轮实际金币=" + earned); - if (earned === null) return {title: title, rounds: rounds, incomplete: true, reason: "未确认本轮实际金币,暂停该项以免越过奖励阈值"}; - if (earned <= options.stopAtCoins) return {title: title, rounds: rounds, lastRewardCoins: earned, - reason: "本轮实际金币≤" + options.stopAtCoins + ",结束当前流程"}; + if (earned === null && options.stopAtCoins !== undefined) return {title: title, rounds: rounds, incomplete: true, reason: "未确认本轮实际金币,暂停该项以免越过奖励阈值"}; + var stopAt = options.stopAtCoins !== undefined ? options.stopAtCoins : 1; + if (earned !== null && earned <= stopAt) return {title: title, rounds: rounds, lastRewardCoins: earned, + reason: "本轮实际金币≤" + stopAt + ",结束当前流程"}; } } else if (!outcome.changed && !outcome.unavailable && after && !after.unavailable) { noProgress++; @@ -906,10 +945,85 @@ function drainTask(initial, kind, options) { incomplete: true, reason: "连续3轮未确认进展,保留异常,不冒充任务已完成"}; } } +function continuousVideoCard(page) { + 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, /^(?:去看视频|看视频|继续看视频)$/); + var progressItem = first(region, /^\d+\/\d+$/); + var progress = progressItem && quota(progressItem.text); + var status = first(region, /(?:\d+金币待领取|已领\d+金币)/); + var done = !claim && !!first(region, /今日(?:奖励|金币|任务)?已(?:全部)?(?:领完|领取完|完成)|今日奖励已全部领取|明日再来|明天再来/); + return {claim:claim, watch:watch, progress:progress, done:done, + signature:(progressItem ? progressItem.text : "") + "|" + (status ? status.text : "")}; +} +function locateContinuousVideoCard() { + 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(i1200000) return {title:"连续看视频阶段奖励",rounds:claims,incomplete:true, + reason:"20分钟未确认奖励进展,保留异常,不当作全部领完"}; + if(card.claim) { + tapFresh(card.claim,function(page){var current=continuousVideoCard(page);return current&¤t.claim;}); + var receipt=snapshot(); + if(!first(receipt,/^任务完成奖励$/)) throw new Error("连续看视频领取后未确认奖励到账弹窗"); + 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("连续看视频尚未确认领完,且未找到观看入口"); + tapFresh(card.watch,function(page){var current=continuousVideoCard(page);return current&¤t.watch;}); + var watchUntil=Date.now()+60000; + while(Date.now()text,desc:()=>desc,id:()=>id,bounds:()=>box,visibleToUser:()=>visible,enabled:()=>true};} +test('单次目标应用查询保留文字、描述与无文字广告关闭ID并剔除隐藏节点',()=>{ + const c=vm.createContext({});vm.runInContext(source.slice(0,source.indexOf('// MAIN:')),c); + c.device={width:1080,height:2400};c.keepScreenAwake=()=>{};c.foregroundPackage=()=>c.CONFIG.packageName;c.files={write:()=>{}}; + const box={left:10,top:100,right:200,bottom:160}; + const nodes=[node('任务中心','任务中心','',box),node('','关闭弹窗','',box), + node('','','com.kuaishou.nebula:id/video_countdown_end_icon',box),node('隐藏','','',box,false), + node('越界','','',{left:0,top:2500,right:100,bottom:2600})]; + let queries=0;c.packageName=p=>{assert.equal(p,'com.kuaishou.nebula');return {find:()=>{queries++;return {size:()=>nodes.length,get:i=>nodes[i]};}};}; + const page=c.readSnapshot();assert.equal(queries,1);assert.deepEqual(Array.from(page,x=>x.text),['任务中心','关闭弹窗','@video_countdown_end_icon']); +}); +test('vivo已成功领取14金币后识别原生关闭按钮,倒计时未结束时不关闭',()=>{ + const c=vm.createContext({});vm.runInContext(source.slice(0,source.indexOf('// MAIN:')),c);c.device={width:1080,height:2400}; + const p=JSON.parse(fs.readFileSync(require('node:path').join(__dirname,'fixtures/vivo-ad-reward.json'),'utf8')); + assert.equal(c.adReward(p),true);assert.equal(c.adClose(p).text,'@video_countdown_end_icon'); + for(const label of ['28秒后可领取奖励','0秒后可领取奖励','已成功领取奖励']){ + const page=p.map(x=>({...x,text:x.text==='已成功领取14金币'?label:x.text})); + assert.equal(!!c.adClose(page),label==='已成功领取奖励'); + } + const background=p.map(x=>({...x,rect:{...x.rect,top:1500,bottom:1550}}));assert.equal(c.adClose(background),null); +}); +test('去搜索点击紧邻按钮容器,不点击整行,容器过大时回退文字位置',()=>{ + const c=vm.createContext({});vm.runInContext(source.slice(0,source.indexOf('// MAIN:')),c);c.device={width:1080,height:2400};c.foregroundPackage=()=>c.CONFIG.packageName;c.sleep=()=>{};c.writeRunLog=()=>{}; + let clicks=0,presses=0;c.press=()=>{presses++;return true;}; + const rect={left:822,top:1444,right:963,bottom:1507};let parentBox={left:763,top:1411,right:1022,bottom:1541}; + const parent={bounds:()=>parentBox,enabled:()=>true,clickable:()=>true,click:()=>{clicks++;return true;}}; + const item={text:'去搜索',rect,node:{clickable:()=>false,parent:()=>parent}}; + c.clickItem(item);assert.equal(clicks,1);assert.equal(presses,0); + parentBox={left:43,top:1357,right:1037,bottom:1595};c.clickItem(item);assert.equal(clicks,1);assert.equal(presses,1); +}); +test('实际到账1金币锁定退出信号,最高奖励与余额不触发',()=>{ + const c=vm.createContext({});vm.runInContext(source.slice(0,source.indexOf('// MAIN:')),c); + for(const value of ['最高1金币','金币1','搜索得1金币'])c.recordRewardCoins(value);assert.equal(c.currentRoundRewardCoins,null); + c.recordRewardCoins('已成功领取1金币');c.recordRewardCoins('已获得50金币');assert.equal(c.currentRoundRewardCoins,1); +}); +test('搜索与逛街类目单次1金币退出当前流程',()=>{ + for(const kind of ['search','street']){ + const c=vm.createContext({});vm.runInContext(source.slice(0,source.indexOf('// MAIN:')),c); + c.locateTask=()=>({title:'测试任务'});c.snapshot=()=>[];c.coinBalance=()=>100;c.ensureTaskCenter=()=>{};c.writeRunLog=()=>{}; + c.boundedCall=(_name,_ms,fn)=>fn();c.executeRound=()=>{c.recordRewardCoins('恭喜获得1金币');return {rewardSeen:true};}; + const result=c.drainTask({title:'测试任务'},kind,{});assert.equal(result.lastRewardCoins,1);assert.match(result.reason,/1金币/); + } +}); +test('连续看视频区分待领取、观看和全部领完,阶段进度满不等于全部领完',()=>{ + const c=vm.createContext({});vm.runInContext(source.slice(0,source.indexOf('// MAIN:')),c);c.device={width:1080,height:2400}; + const p=JSON.parse(fs.readFileSync(require('node:path').join(__dirname,'fixtures/vivo-continuous-video.json'),'utf8')); + let card=c.continuousVideoCard(p);assert.equal(card.progress.done,900);assert.equal(card.watch.text,'去看视频');assert.equal(card.done,false); + let ready=p.map(x=>({...x,text:x.text==='去看视频'?'领金币':x.text}));assert.equal(c.continuousVideoCard(ready).claim.text,'领金币'); + let full=p.map(x=>({...x,text:x.text==='900/12112'?'12112/12112':x.text}));assert.equal(c.continuousVideoCard(full).done,false); + const done=p.filter(x=>x.text!=='去看视频');done.push({text:'今日奖励已全部领取',rect:{left:100,top:942,right:800,bottom:990}}); + assert.equal(c.continuousVideoCard(done).done,true); +});