Skip to content

Instantly share code, notes, and snippets.

@jabranr
Last active August 26, 2023 07:28
Show Gist options
  • Save jabranr/7d022861d93dcc1af077bb44e579efa5 to your computer and use it in GitHub Desktop.
Save jabranr/7d022861d93dcc1af077bb44e579efa5 to your computer and use it in GitHub Desktop.
WhatsApp bookmarklet
/**
* Use this bookmarklet to start WhatsApp chat without saving a contact first
*/
(function(){
let phone = window.prompt('Enter phone with country code');
if (Boolean(phone)) {
phone = phone.startsWith('+') ? phone : phone.startsWith('0') ? phone.replace(/^0+/, '+') : phone.padStart(phone.length+1, '+');
window.open(`https://wa.me/${phone}`);
}
}());
/**
* Minified code
* !function(){let t=window.prompt("Enter phone with country code");Boolean(t)&&(t=t.startsWith("+")?t:t.startsWith("0")?t.replace(/^0+/,"+"):t.padStart(t.length+1,"+"),window.open(`https://wa.me/${t}`))}();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment