feat: 自动等待月卡脚本 (#2691)

This commit is contained in:
躁动的氨气
2026-01-16 04:20:58 +08:00
committed by GitHub
parent 1490b6f96a
commit 0ae0c6594f
7 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1 @@
可用于少女月卡临时使用或4点前一会儿启动一直等待月卡直到领取完毕

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -0,0 +1,73 @@
// 图片资源缓存
const img_cache = {};
const template_cache = {};
// 获取图片资源
function getImgMat(path) {
if (!img_cache[path]) {
img_cache[path] = file.readImageMatSync('assets/' + path + '.png');
}
return img_cache[path];
}
// 获取模板
function getTemplate(path) {
if (!template_cache[path]) {
const img_mat = getImgMat(path);
template_cache[path] = RecognitionObject.TemplateMatch(
img_mat,
0, 0, 1920, 1080
);
}
return template_cache[path];
}
// 查找图片
async function findImage(path) {
const searchImg = getTemplate(path);
const captureRegion = captureGameRegion();
const result = captureRegion.find(searchImg);
captureRegion.dispose();
return result.isExist();
}
(async function () {
let success = false;
await genshin.returnMainUi();
while (true) {
const result1 = await findImage("girl_moon");
const result2 = await findImage("welkin_moon_logo");
if (result1 || result2) {
log.info("点击月神");
await sleep(200);
click(100, 100);
await sleep(200);
}
const stone = await findImage("primogem");
if (stone) {
log.info("点击原石");
while (true) {
await sleep(200);
click(100, 100);
await sleep(200);
const isInMainUI = await findImage("paimon_menu");
if (isInMainUI) {
log.info("已进入主页面");
success = true;
await sleep(500);
break;
}
}
}
if (success) {
break;
}
await sleep(2000);
}
})();

View File

@@ -0,0 +1,14 @@
{
"manifest_version": 1,
"name": "自动月卡",
"version": "0.5",
"bgi_version": "0.54.0",
"description": "一直等待直到点击掉月卡",
"authors": [
{
"name": "躁动的氨气",
"links": "https://github.com/zaodonganqi"
}
],
"main": "main.js"
}