whatsapp-send/index.html
2025-03-15 15:13:05 +01:00

66 lines
2.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>New WhatsApp Chat</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#3C503A" />
<link rel="manifest" href="webmanifest.json" />
<link rel="stylesheet" href="style.css" />
<script>
function getLink() {
var phone = document.getElementById("phone").value.replace(/\D/g, "");
var message = document.getElementById("message-wrapper").open
? document.getElementById("message").value
: "";
return "whatsapp://send/?phone=" + phone + "&text=" + message + "&type=phone_number";
}
function submit() {
location.href = getLink();
}
function copyLink() {
var input = document.getElementById("copy-input");
input.value = getLink();
input.select();
var result = document.execCommand("copy");
input.blur();
if (result)
alert("Copied link to clipboard");
else
alert("Couldn't copy link to clipboard");
}
</script>
</head>
<body>
<h1>Start a new WhatsApp chat</h1>
<p>Type a phone number, including country code</p>
<input id="phone" type="tel" placeholder="+1 (123) 456-7890" />
<details id="message-wrapper">
<summary>Write a message</summary>
<textarea id="message" placeholder="(Optional) Message to send"></textarea>
</details>
<button id="send" onclick="submit()">Submit</button>
<br>
<button onclick="copyLink()">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16" style="transform: rotate(45deg);">
<path d="M4.5 3a2.5 2.5 0 0 1 5 0v9a1.5 1.5 0 0 1-3 0V5a.5.5 0 0 1 1 0v7a.5.5 0 0 0 1 0V3a1.5 1.5 0 1 0-3 0v9a2.5 2.5 0 0 0 5 0V5a.5.5 0 0 1 1 0v7a3.5 3.5 0 1 1-7 0z"/>
</svg>
Copy WhatsApp link
</button>
<br>
<p id="desc">
By default, WhatsApp does not allow you to message
users who are not in your contacts list. This website
allows you to directly message any phone number through
WhatsApp, without having to add that number to your contacts.
</p>
<input id="copy-input" type="text" />
</body>
</html>