This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimal.html
94 lines (85 loc) · 3.3 KB
/
minimal.html
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
<!DOCTYPE html>
<html lang="en">
<!--
an (about) 3000KB version of ExplodingEmail
if you can get it smaller without making it hard to maintain, make a pr
-->
<head>
<meta charset="UTF-8">
<title>Minimal ExplodingEmail</title>
</head>
<body>
<h1>Minimal version of Exploding Email for TOR users.</h1>
<p>view http://ttqp5vp3ylxrhpnfkehpzsslabaa7qxdur255jxgwmiisshv2wdntkid.onion/ for the official version.</p>
<p>view https://exploding.email for the full version.</p>
<p>make sure you have javascript enabled</p>
<p>refreshing will disconnect you from your inbox, save your resume token if you want to use it before it expires.</p>
<br><br>
<label for="resume_token_enter">Enter a resume token if you have one:</label>
<input type="text" id="resume_token_enter" name="resume_token_enter" value="">
<button onclick="resume_session()">Resume</button>
<br><br>
<p>your email:</p>
<p id="email"></p>
<p>resume token:</p>
<p id="resume_token"></p>
<p>emails will appear below</p>
<hr>
<div id="emails">
</div>
</body>
<script>
let ws;
let resume_token
//if the url is /?token=<token> then get the resume token
if(window.location.search.length > 1) {
resume_token = window.location.search.substring(1);
resume_token = resume_token.split('=')[1];
}
// const url = "ttqp5vp3ylxrhpnfkehpzsslabaa7qxdur255jxgwmiisshv2wdntkid.onion";
const url = "ttqp5vp3ylxrhpnfkehpzsslabaa7qxdur255jxgwmiisshv2wdntkid.onion";
if(resume_token) {
ws = new WebSocket(`ws://${url}/auth/${resume_token}`);
} else {
ws = new WebSocket(`ws://${url}/generate`);
}
function esc(str) {
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
}
ws.onmessage = (data) => {
const json = JSON.parse(data.data);
if(json.op === 2) {
document.getElementById("email").innerText = json.email;
document.getElementById("resume_token").innerText = json.token;
} else if(json.op === 6) {
//add a new div for the email
const div = document.createElement("div");
div.innerText = `from ${json.data.from} to ${json.data.to} subject ${esc(json.data.subject)} date ${json.data.date} ip ${json.data.ip}`;
const p = document.createElement("p");
p.innerText = json.data.body;
div.appendChild(p);
document.getElementById("emails").appendChild(div);
document.getElementById("emails").appendChild(document.createElement("hr"));
} else if(json.op === 0) {
alert("invalid token");
} else if(json.op === 5) {
document.getElementById("email").innerText = json.email;
document.getElementById("resume_token").innerText = resume_token;
}
}
function validate_token(str) {
return !!str.match(/^[A-Za-z0-9-_]+$/);
}
function resume_session() {
//refresh the page with /resume?token=<token>
const token = document.getElementById("resume_token_enter").value;
if(token.length > 0) {
if(!validate_token(token)) {
alert("invalid token");
return;
}
window.location.href = `?token=${token}`;
}
}
</script>
</html>