等到4點 (#363)

等到4點,用於等到第二天4點執行其他任務
This commit is contained in:
this-Fish
2025-02-24 09:59:11 +08:00
committed by GitHub
parent b6720b7dd4
commit 50f79211ff
2 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
(async function () {
setGameMetrics(1920, 1080, 2);
function getTimeUntilNext4AM() {
const now = new Date();
const next4AM = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate(),
4, 0, 0, 0
);
// 如果現在時間已經過了今天的 4 點,則計算明天的 4 點
if (now >= next4AM) {
next4AM.setDate(next4AM.getDate() + 1);
}
return next4AM - now;
}
// 執行
const timeUntilNext4AM = getTimeUntilNext4AM();
log.info(`等待 ${timeUntilNext4AM / 60000} 分鐘直到下一個 4 點…`);
// 多等待1分鐘
await sleep(timeUntilNext4AM + 60000);
log.info("時間到了!現在是 4 點。");
//1 分鐘 = 60000 毫秒
})();

View File

@@ -0,0 +1,16 @@
{
"manifest_version": 1,
"name": "等到4點", // 名称
"version": "1.0", // 版本
"bgi_version": "1.0", // 适用于 BetterGI 的最低版本BetterGI低于此版本会提示
"description": "等到4點,用於等到第二天4點執行其他任務", // 描述
// 作者信息
"authors": [
{
"name": "蜜柑魚"
}
],
// 入口文件
"main": "main.js"
}