Created
October 30, 2020 14:01
-
-
Save camaleaun/be6c97f6a063ae6699ec6b14342d7e26 to your computer and use it in GitHub Desktop.
WhatsApp link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isMobileWA() | |
{ | |
return (/Android|webOS|iPhone|iPad|iPod|Windows Phone|IEMobile|Mobile|BlackBerry/i.test(navigator.userAgent) ); | |
} | |
var elm = jQuery('a[href*="whatsapp.com"]'); | |
jQuery.each(elm, function(index, value){ | |
var item = jQuery(value).attr('href'); | |
if(item.indexOf('chat') != -1){ | |
//nothing | |
} else if (item.indexOf('web.whatsapp') != -1 && isMobileWA()){ | |
var itemLink = item; | |
var newLink = itemLink.replace('web.whatsapp', 'api.whatsapp'); | |
jQuery(value).attr("href", newLink); | |
} else if (item.indexOf('api.whatsapp') != -1 && !isMobileWA()){ | |
var itemLink = item; | |
var newLink = itemLink.replace('api.whatsapp', 'web.whatsapp'); | |
jQuery(value).attr("href", newLink); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment