Skip to content

Commit 50527a2

Browse files
authored
Add files via upload
1 parent 8566817 commit 50527a2

File tree

7 files changed

+225
-0
lines changed

7 files changed

+225
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Coding Team
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

background.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
2+
if (request.action === "sendEmail") {
3+
const url = "https://cmailerapi.codingteam.tech/send-email";
4+
const payload = JSON.stringify(request.data);
5+
6+
const xhr = new XMLHttpRequest();
7+
xhr.open("POST", url);
8+
xhr.setRequestHeader("Content-Type", "application/json");
9+
10+
xhr.onreadystatechange = () => {
11+
if (xhr.readyState === 4) {
12+
if (xhr.status === 200) {
13+
sendResponse({ success: true });
14+
} else {
15+
const responseObj = JSON.parse(xhr.responseText);
16+
const error_message = responseObj.message || "Erreur lors de l'envoi de l'e-mail.";
17+
sendResponse({ success: false, message: error_message });
18+
}
19+
}
20+
};
21+
22+
xhr.send(payload);
23+
return true; // Indique que sendResponse sera appelé de manière asynchrone
24+
}
25+
});

icon.png

39.9 KB
Loading

manifest.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "CMAILER",
4+
"version": "1.0",
5+
"description": "Extension de navigateur utilisant CMAILERAPI",
6+
"action": {
7+
"default_popup": "popup.html"
8+
},
9+
"permissions": [
10+
"https://cmailerapi.codingteam.tech/send-email"
11+
],
12+
"background": {
13+
"service_worker": "background.js"
14+
},
15+
"icons": {
16+
"48": "icon.png"
17+
}
18+
}

ok.mp3

132 KB
Binary file not shown.

popup.html

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Envoi d'Email</title>
5+
<meta charset="UTF-8">
6+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
8+
<style>
9+
body {
10+
font-family: Roboto, Arial, sans-serif;
11+
background-color: #f0f0f0;
12+
display: flex;
13+
justify-content: center;
14+
align-items: center;
15+
height: 100vh;
16+
margin: 0;
17+
}
18+
19+
.email-container {
20+
background-color: #ffffff;
21+
border-radius: 8px;
22+
padding: 20px;
23+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
24+
width: 300px;
25+
}
26+
27+
.email-container h1 {
28+
text-align: center;
29+
margin-bottom: 20px;
30+
font-weight: 500;
31+
color: #333333;
32+
}
33+
34+
.input-group {
35+
margin-bottom: 15px;
36+
}
37+
38+
.input-group label {
39+
font-weight: 500;
40+
display: block;
41+
margin-bottom: 5px;
42+
color: #555555;
43+
}
44+
45+
.input-group input[type="email"],
46+
.input-group input[type="text"],
47+
.input-group textarea {
48+
width: 100%;
49+
padding: 10px;
50+
border: 1px solid #e0e0e0;
51+
border-radius: 4px;
52+
transition: border-color 0.3s ease-in-out;
53+
}
54+
55+
.input-group textarea {
56+
resize: vertical;
57+
height: 100px;
58+
}
59+
60+
.input-group input[type="email"]:focus,
61+
.input-group input[type="text"]:focus,
62+
.input-group textarea:focus {
63+
border-color: #4285f4;
64+
outline: none;
65+
}
66+
67+
#sendButton {
68+
background-color: #4285f4;
69+
color: white;
70+
border: none;
71+
padding: 10px 15px;
72+
cursor: pointer;
73+
border-radius: 4px;
74+
width: 100%;
75+
font-weight: 500;
76+
transition: background-color 0.3s ease-in-out;
77+
}
78+
79+
#sendButton:hover {
80+
background-color: #3367d6;
81+
}
82+
83+
#status {
84+
margin-top: 10px;
85+
font-weight: bold;
86+
text-align: center;
87+
color: #ff0000;
88+
}
89+
</style>
90+
</head>
91+
<body>
92+
<div class="email-container">
93+
<h1><i class="fa-solid fa-envelope fa-shake"></i> CMAILER</h1>
94+
<div class="input-group">
95+
<label for="to"><i class="fa-solid fa-truck fa-fade"></i> Destinataire :</label>
96+
<input type="email" id="to" required>
97+
</div>
98+
<div class="input-group">
99+
<label for="subject"><i class="fa-solid fa-pen-to-square fa-fade"></i> Sujet :</label>
100+
<input type="text" id="subject" required>
101+
</div>
102+
<div class="input-group">
103+
<label for="message"><i class="fa-solid fa-comment-dots fa-fade"></i> Message :</label>
104+
<textarea id="message" required></textarea>
105+
</div>
106+
<button id="sendButton">Envoyer l'Email <i class="fa-solid fa-paper-plane fa-beat-fade"></i></i></button>
107+
<div id="status"></div>
108+
</div>
109+
<script src="popup.js"></script>
110+
</body>
111+
</html>

popup.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
document.getElementById('sendButton').addEventListener('click', () => {
2+
const to = document.getElementById('to').value;
3+
const subject = document.getElementById('subject').value;
4+
const message = document.getElementById('message').value;
5+
6+
const url = "https://cmailerapi.codingteam.tech/send-email";
7+
8+
const data = {
9+
to: to,
10+
subject: subject,
11+
message: message
12+
};
13+
14+
const xhr = new XMLHttpRequest();
15+
xhr.open("POST", url);
16+
xhr.setRequestHeader("Content-Type", "application/json");
17+
18+
document.getElementById('sendButton').disabled = true;
19+
document.getElementById('sendButton').innerText = "Envoi en cours, veuillez patienter...";
20+
21+
xhr.onreadystatechange = function() {
22+
if (xhr.readyState === 4) {
23+
document.getElementById('sendButton').disabled = false;
24+
if (xhr.status === 200) {
25+
document.getElementById('status').textContent = "E-mail envoyé avec succès.";
26+
setTimeout(() => {
27+
document.getElementById('status').textContent = "";
28+
document.getElementById('to').value = "";
29+
document.getElementById('subject').value = "";
30+
document.getElementById('message').value = "";
31+
playSuccessSound();
32+
}, 3000); // 3 seconds
33+
} else {
34+
const responseObj = JSON.parse(xhr.responseText);
35+
const error_message = responseObj.message || "Erreur lors de l'envoi de l'e-mail.";
36+
document.getElementById('status').textContent = `Erreur : ${error_message}`;
37+
}
38+
setTimeout(() => {
39+
document.getElementById('sendButton').innerText = "Envoyer l'e-mail";
40+
}, 1000); // 1 second
41+
}
42+
};
43+
44+
xhr.send(JSON.stringify(data));
45+
});
46+
47+
function playSuccessSound() {
48+
const successSound = new Audio("ok.mp3");
49+
successSound.play();
50+
}

0 commit comments

Comments
 (0)