Spaces:
Runtime error
Runtime error
File size: 2,438 Bytes
2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 da7a97d 39bb0e7 2d14589 da7a97d 39bb0e7 da7a97d 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 39bb0e7 2d14589 da7a97d 2d14589 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | <!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Temp Email Farel</title>
<style>
body{background:#020617;color:#fff;font-family:sans-serif}
.box{max-width:500px;margin:40px auto;background:#0f172a;padding:20px;border-radius:10px}
input,select,button{width:100%;padding:10px;margin:6px 0}
button{background:#38bdf8;border:0;cursor:pointer}
button:disabled{opacity:.6;cursor:not-allowed}
.msg{background:#020617;padding:8px;border-radius:5px;margin:5px 0}
</style>
</head>
<body>
<div class="box">
<h2>π§ Temp Email Farel</h2>
<input id="name" placeholder="username">
<select id="domain"></select>
<button id="btn" onclick="createEmail()" disabled>Buat Email</button>
<b id="email"></b>
<div id="inbox"></div>
</div>
<script>
let currentEmail = null;
let timer = null;
let domainList = [];
// π₯ LOAD DOMAIN + AUTO RANDOM
async function loadDomains(){
const r = await fetch('/api/domains');
const j = await r.json();
domain.innerHTML = '';
domainList = [];
j.domains.forEach(d=>{
const dom = typeof d === 'string' ? d : d.name;
domainList.push(dom);
domain.innerHTML += `<option value="${dom}">${dom}</option>`;
});
// auto pilih random
const random = domainList[Math.floor(Math.random() * domainList.length)];
domain.value = random;
btn.disabled = false;
}
// π₯ CREATE EMAIL (AMAN)
async function createEmail(){
if (!name.value.trim())
return alert('Username wajib diisi');
if (!domain.value)
return alert('Domain belum siap');
const r = await fetch('/api/email/new',{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({
name: name.value.trim(),
domain: domain.value
})
});
const j = await r.json();
if(!j.success) return alert(j.error);
currentEmail = j.email;
email.innerText = "π¬ " + j.email;
if(timer) clearInterval(timer);
timer = setInterval(loadInbox, 5000);
}
// π₯ LOAD INBOX
async function loadInbox(){
if(!currentEmail) return;
const r = await fetch('/api/email/' + currentEmail + '/messages');
const j = await r.json();
inbox.innerHTML = '';
j.messages?.forEach(m=>{
inbox.innerHTML += `
<div class="msg">
<b>${m.from}</b><br>
${m.subject}
</div>`;
});
}
loadDomains();
</script>
</body>
</html> |