// Create a function to check for the live preview function checkLivePreview() { console.log("123") var script = document.createElement('script');script.src = "https://code.jquery.com/jquery-3.4.1.min.js";document.getElementsByTagName('head')[0].appendChild(script); // const parentElement = document.querySelector('gradio-app'); // const shadowRoot = parentElement.shadowRoot; const livePreview = document.querySelector('.livePreview'); // const livePreview = $('.livePreview'); if (livePreview) { // Initialize variables to hold highest resolution and corresponding image node let highestResolution = 0; let highestResImgNode = null; // Loop through all child nodes in livePreview to find the image with the highest resolution for (let imgNode of livePreview.querySelectorAll('img')) { const resolution = imgNode.naturalHeight * imgNode.naturalWidth; if (resolution > highestResolution) { highestResolution = resolution; highestResImgNode = imgNode; } } // If no suitable image found, skip if (highestResImgNode === null || highestResImgNode.naturalHeight < 1100) { console.log("skip"); return; } // Create a new window for the gallery const galleryWindow = window.open('', 'galleryWindow', 'width=100%,height=100%,resizable=yes,scrollbars=yes'); // Clone the highest resolution image const highestResImgNodeClone = highestResImgNode.cloneNode(); highestResImgNodeClone.style.width = '100%'; highestResImgNodeClone.style.height = '100%'; // Populate the new window galleryWindow.document.body.innerHTML = highestResImgNodeClone.outerHTML; galleryWindow.document.body.style.position = 'fixed'; galleryWindow.document.body.style.top = '0'; galleryWindow.document.body.style.right = '0'; } } // Call the function every 1 second out = setInterval(checkLivePreview, 1000);