2026-11-02 16:01:02 +08:00

28 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 自绘页面仍由 OCR 判断;应用宝首页底部导航优先补充原生的精确文字和真实 bounds。
function findNativeYibaoMoneyEntry(page, ocrItems) {
if (!page || page.packageName !== CONFIG.yibaoPackage) return null;
var items = page.items || [];
var corpus = items.concat(ocrItems || []).map(function (item) {return normalizeText(item.text || item.desc || "");}).join("");
if (/任务未完成|现在退出|恭喜|奖励还差|继续做任务得额外奖励/.test(corpus)) return null;
if (!/热门软件|热门游戏/.test(corpus)) return null;
var footer = items.filter(function (item) {
return item.enabled !== false && item.bounds && item.bounds.left >= 0 && item.bounds.right <= device.width &&
item.bounds.bottom <= device.height && item.centerY >= device.height * .90;
});
var labels = footer.map(function (item) {return normalizeText(item.text || item.desc);});
if (["首页", "秒玩", "商城", "我的"].some(function (label) {return labels.indexOf(label) < 0;})) return null;
var entries = footer.filter(function (item) {return normalizeText(item.text || item.desc) === "赚钱";});
return entries.length === 1 ? entries[0] : null;
}
function supplementYibaoNavigation(items) {
if (!items || !items.length) return items;
var entry = findNativeYibaoMoneyEntry(readCommonInstallPage(), items);
if (!entry) return items;
var alreadyExact = items.some(function (item) {
return normalizeText(item.text) === "赚钱" && Math.abs(item.centerY - entry.centerY) < 40;
});
if (alreadyExact) return items;
log("首页底部赚钱使用原生文字补充 OCR,bounds=" + JSON.stringify(entry.bounds));
return items.concat([{text:"赚钱",bounds:entry.bounds,centerX:entry.centerX,centerY:entry.centerY,enabled:true,source:"native"}]);
}