mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-17 03:43:26 +08:00
添加多账户功能 (#2102)
* 添加多账户功能 参考autocode脚本 * Update manifest.json * Update manifest.json * Update manifest.json * Update repo/js/PurchaseArtifacts/main.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: 躁动的氨气 <131591012+zaodonganqi@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -6,3 +6,4 @@
|
||||
|
||||
此外脚本完整运行后会记录本次的时间,没有刷新时运行脚本会自动跳过。
|
||||
|
||||
账户名只允许使用数字,中英文,同时长度在20个字符以内。
|
||||
@@ -1,3 +1,4 @@
|
||||
let userName = settings.userName || "默认账户";
|
||||
(async function () {
|
||||
|
||||
async function Purchase(locationName) {
|
||||
@@ -5,6 +6,17 @@
|
||||
await pathingScript.runFile(filePath);
|
||||
}
|
||||
|
||||
//检验账户名
|
||||
function getUserName() {
|
||||
userName = userName.trim();
|
||||
//数字,中英文,长度在20个字符以内
|
||||
if (!userName || !/^[\u4e00-\u9fa5A-Za-z0-9]{1,20}$/.test(userName)) {
|
||||
log.error(`账户名${userName}违规,暂时使用默认账户名,请查看readme后修改`)
|
||||
userName = "默认账户";
|
||||
}
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定区域内查找并点击指定文字
|
||||
* @param {string} targetText - 要点击的目标文字
|
||||
@@ -305,13 +317,15 @@ async function isTaskRefreshed(filePath, options = {}) {
|
||||
await Shopping();
|
||||
}
|
||||
|
||||
await file.writeText("assets/weekly.txt", new Date().toISOString());
|
||||
await file.writeText(recordPath, new Date().toISOString());
|
||||
}
|
||||
|
||||
userName = getUserName();
|
||||
const recordPath = `assets/${userName}.txt`;
|
||||
//每周四4点刷新
|
||||
if( await isTaskRefreshed("assets/weekly.txt", {
|
||||
if( await isTaskRefreshed(recordPath, {
|
||||
refreshType: 'weekly',
|
||||
weeklyDay: 4, // 周一
|
||||
weeklyDay: 4, // 周四
|
||||
weeklyHour: 4 // 凌晨4点
|
||||
})){
|
||||
await main();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "自动购买狗粮(8点位)",
|
||||
"version": "2.0",
|
||||
"version": "2.1",
|
||||
"bgi_version": "0.50",
|
||||
"description": "自动购买狗粮",
|
||||
"authors": [
|
||||
@@ -15,5 +15,8 @@
|
||||
}
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js"
|
||||
"main": "main.js",
|
||||
"saved_files": [
|
||||
"assets/*.txt"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
[
|
||||
{
|
||||
"name": "userName",
|
||||
"type": "input-text",
|
||||
"label": "账户名称\n用于多账户运行时区分不同账户",
|
||||
"default": "默认账户"
|
||||
},
|
||||
{
|
||||
"name": "select1",
|
||||
"type": "checkbox",
|
||||
|
||||
Reference in New Issue
Block a user