틀:Exercise: 두 판 사이의 차이

(새 문서: {{#invoke:exercise|make}})
 
편집 요약 없음
 
(같은 사용자의 중간 판 4개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{#invoke:exercise|make}}
<html>
<div id="sandbox-button"></div>
<script>
document.addEventListener("DOMContentLoaded", function () {
    const username = mw.config.get("wgUserName");
    if (!username) return;
 
    const now = new Date();
    const pad = n => n.toString().padStart(2, '0');
    const y = now.getFullYear();
    const m = pad(now.getMonth() + 1);
    const d = pad(now.getDate());
    const h = pad(now.getHours());
    const min = pad(now.getMinutes());
 
    const timestamp = `${y}${m}${d}${h}${min}`;
    const page = `연습장:${username}/${timestamp}`;
    const url = new URL("/wiki/index.php", location.origin);
    url.searchParams.set("title", page);
    url.searchParams.set("action", "edit");
 
    const a = document.createElement("a");
    a.setAttribute("href", url.href);  // ← 브라우저가 알아서 제대로 처리
    a.className = "mw-ui-button";
    a.textContent = `연습장(${timestamp}) 만들기`;
 
    const container = document.getElementById("sandbox-button");
    container.innerHTML = "";
    container.appendChild(a);
});
</script>
</html>

2025년 4월 9일 (수) 14:29 기준 최신판