Compare commits
5 commits
2600300d36
...
00831bb0c2
Author | SHA1 | Date | |
---|---|---|---|
00831bb0c2 | |||
ea2cc6e5f7 | |||
ea1efecfea | |||
05cfd6aaf8 | |||
b15651b5b3 |
5 changed files with 151 additions and 76 deletions
17
Files/background.js
Normal file
17
Files/background.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,20 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Mailcow Temp Mail",
|
"name": "Mailcow Temporary Email",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"description": "Fetch and generate temporary emails via Mailcow",
|
"description": "Create and copy a temporary email from Mailcow",
|
||||||
"permissions": ["cookies", "storage", "clipboardWrite", "activeTab", "https://mail.pandem.fr*"],
|
"permissions": [
|
||||||
|
"storage",
|
||||||
|
"activeTab",
|
||||||
|
"https://mail.pandem.fr/SOGo/*"
|
||||||
|
],
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_popup": "popup.html",
|
"default_popup": "popup.html",
|
||||||
"default_icon": "icon.png"
|
"default_icon": {
|
||||||
|
"16": "icons/icon.png",
|
||||||
|
"48": "icons/icon.png",
|
||||||
|
"128": "icons/icon.png"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["background.js"],
|
"scripts": ["background.js"],
|
||||||
|
|
|
@ -1,19 +1,40 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Mailcow Temp Mail</title>
|
<meta charset="UTF-8">
|
||||||
<style>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
body { width: 250px; padding: 10px; font-family: Arial, sans-serif; }
|
<title>Mailcow Temp Mail</title>
|
||||||
button { width: 100%; padding: 5px; margin-top: 5px; }
|
<style>
|
||||||
input { width: 100%; padding: 5px; margin-bottom: 5px; text-align: center; }
|
body {
|
||||||
</style>
|
background-color: #0073b7; /* Mailcow Blue */
|
||||||
|
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>
|
||||||
<h3>Mailcow Temp Mail</h3>
|
<h2>Mailcow Login</h2>
|
||||||
<input type="text" id="email" readonly placeholder="No email found">
|
<input type="text" id="email" placeholder="Email">
|
||||||
<button id="fetch">Get My Temp Email</button>
|
<input type="password" id="password" placeholder="Password">
|
||||||
<button id="generate">Generate New Email</button>
|
<button id="login-btn">Login</button>
|
||||||
<button id="copy">Copy to Clipboard</button>
|
<p id="status"></p>
|
||||||
<script src="popup.js"></script>
|
<script src="popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,63 +1,12 @@
|
||||||
const API_BASE = "https://mail.paxcia.net";
|
document.getElementById("login-btn").addEventListener("click", async () => {
|
||||||
const GET_ALIAS_ENDPOINT = "/api/v1/get/alias";
|
const username = document.getElementById("email").value;
|
||||||
const ADD_ALIAS_ENDPOINT = "/api/v1/add/alias";
|
const password = document.getElementById("password").value;
|
||||||
|
|
||||||
document.getElementById("fetch").addEventListener("click", async () => {
|
const success = await login(username, password);
|
||||||
try {
|
|
||||||
const response = await fetch(API_BASE + GET_ALIAS_ENDPOINT, {
|
|
||||||
credentials: "include" // Ensures the request uses the user's Mailcow session
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) throw new Error("Failed to fetch emails");
|
if (success) {
|
||||||
|
document.getElementById("status").innerText = "Login Successful!";
|
||||||
const aliases = await response.json();
|
} else {
|
||||||
|
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);
|
|
||||||
});
|
|
||||||
|
|
80
Files/style.css
Normal file
80
Files/style.css
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue