Last active
December 7, 2021 19:10
-
-
Save jittarao/7e5473df67cd3d0d52523ad45bf37c3b to your computer and use it in GitHub Desktop.
Show Messenger on specific pages on mobile
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
// PASTE THIS AFTER GIST TRACKING CODE | |
function isMobile() { | |
// credit to Timothy Huang for this regex test: | |
// https://dev.to/timhuang/a-simple-way-to-detect-if-browser-is-on-a-mobile-device-with-javascript-44j3 | |
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); | |
} | |
document.addEventListener('gistReady', function () { | |
gist.chat('hide'); | |
if(isMobile() && window.location.href.indexOf("/PAGE_PATTERN/") > -1) { | |
gist.chat('show'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment