mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-16 03:33:25 +08:00
feat: 自动等待月卡脚本 (#2691)
This commit is contained in:
1
repo/js/SkipMonthlyCard/README.md
Normal file
1
repo/js/SkipMonthlyCard/README.md
Normal file
@@ -0,0 +1 @@
|
||||
可用于少女月卡临时使用或4点前一会儿启动一直等待月卡直到领取完毕
|
||||
BIN
repo/js/SkipMonthlyCard/assets/girl_moon.png
Normal file
BIN
repo/js/SkipMonthlyCard/assets/girl_moon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
repo/js/SkipMonthlyCard/assets/paimon_menu.png
Normal file
BIN
repo/js/SkipMonthlyCard/assets/paimon_menu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
repo/js/SkipMonthlyCard/assets/primogem.png
Normal file
BIN
repo/js/SkipMonthlyCard/assets/primogem.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
repo/js/SkipMonthlyCard/assets/welkin_moon_logo.png
Normal file
BIN
repo/js/SkipMonthlyCard/assets/welkin_moon_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
73
repo/js/SkipMonthlyCard/main.js
Normal file
73
repo/js/SkipMonthlyCard/main.js
Normal 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);
|
||||
}
|
||||
})();
|
||||
14
repo/js/SkipMonthlyCard/manifest.json
Normal file
14
repo/js/SkipMonthlyCard/manifest.json
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user