Spaces:
Running
Running
File size: 7,433 Bytes
405ff9d 475a817 |
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Live Temp Mail</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<style>
body { background-color: #0f172a; color: white; }
#toast {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #22c55e;
color: white;
padding: 10px 20px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
#toast.show {
opacity: 1;
}
</style>
</head>
<body class="flex items-center justify-center min-h-screen">
<div id="toast">π Copied Successfully!</div>
<div class="bg-gray-900 rounded-2xl shadow-2xl p-6 max-w-2xl w-full">
<h1 class="text-2xl font-bold text-center mb-4 text-indigo-400">π§ Live Temp Mail</h1>
<div class="bg-gray-800 rounded-xl p-4 flex justify-between items-center">
<input id="email" readonly class="bg-transparent text-white w-full font-mono text-sm" />
<button onclick="copyEmail()" class="ml-2 px-3 py-1 text-sm bg-indigo-600 hover:bg-indigo-700 rounded">π Copy</button>
</div>
<div class="flex justify-between mt-4 mb-2">
<button onclick="generateEmail()" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded">π New Email</button>
<button onclick="fetchInbox()" class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded">π© Refresh Inbox</button>
</div>
<div class="text-right text-sm text-yellow-300 mb-2">β³ Time left: <span id="timer">10:00</span></div>
<h2 class="mt-4 mb-2 font-semibold text-lg text-indigo-300">π₯ Inbox</h2>
<div id="inbox" class="bg-gray-800 p-4 rounded-xl space-y-3 max-h-64 overflow-y-auto text-sm">
<p class="text-gray-400">π No messages yet.</p>
</div>
<h2 class="mt-6 mb-2 font-semibold text-lg text-yellow-300">π¨ Message Content</h2>
<div id="messageContent" class="bg-gray-800 p-4 rounded-xl text-sm overflow-y-auto max-h-64">
<p class="text-gray-400">Select a message to view its content.</p>
</div>
</div>
<script>
let currentEmail = "";
let currentLogin = "";
let currentDomain = "";
let timerInterval;
let inboxInterval;
let timeLeft = 600;
function showToast(msg) {
const toast = document.getElementById("toast");
toast.textContent = msg;
toast.classList.add("show");
setTimeout(() => toast.classList.remove("show"), 2000);
}
function randomStr(len = 10) {
const chars = "abcdefghijklmnopqrstuvwxyz123456789";
return Array.from({length: len}, () => chars[Math.floor(Math.random() * chars.length)]).join('');
}
function startTimer() {
clearInterval(timerInterval);
timeLeft = 600;
const timerEl = document.getElementById("timer");
timerInterval = setInterval(() => {
const minutes = Math.floor(timeLeft / 60).toString().padStart(2, '0');
const seconds = (timeLeft % 60).toString().padStart(2, '0');
timerEl.textContent = `${minutes}:${seconds}`;
timeLeft--;
if (timeLeft < 0) {
clearInterval(timerInterval);
clearInterval(inboxInterval);
generateEmail();
}
}, 1000);
}
function startAutoRefreshInbox() {
clearInterval(inboxInterval);
inboxInterval = setInterval(fetchInbox, 5000);
}
function generateEmail() {
currentLogin = randomStr();
currentDomain = "1secmail.com";
currentEmail = `${currentLogin}@${currentDomain}`;
document.getElementById("email").value = currentEmail;
document.getElementById("inbox").innerHTML = '<p class="text-gray-400">π No messages yet.</p>';
document.getElementById("messageContent").innerHTML = '<p class="text-gray-400">Select a message to view its content.</p>';
startTimer();
startAutoRefreshInbox();
}
function copyEmail() {
navigator.clipboard.writeText(currentEmail);
showToast("π Email copied!");
}
async function fetchInbox() {
const inboxDiv = document.getElementById("inbox");
if (!currentLogin || !currentDomain) {
inboxDiv.innerHTML = '<p class="text-gray-400">β³ Waiting for email setup...</p>';
return;
}
inboxDiv.innerHTML = '<p class="text-gray-400">π Fetching messages...</p>';
try {
const res = await fetch(`https://www.1secmail.com/api/v1/?action=getMessages&login=${currentLogin}&domain=${currentDomain}`);
const data = await res.json();
if (data.length === 0) {
inboxDiv.innerHTML = '<p class="text-gray-400">π No messages found.</p>';
return;
}
inboxDiv.innerHTML = '';
data.forEach(msg => {
const msgDiv = document.createElement("div");
msgDiv.className = "border-b border-gray-700 pb-2 cursor-pointer hover:bg-gray-700 p-2 rounded";
msgDiv.innerHTML = `
<p class="font-bold text-white">${msg.from}</p>
<p class="text-gray-300">${msg.subject}</p>
<div class="flex gap-2 mt-2">
<button onclick="fetchMessage(${msg.id})" class="bg-blue-600 px-2 py-1 text-xs rounded">π Open</button>
<button onclick="copyMessage(${msg.id})" class="bg-indigo-600 px-2 py-1 text-xs rounded">π Copy</button>
<button onclick="deleteMessage(${msg.id})" class="bg-red-600 px-2 py-1 text-xs rounded">ποΈ Delete</button>
<button onclick="forwardMessage(${msg.id})" class="bg-yellow-600 px-2 py-1 text-xs rounded">π€ Forward</button>
</div>`;
inboxDiv.appendChild(msgDiv);
});
} catch (err) {
inboxDiv.innerHTML = '<p class="text-red-500">β Error fetching inbox. Check connection or domain.</p>';
}
}
async function fetchMessage(id) {
const contentDiv = document.getElementById("messageContent");
contentDiv.innerHTML = '<p class="text-gray-400">π Loading message...</p>';
try {
const res = await fetch(`https://www.1secmail.com/api/v1/?action=readMessage&login=${currentLogin}&domain=${currentDomain}&id=${id}`);
const data = await res.json();
contentDiv.innerHTML = `
<p class="text-indigo-400 font-bold mb-2">From: ${data.from}</p>
<p class="text-green-400 font-bold mb-2">Subject: ${data.subject}</p>
<div class="text-gray-200 mt-2">${data.htmlBody || data.textBody}</div>
`;
} catch (err) {
contentDiv.innerHTML = '<p class="text-red-500">β Error loading message.</p>';
}
}
function copyMessage(id) {
fetch(`https://www.1secmail.com/api/v1/?action=readMessage&login=${currentLogin}&domain=${currentDomain}&id=${id}`)
.then(res => res.json())
.then(data => {
const content = data.htmlBody || data.textBody;
navigator.clipboard.writeText(content);
showToast("π Message copied!");
});
}
function deleteMessage(id) {
alert("ποΈ Delete not supported by 1secmail API (for demo only)");
}
function forwardMessage(id) {
alert("π€ Forward not implemented β requires SMTP backend");
}
window.addEventListener('DOMContentLoaded', () => {
generateEmail();
});
</script>
</body>
</html>
|