158 lines
3.7 KiB
HTML
158 lines
3.7 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" />
|
|
<link rel="manifest" href="webmanifest.json" />
|
|
<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>
|
|
<style>
|
|
body {
|
|
background-color: #EFE9DD;
|
|
text-align: center;
|
|
font-family: sans-serif;
|
|
}
|
|
* {
|
|
-webkit-tap-highlight-color: transparent;
|
|
}
|
|
h1 {
|
|
margin-bottom: 0;
|
|
opacity: 0.7;
|
|
}
|
|
p {
|
|
opacity: 0.5;
|
|
font-size: 0.85rem;
|
|
max-width: 400px;
|
|
margin: 1rem auto;
|
|
}
|
|
summary {
|
|
opacity: 0.5;
|
|
font-size: 0.85rem;
|
|
margin: 0.5rem auto;
|
|
cursor: pointer;
|
|
user-select: none;
|
|
}
|
|
summary:focus {
|
|
outline: none;
|
|
opacity: 0.7;
|
|
}
|
|
#desc {
|
|
margin-top: 2rem;
|
|
font-size: 0.75rem;
|
|
}
|
|
.icon {
|
|
width: 1.25rem;
|
|
height: 1.25rem;
|
|
position: relative;
|
|
top: 0.25rem;
|
|
}
|
|
|
|
input, textarea {
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 4px;
|
|
border: 1px solid rgba(0, 0, 0, 0.5);
|
|
transition: all 150ms;
|
|
font-size: 1rem;
|
|
}
|
|
textarea {
|
|
resize: vertical;
|
|
font-family: sans-serif;
|
|
font-size: 0.75rem;
|
|
width: 100%;
|
|
max-width: 400px;
|
|
box-sizing: border-box;
|
|
}
|
|
input:focus, textarea:focus {
|
|
outline: none;
|
|
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
|
|
}
|
|
#copy-input {
|
|
opacity: 0; /* Used for copying to clipboard */
|
|
pointer-events: none;
|
|
}
|
|
|
|
button {
|
|
background-color: inherit;
|
|
border: none;
|
|
margin: 0.25rem 0;
|
|
opacity: 0.5;
|
|
cursor: pointer;
|
|
}
|
|
button:hover, button:focus {
|
|
opacity: 1;
|
|
outline: none;
|
|
}
|
|
|
|
#send {
|
|
background-color: #1DAA61;
|
|
color: white;
|
|
border: none;
|
|
padding: 0.5rem 2rem;
|
|
margin-top: 1rem;
|
|
border-radius: 4px;
|
|
transition: all 150ms;
|
|
opacity: 1;
|
|
}
|
|
#send:active {
|
|
background-color: #18864D;
|
|
}
|
|
#send:focus {
|
|
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
|
|
}
|
|
</style>
|
|
</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>
|
|
|