MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / showLoading

Function showLoading

scripts/helpers/utils.js:666–691  ·  view source on GitHub ↗
(text = "")

Source from the content-addressed store, hash-verified

664}
665
666export function showLoading(text = "") {
667 let html = /*html*/ `
668 <div class="loading-container">
669 <div>
670 <div class="loader"></div><br/>
671 <p class="text">${text}</p>
672 </div>
673 </div>
674 `;
675 let div = document.createElement("div");
676 div.innerHTML = html;
677 document.body.appendChild(div);
678
679 return {
680 closeLoading: () => div?.remove?.(),
681 setLoadingText: (textOrFunction) => {
682 let textP = document.querySelector(".loading-container .text");
683 if (!textP) return;
684 if (typeof textOrFunction === "function") {
685 textP.innerHTML = textOrFunction(textP.innerHTML);
686 } else {
687 textP.innerHTML = textOrFunction;
688 }
689 },
690 };
691}
692
693export function openPopupWithHtml(html, width = 300, height = 300) {
694 let win = window.open(

Calls 1

removeMethod · 0.45

Tested by

no test coverage detected