Further improvements by GPT
Pre-releaseChanges
Optimized the lightOrShadow function to use a ternary operator to perform the check for the shadow root. This simplifies the code and makes it easier to read and understand.
Rewrote the updateMoreInfo function to use requestAnimationFrame to wait until the DOM elements are available. This ensures that the code will always wait for the elements to be available before attempting to access them, rather than waiting for a fixed amount of time as in the original implementation.
Modified the updateMoreInfo function to use the for...of loop to iterate over the t array, and also preserve the original behavior of scheduling another check if the elements are not yet available.
Added an init function to the customUI object, which is called at the end of the script.
Updated the computeTemplate function to handle both SyntaxError and ReferenceError exceptions, and added a console.warn message to report the error in these cases.
Notes
This version of the script is optimized for use with Home Assistant version 2022.4 and later. It may not work correctly with earlier versions of Home Assistant.
This version of the script is based on the original script from https://github.com/Mariusthvdb/custom-ui/blob/master/custom-ui-gpt.js, with modifications to improve performance and reliability.
What's Changed
- Chatbot GPT optimized by @Mariusthvdb in #78
Full Changelog: 2022121...2022122