Last active
January 24, 2023 13:46
-
-
Save gjrevans/5982f917d90db8f1a69caa979a5faacf to your computer and use it in GitHub Desktop.
Customize the placement, size, color of the intercom launcher
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
// Intercom | |
// | |
// Inject styles into Intercom iframe | |
var stylesheet = document.createElement('link'); | |
stylesheet.rel = 'stylesheet'; | |
stylesheet.href = 'path_to_file.css'; | |
// Wait for the iframe to become ready (max 30 seconds) | |
var timeout = setTimeout(function() { | |
clearInterval(interval); | |
}, 30000); | |
// Check if the iframe is ready every 100ms | |
var interval = setInterval(function() { | |
var iframe = document.querySelector('.intercom-launcher-frame'); | |
if (iframe) { | |
// Append the app stylesheet to the iframe head | |
iframe.contentDocument.head.appendChild(stylesheet); | |
clearInterval(interval); | |
clearTimeout(timeout); | |
} | |
}, 100); |
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
// 1. Variables | |
$icon-size: 4rem; | |
$position-from-bottom: 4rem; | |
$positon-from-left: 1rem; | |
// 2. iframe Element | |
#intercom-container iframe.intercom-launcher-frame { | |
bottom: $position-from-bottom !important; | |
right: $positon-from-left !important; | |
height: $icon-size !important; | |
width: $icon-size !important; | |
} | |
// 3. iframe Content | |
#intercom-container-body { | |
background-color: transparent !important; | |
} | |
#intercom-container .intercom-launcher { | |
width: $icon-size; | |
height: $icon-size; | |
} | |
#intercom-container .intercom-launcher-open-icon { | |
background-size: 54% 60%; | |
background-position: 50% 60%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment