js: CD-Aware-AutoGather: 移除失效的脚本路径获取方法 (#2365)

This commit is contained in:
Patrick-Ze
2025-11-17 22:44:27 +08:00
committed by GitHub
parent e495523c87
commit 292d499ef1
4 changed files with 8 additions and 27 deletions

View File

@@ -2,6 +2,8 @@
**双击运行脚本所在目录下的`SymLink.bat`文件,以创建符号链接。**
(脚本所在目录为你的BetterGI安装位置下面的`repo\js\CD-Aware-AutoGather`文件夹)
此操作只需要一次。运行后,脚本下的`pathing`文件夹将指向Better GI的地图追踪文件夹`User\AutoPathing`你通过Better GI新增或删除地图追踪任务后脚本这边看到的也是修改后的。
# 运行模式

View File

@@ -7,7 +7,7 @@
let scriptContext = {
scriptStartTime: new Date(),
version: "1.2",
version: "1.3",
};
/**
@@ -368,23 +368,6 @@ async function getGameAccount(multiAccount = false, mask = true) {
return account;
}
/**
* 获取脚本所在文件夹路径
* @returns {string|null} 脚本所在文件夹路径,若未获取到则返回 null
*/
function getScriptDirPath() {
try {
file.readTextSync(`Ayaka-Main-${Math.random()}.txt`);
} catch (error) {
const err_msg = error.toString();
const match = err_msg.match(/'([^']+)'/);
const fullPath = match ? match[1] : null;
const folderPath = fullPath ? fullPath.replace(/\\[^\\]+$/, "") : null;
return folderPath;
}
return null;
}
/**
* 从 manifest.json 获取脚本自身名称
* @returns {string} 脚本名称

View File

@@ -35,11 +35,7 @@ class UserCancelled extends Error {
(async function () {
if (!file.IsFolder("pathing")) {
let batFile = "SymLink.bat";
const folderPath = getScriptDirPath();
if (folderPath) {
batFile = `${folderPath}\\${batFile}`;
}
log.error("{0}文件夹不存在,请双击运行下列位置的脚本以创建文件夹链接\n{1}", "pathing", batFile);
log.error("{0}文件夹不存在,请双击运行本脚本目录下的{1}文件以创建文件夹链接", "pathing", batFile);
return;
}
if (!runMode) {
@@ -260,7 +256,7 @@ function analysisCharacterRequirement(actions_map) {
analysisResult[name] = value;
}
const outFile = `${getScriptDirPath()}\\各条路线所需角色.txt`;
const outFile = `各条路线所需角色.txt`;
let text = "";
// text = JSON.stringify(analysisResult, null, 2);
for (const [key, values] of Object.entries(analysisResult)) {
@@ -382,7 +378,7 @@ async function runPathTaskIfCooldownExpired(account, pathTask) {
// 如果用户取消,抛出异常
if (cancel) {
log.info(`${progress}{0}: 用户取消任,不更新记录`, pathName);
log.info(`${progress}{0}: 用户取消任,不更新记录`, pathName);
throw new UserCancelled(cancel);
}
@@ -414,7 +410,7 @@ async function runPathTaskIfCooldownExpired(account, pathTask) {
let secondDiffTime = new Date() - secondPathStartTime;
if (secondCancel) {
log.info(`${progress}{0}: 用户取消任,不更新记录`, pathName);
log.info(`${progress}{0}: 用户取消任,不更新记录`, pathName);
throw new UserCancelled(secondCancel);
}

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "带CD管理的自动采集",
"version": "1.7.7",
"version": "1.7.8",
"bgi_version": "0.45.0",
"description": "自动同步你通过BetterGI订阅的地图追踪任务执行采集任务并管理材料刷新时间支持多账号。\n首次使用前请先简单阅读说明可在`全自动`——`JS脚本`页面,点击本脚本名称查看)",
"authors": [