-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencode.js
26 lines (25 loc) · 1.19 KB
/
encode.js
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
var displayer = document.getElementById("encodedDisplay")
var sharing = document.getElementById("sharing")
var whatsApp = document.getElementById("whatsApp")
var url;
var space = document.getElementById("space")
var space2 = document.getElementById("space2")
function encode() { // encodes the message and generates the URL
var message = document.getElementById("message").value
console.log(message)
var encoded = btoa(encodeURIComponent(message)) // base64 encode
console.log(encoded)
url = "https://spoiler.axeltong.be/?base64=" + encoded
displayer.classList.add('encoded');
sharing.classList.add('share');
displayer.innerHTML = "<textarea class=\"textOut\" readonly>Share this link: " + url + "</textarea> <br> <br> <button onclick=\"copy()\" class=\"button-2\">Copy link</button>"
whatsApp.innerHTML = "<a href=\"whatsapp://send?text=" + url + "\" data-action=\"share/whatsapp/share\">Share via Whatsapp</a>" // send whatsapp message
space.innerHTML = "<br>"
space2.innerHTML = "<br>"
displayer.removeAttribute("hidden")
}
function copy() {
navigator.clipboard.writeText(url);
// Alert the copied text
alert("Copied " + url);
}