107 lines
2.7 KiB
JavaScript
107 lines
2.7 KiB
JavaScript
document.getElementById("commandExec").addEventListener("click", async () => {
|
|
const req = await fetch("/actions/command-execute", {
|
|
method: "POST",
|
|
});
|
|
|
|
const res = await req.text();
|
|
|
|
if (res === "Accepted") {
|
|
alert("コマンド実行を受け付けました");
|
|
} else {
|
|
alert(`コマンド実行の要求にエラーが発生しました:${res}`);
|
|
}
|
|
});
|
|
|
|
document.getElementById("weatherUeuse").addEventListener("click", async () => {
|
|
const req = await fetch("/actions/weather", {
|
|
method: "POST",
|
|
});
|
|
|
|
const res = await req.text();
|
|
|
|
if (res === "Accepted") {
|
|
alert("天気お知らせを受け付けました");
|
|
} else {
|
|
alert(`天気お知らせの要求にエラーが発生しました:${res}`);
|
|
}
|
|
});
|
|
|
|
document.getElementById("eventdayUeuse").addEventListener("click", async () => {
|
|
const req = await fetch("/actions/eventday", {
|
|
method: "POST",
|
|
});
|
|
|
|
const res = await req.text();
|
|
|
|
if (res === "Accepted") {
|
|
alert("祝日等お知らせを受け付けました");
|
|
} else {
|
|
alert(`祝日等お知らせの要求にエラーが発生しました:${res}`);
|
|
}
|
|
});
|
|
|
|
document.getElementById("ueuse").addEventListener("click", async () => {
|
|
const text = prompt("ユーズ内容").toLowerCase();
|
|
|
|
if (text === "") {
|
|
alert("ユーズ内容がありません。");
|
|
return;
|
|
}
|
|
|
|
const nsfw = confirm("NSFWにしますか?");
|
|
|
|
const req = await fetch("/actions/ueuse", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
text, text,
|
|
nsfw: nsfw,
|
|
}),
|
|
});
|
|
|
|
const res = await req.text();
|
|
|
|
if (res === "Success") {
|
|
alert("ユーズ投稿を受け付けました");
|
|
} else {
|
|
alert(`ユーズ投稿の要求にエラーが発生しました:${res}`);
|
|
}
|
|
});
|
|
|
|
document.getElementById("api").addEventListener("click", async () => {
|
|
const token = await (await fetch("/actions/token", {
|
|
method: "GET",
|
|
})).text();
|
|
|
|
const endpoint = prompt("エンドポイント", "/serverinfo-api").toLowerCase();
|
|
|
|
if (endpoint === "") {
|
|
alert("エンドポイントが設定されていません。");
|
|
return;
|
|
}
|
|
|
|
const body = prompt("body(JSON)", `{"token": "${token}"}`).toLowerCase();
|
|
|
|
if (body === "") {
|
|
alert("bodyが設定されていません。");
|
|
return;
|
|
}
|
|
|
|
const req = await fetch("/actions/api", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
endpoint: endpoint,
|
|
body: JSON.parse(body),
|
|
}),
|
|
});
|
|
|
|
const res = await req.text();
|
|
|
|
alert(res);
|
|
});
|