fix: update settings

This commit is contained in:
2026-06-25 19:21:09 +05:00
parent 2edba57952
commit 8a5a27f3b6
8 changed files with 122 additions and 24 deletions
+30 -6
View File
@@ -1,19 +1,43 @@
const input = document.getElementById("channel-input");
const copyBtn = document.getElementById("copy-btn");
const openBtn = document.getElementById("open-btn");
const linkEl = document.getElementById("game-link");
const autoRestartEl = document.getElementById("opt-auto-restart");
const singlePlayEl = document.getElementById("opt-single-play");
function buildUrl() {
const name = input.value.trim().toLowerCase() || "Ku6ep_XBOCTuK";
const single = singlePlayEl.checked ? "1" : "0";
return `${location.origin}${location.pathname.replace(/\/[^/]*$/, "/")}game?channel=${encodeURIComponent(name)}&singlePlay=${single}`;
}
function updateLink() {
linkEl.textContent = buildUrl();
linkEl.className = "";
}
function copyLink() {
const name = input.value.trim().toLowerCase() || "Ku6ep_XBOCTuK";
const autoRestart = autoRestartEl.checked ? "1" : "0";
const url = `${location.origin}${location.pathname.replace(/\/[^/]*$/, "/")}game.html?channel=${encodeURIComponent(name)}&autoRestart=${autoRestart}`;
navigator.clipboard.writeText(url).then(() => {
navigator.clipboard.writeText(buildUrl()).then(() => {
linkEl.textContent = "СКОПИРОВАНО!";
linkEl.className = "copied";
setTimeout(updateLink, 1500);
});
}
copyBtn.addEventListener("click", copyLink);
function openLink() {
window.open(buildUrl(), "_blank");
}
input.addEventListener("input", updateLink);
singlePlayEl.addEventListener("change", updateLink);
input.addEventListener("keydown", (e) => {
if (e.key === "Enter") copyLink();
});
copyBtn.addEventListener("click", copyLink);
openBtn.addEventListener("click", openLink);
updateLink();
document.querySelector(".hint-toggle").addEventListener("click", () => {
document.querySelector(".settings-hints").classList.toggle("hidden");
});