-
-
Save gklein/5309212da89a5c5b936746ff0cf8acf3 to your computer and use it in GitHub Desktop.
javascript: (function() { var re = /^\+?(972|0)(\-)?0?([5]{1}\d)\-?(\d{7})$/; var val=prompt("Phone Number #","");var phone=val.replace(re,'972$3$4');location="https://wa.me/"+escape(phone);})() |
Thank you, @gklein!
I wrote my version of phone processing — https://gist.github.com/baslie/6091c3e5bc1439e3b3c3e33b8bfafee2.
The bookmarklet works as follows:
- Save the code in bookmarks, for example as "Phone to WhatsApp".
- Highlight the phone number on the page.
- Press "Phone to WhatsApp".
The only thing I need help is how to validate the phone number. I need the script to add the missing prefixes itself (e.g. country codes).
Thank you, @gklein!
I wrote my version of phone processing — https://gist.github.com/baslie/6091c3e5bc1439e3b3c3e33b8bfafee2.The bookmarklet works as follows:
- Save the code in bookmarks, for example as "Phone to WhatsApp".
- Highlight the phone number on the page.
- Press "Phone to WhatsApp".
The only thing I need help is how to validate the phone number. I need the script to add the missing prefixes itself (e.g. country codes).
You can use replace() with a regular expression in order to adapt the phone number to the required format.
Thank you, @gklein!
I wrote my version of phone processing — https://gist.github.com/baslie/6091c3e5bc1439e3b3c3e33b8bfafee2.
The bookmarklet works as follows:
- Save the code in bookmarks, for example as "Phone to WhatsApp".
- Highlight the phone number on the page.
- Press "Phone to WhatsApp".
The only thing I need help is how to validate the phone number. I need the script to add the missing prefixes itself (e.g. country codes).
You can use replace() with a regular expression in order to adapt the phone number to the required format.
Yeap, of course :) I need more practice with REGEXPs
Thank you, @gklein!
I wrote my version of phone processing — https://gist.github.com/baslie/6091c3e5bc1439e3b3c3e33b8bfafee2.
The bookmarklet works as follows:
- Save the code in bookmarks, for example as "Phone to WhatsApp".
- Highlight the phone number on the page.
- Press "Phone to WhatsApp".
The only thing I need help is how to validate the phone number. I need the script to add the missing prefixes itself (e.g. country codes).
You can use replace() with a regular expression in order to adapt the phone number to the required format.
Yeap, of course :) I need more practice with REGEXPs
Try this one:
https://www.youtube.com/watch?v=ZfQFUJhPqMM
Good luck.
Bookmarklet does not work - clicking it does not trigger the pop-up window
Checked today on the following versions of Chrome:
Version 78.0.3904.97 (Official Build) (64-bit)
Version 79.0.3941.4 (Official Build) dev (64-bit)
Can you please check and resolve?