Last active
November 11, 2019 05:01
-
-
Save echr/2bb1b8f3e8ea025cb13561aba1c021f6 to your computer and use it in GitHub Desktop.
Simple Fix Whatsapp Click to chat (api.whatsapp.com) in Facebook Browser
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
<script> | |
function isFacebookApp() { | |
var ua = navigator.userAgent || navigator.vendor || window.opera; | |
return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1); | |
} | |
if (isFacebookApp()) { | |
var buttons = document.querySelectorAll('a[href*="https://api.whatsapp.com"]'); | |
[].forEach.call(buttons, function(button) { | |
button.href = button.href.replace('https://api.whatsapp.com/', 'whatsapp://') | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment