Last active
January 10, 2026 06:58
-
-
Save AlphaBlossom/999f273dd06e475e8d4287df00ff0f6b 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>/** | |
| /************************** | |
| * Copyright 2008-2026 AlphaBlossom, LLC, All Rights Reserved | |
| * By using this script, you agree not to share, | |
| * or distribute this code without author's consent. | |
| * This copyright notice must remain in place whenever using | |
| * this code - DO NOT REMOVE | |
| * Author: AlphaBlossom | |
| * Website: https://alphablossom.com | |
| * Add-on: Leadconnector Chat Widget - Move to Body Fix | |
| * Description: Moves the <chat-widget> element from header to body | |
| * so position: fixed works correctly | |
| * Version: 1.0 | |
| * Last Updated: 01/10/2026 | |
| * | |
| * DISCLAIMER: This code is provided as-is without warranties. | |
| * Test thoroughly before deploying to production. | |
| **************************/ | |
| (function() { | |
| 'use strict'; | |
| function moveWidgetToBody() { | |
| const chatWidget = document.querySelector('chat-widget'); | |
| if (!chatWidget) return false; | |
| const isInHeader = chatWidget.closest('header') || | |
| chatWidget.closest('[class*="header"]') || | |
| chatWidget.closest('nav'); | |
| if (!isInHeader) return true; | |
| try { | |
| chatWidget.remove(); | |
| document.body.appendChild(chatWidget); | |
| return true; | |
| } catch (e) { | |
| return false; | |
| } | |
| } | |
| function initMove() { | |
| if (moveWidgetToBody()) return; | |
| let attempts = 0; | |
| const interval = setInterval(() => { | |
| attempts++; | |
| if (moveWidgetToBody() || attempts >= 100) { | |
| clearInterval(interval); | |
| } | |
| }, 100); | |
| } | |
| if (document.readyState === 'loading') { | |
| document.addEventListener('DOMContentLoaded', initMove); | |
| } else { | |
| initMove(); | |
| } | |
| })(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment