V1 test
This commit is contained in:
parent
caba227e85
commit
2600300d36
3 changed files with 98 additions and 0 deletions
16
Files/manifest.json
Normal file
16
Files/manifest.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"manifest_version": 2,
|
||||||
|
"name": "Mailcow Temp Mail",
|
||||||
|
"version": "1.0",
|
||||||
|
"description": "Fetch and generate temporary emails via Mailcow",
|
||||||
|
"permissions": ["cookies", "storage", "clipboardWrite", "activeTab", "https://mail.pandem.fr*"],
|
||||||
|
"browser_action": {
|
||||||
|
"default_popup": "popup.html",
|
||||||
|
"default_icon": "icon.png"
|
||||||
|
},
|
||||||
|
"background": {
|
||||||
|
"scripts": ["background.js"],
|
||||||
|
"persistent": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
19
Files/popup.html
Normal file
19
Files/popup.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Mailcow Temp Mail</title>
|
||||||
|
<style>
|
||||||
|
body { width: 250px; padding: 10px; font-family: Arial, sans-serif; }
|
||||||
|
button { width: 100%; padding: 5px; margin-top: 5px; }
|
||||||
|
input { width: 100%; padding: 5px; margin-bottom: 5px; text-align: center; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h3>Mailcow Temp Mail</h3>
|
||||||
|
<input type="text" id="email" readonly placeholder="No email found">
|
||||||
|
<button id="fetch">Get My Temp Email</button>
|
||||||
|
<button id="generate">Generate New Email</button>
|
||||||
|
<button id="copy">Copy to Clipboard</button>
|
||||||
|
<script src="popup.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
63
Files/popup.js
Normal file
63
Files/popup.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
const API_BASE = "https://mail.paxcia.net";
|
||||||
|
const GET_ALIAS_ENDPOINT = "/api/v1/get/alias";
|
||||||
|
const ADD_ALIAS_ENDPOINT = "/api/v1/add/alias";
|
||||||
|
|
||||||
|
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 (!response.ok) throw new Error("Failed to fetch emails");
|
||||||
|
|
||||||
|
const aliases = await response.json();
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
Loading…
Reference in a new issue