Skip to content

Instantly share code, notes, and snippets.

@groksrc
Created April 19, 2023 20:03
Show Gist options
  • Save groksrc/b5af7c8cf879b204f6df4e73c4f21892 to your computer and use it in GitHub Desktop.
Save groksrc/b5af7c8cf879b204f6df4e73c4f21892 to your computer and use it in GitHub Desktop.
// Function to set the width and height of the element
function setElementSize(element) {
element.style.width = '47px';
element.style.height = '47px';
}
// Function to check for the element's existence and set its size
function checkForElement() {
const chatWidget = document.querySelector('chat-widget');
if (chatWidget && chatWidget.shadowRoot) {
const element = chatWidget.shadowRoot.querySelector('#lc_text-widget--btn');
if (element) {
setElementSize(element);
clearInterval(intervalId); // Stop checking once the element is found and resized
}
}
}
// Start checking for the element every 100 milliseconds
const intervalId = setInterval(checkForElement, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment