Created
September 12, 2018 09:42
-
-
Save Misophistful/2f14c201a6e0ca9df3257391479f3c0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
window.intercomSettings = { | |
app_id: “m86iqlk9” | |
}; | |
function parseJwt (token) { | |
var base64Url = token.split(‘.’)[1]; | |
var base64 = base64Url.replace(/-/g, ‘+’).replace(/_/g, ‘/‘); | |
return JSON.parse(window.atob(base64)); | |
}; | |
var intercom = function(){var w=window;var ic=w.Intercom;if(typeof ic===“function”){ic(‘reattach_activator’);ic(‘update’,intercomSettings);}else{var d=document;var I=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement(‘script’);s.type=‘text/javascript’;s.async=true;s.src=‘https://widget.intercom.io/widget/m86iqlk9';var x=d.getElementsByTagName(‘script’)[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent(‘onload’,l);}else{w.addEventListener(‘load’,l,false);}}}; | |
function testing () { | |
var token = Hivebrite.data.jwt; | |
var credentials = parseJwt(token); | |
var id = credentials.id; | |
var name = credentials.name; | |
var email = credentials.primary_email; | |
console.warn(`id: ${id}, name: ${name}, email: ${email}`); | |
window.intercomSettings = { | |
app_id: ‘m86iqlk9’, | |
name: name, | |
email: email, | |
created_at: 1312182000 // Signup date as a Unix timestamp | |
}; | |
intercom(); | |
}; | |
const showJwtToken = () => testing(); | |
setTimeout(showJwtToken, 3000); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment