-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
75 lines (71 loc) · 2.82 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Terrible Discord Spoilers - Character by Character spoilers</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Terrible Discord Spoilers is a tool to create character by character spoilers for Discord.">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
</head>
<body>
<div>
<a href="https://github.com/LiTO773/TerribleDiscordSpoilers"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
<div class="container">
<h1>Terrible Discord Spoilers</h1>
<p>One click reveal is for the weak. MAKE THEM CLICK ON ALL CHARACTERS!</p>
<textarea name="text" id="text" class="text" rows="11" oninput="getChanges()" placeholder="Write here the text you want to convert to spoilers.
For emojis or other special words use <>, this way it will add spoilers to the whole word and not every character.
Example: <:ok_hand:> will become ||:ok_hand:||"></textarea>
<br>
<br>
<p id="message">Click below to copy to clipboard:</p>
<textarea name="spoilers" id="spoilers" readonly="true" onclick="clipboard()" class="text" rows="11"></textarea>
<p class="count">TOTAL CHARACTERS: <span id="totalChars">0</span></p>
</div>
</div>
<script>
function getChanges() {
var text = document.getElementById("text").value;
var spoilers = ""
var specialString = false
for (let i = 0; i < text.length; i++) {
if (specialString) {
if (text.charAt(i) == ">") {
console.log(1);
spoilers += '||'
specialString = false
} else {
console.log(2)
spoilers += text.charAt(i)
}
} else if (text.charAt(i) !== "\n") {
if (text.charAt(i) == "<") {
console.log(3)
spoilers += '||'
specialString = true
} else {
console.log(4)
spoilers += "||" + text.charAt(i) + "||"
}
} else {
spoilers += "\n"
}
}
console.log(spoilers.length)
document.getElementById("spoilers").value = spoilers
totalChars(spoilers.length)
}
function totalChars(size) {
document.getElementById("totalChars").style.color = (size > 2000) ? "#FF0000" : "#99aab5"
document.getElementById("totalChars").innerHTML = size
}
function clipboard() {
var text = document.getElementById("spoilers");
text.select();
document.execCommand("copy");
document.getElementById("message").innerText = "Copied to clipboard 👍"
}
</script>
</body>
</html>