Compare commits

..

No commits in common. "00831bb0c2c8b56504ace0d00ddd8c47a9ba5c3f" and "2600300d360523c4950d2e7b7f84107159f635ee" have entirely different histories.

5 changed files with 76 additions and 151 deletions

View file

@ -1,17 +0,0 @@
async function login(username, password) {
const authHeader = "Basic " + btoa(username + ":" + password);
const response = await fetch("https://mail.pandem.fr/SOGo/so/session", {
method: "POST",
headers: {
"Authorization": authHeader,
"Content-Type": "application/json"
}
});
if (response.ok) {
return true; // Successfully logged in
} else {
return false; // Login failed
}
}

View file

@ -1,20 +1,12 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Mailcow Temporary Email", "name": "Mailcow Temp Mail",
"version": "1.0", "version": "1.0",
"description": "Create and copy a temporary email from Mailcow", "description": "Fetch and generate temporary emails via Mailcow",
"permissions": [ "permissions": ["cookies", "storage", "clipboardWrite", "activeTab", "https://mail.pandem.fr*"],
"storage",
"activeTab",
"https://mail.pandem.fr/SOGo/*"
],
"browser_action": { "browser_action": {
"default_popup": "popup.html", "default_popup": "popup.html",
"default_icon": { "default_icon": "icon.png"
"16": "icons/icon.png",
"48": "icons/icon.png",
"128": "icons/icon.png"
}
}, },
"background": { "background": {
"scripts": ["background.js"], "scripts": ["background.js"],

View file

@ -1,40 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html>
<head> <head>
<meta charset="UTF-8"> <title>Mailcow Temp Mail</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style>
<title>Mailcow Temp Mail</title> body { width: 250px; padding: 10px; font-family: Arial, sans-serif; }
<style> button { width: 100%; padding: 5px; margin-top: 5px; }
body { input { width: 100%; padding: 5px; margin-bottom: 5px; text-align: center; }
background-color: #0073b7; /* Mailcow Blue */ </style>
color: white;
font-family: Arial, sans-serif;
width: 250px;
text-align: center;
}
input, button {
width: 80%;
border-radius: 5px;
padding: 10px;
margin: 5px;
border: none;
}
button {
background-color: #005f8c;
color: white;
cursor: pointer;
}
button:hover {
background-color: #004f74;
}
</style>
</head> </head>
<body> <body>
<h2>Mailcow Login</h2> <h3>Mailcow Temp Mail</h3>
<input type="text" id="email" placeholder="Email"> <input type="text" id="email" readonly placeholder="No email found">
<input type="password" id="password" placeholder="Password"> <button id="fetch">Get My Temp Email</button>
<button id="login-btn">Login</button> <button id="generate">Generate New Email</button>
<p id="status"></p> <button id="copy">Copy to Clipboard</button>
<script src="popup.js"></script> <script src="popup.js"></script>
</body> </body>
</html> </html>

View file

@ -1,12 +1,63 @@
document.getElementById("login-btn").addEventListener("click", async () => { const API_BASE = "https://mail.paxcia.net";
const username = document.getElementById("email").value; const GET_ALIAS_ENDPOINT = "/api/v1/get/alias";
const password = document.getElementById("password").value; const ADD_ALIAS_ENDPOINT = "/api/v1/add/alias";
const success = await login(username, password); document.getElementById("fetch").addEventListener("click", async () => {
try {
const response = await fetch(API_BASE + GET_ALIAS_ENDPOINT, {
credentials: "include" // Ensures the request uses the user's Mailcow session
});
if (success) { if (!response.ok) throw new Error("Failed to fetch emails");
document.getElementById("status").innerText = "Login Successful!";
} else { const aliases = await response.json();
document.getElementById("status").innerText = "Login Failed!";
if (aliases.length > 0) {
const latestEmail = aliases[0].address;
document.getElementById("email").value = latestEmail;
} else {
document.getElementById("email").value = "No temp email found";
}
} catch (error) {
console.error(error);
alert("Error fetching email");
} }
}); });
document.getElementById("generate").addEventListener("click", async () => {
const emailPrefix = "temp" + Date.now();
const domain = "paxcia.net";
const newEmail = `${emailPrefix}@${domain}`;
const requestData = {
address: newEmail,
goto: "your_main@paxcia.net", // Redirect emails to your main inbox
active: true
};
try {
const response = await fetch(API_BASE + ADD_ALIAS_ENDPOINT, {
method: "POST",
credentials: "include", // Uses session login
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(requestData)
});
if (!response.ok) throw new Error("Failed to generate email");
document.getElementById("email").value = newEmail;
alert("New email created: " + newEmail);
} catch (error) {
console.error(error);
alert("Error creating email");
}
});
document.getElementById("copy").addEventListener("click", () => {
const emailField = document.getElementById("email");
emailField.select();
document.execCommand("copy");
alert("Copied: " + emailField.value);
});

View file

@ -1,80 +0,0 @@
/* General Styles */
body {
font-family: "Arial", sans-serif;
background: #f0f4ff;
margin: 0;
padding: 0;
width: 300px;
text-align: center;
}
/* Container */
.container {
background: white;
border-radius: 12px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
margin: 20px;
}
/* Heading */
h2 {
color: #0078D4;
font-size: 18px;
margin-bottom: 15px;
}
/* Inputs */
input {
width: 90%;
padding: 10px;
margin-bottom: 10px;
border: 2px solid #0078D4;
border-radius: 6px;
text-align: center;
font-size: 14px;
outline: none;
}
input:focus {
border-color: #005bb5;
}
/* Buttons */
button {
width: 95%;
padding: 10px;
border: none;
background: #0078D4;
color: white;
font-size: 14px;
font-weight: bold;
border-radius: 6px;
cursor: pointer;
transition: 0.3s;
}
button:hover {
background: #005bb5;
}
/* Button Group */
.button-group {
display: flex;
justify-content: space-between;
gap: 5px;
}
.button-group button {
flex: 1;
}
/* Logout Button */
.logout {
background: #D9534F;
}
.logout:hover {
background: #c9302c;
}