o1-mini-2024-09-12· OpenAI
WildChat-4.8M (AI2)
<style> body { margin: 0; padding: 0; overflow: hidden; height: 100vh; background-color:…
- User
function startProgress() { loadingContainer.style.display = 'flex'; progressBar.style.width = '0%'; progress = 0; interval = setInterval(() => { if (progress < 100) { progress += 10; progressBar.style.width = progress + '%'; } if (progress === 100) { clearInterval(interval); if (!iframeLoadedFlag) { retryButton.style.display = 'block'; errorMessage.style.display = 'block'; } } }, 1000); } function iframeLoaded() { iframeLoadedFlag = true; clearInterval(interval); loadingContainer.style.display = 'none'; document.getElementById('myIframe').style.display = 'block'; hideUnwantedElements(); setupElementHiding(); } function iframeError() { clearInterval(interval); loadingContainer.style.display = 'flex'; retryButton.style.display = 'block'; errorMessage.style.display = 'block'; } retryButton.addEventListener('click', function() { progress = 0; progressBar.style.width = '0%'; iframeLoadedFlag = false; retryButton.style.display = 'none'; errorMessage.style.display = 'none'; loadingContainer.style.display = 'flex'; document.getElementById('myIframe').style.display = 'none'; loadIframe(); startProgress(); }); function loadIframe() { const iframe = document.getElementById('myIframe'); const urlParts = ['https:', '', 'fffiloni-pasd.hf.space/--replicas/aieqz', '']; iframe.src = urlParts.join('/'); iframe.onload = iframeLoaded; iframe.onerror = iframeError; } function hideUnwantedElements() { const iframe = document.getElementById('myIframe'); try { const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; if (!iframeDocument) return; // مخفی یا جایگزین کردن تصاویر مشخصشده const images = iframeDocument.querySelectorAll('img'); images.forEach(img => { const src = img.src; if ( src.includes('https://huggingface.co/spaces/fffiloni/PASD?duplicate=true') || src.includes('https://github.com/yangxy/PASD') || src.includes('https://huggingface.co/papers/2308.14469') ) { img.style.display = 'none'; } }); // مخفی کردن لینکهای مشخصشده const links = iframeDocument.querySelectorAll('a'); links.forEach(link => { if (link.href === 'https://gradio.app/') { link.style.display = 'none'; } }); // مخفی یا جایگزین کردن متون مشخصشده const unwantedTexts = [ "Pixel-Aware Stable Diffusion for Realistic Image Super-resolution and Personalized Stylization", "Made with Gradio" ]; unwantedTexts.forEach(unwanted => { const textNodes = getTextNodesContaining(iframeDocument.body, unwanted); textNodes.forEach(node => { const parentElement = node.parentElement; if (parentElement) { parentElement.style.display = 'none'; } }); }); // جایگزینی متن "PASD Magnify" با "افزایش کیفیت تصاویر با برنامه هوش مصنوعی" const textsToReplace = { "PASD Magnify": "افزایش کیفیت تصاویر با برنامه هوش مصنوعی" }; Object.keys(textsToReplace).forEach(originalText => { const newText = textsToReplace[originalText]; const textNodes = getTextNodesContaining(iframeDocument.body, originalText); textNodes.forEach(node => { node.textContent = node.textContent.replace(new RegExp(escapeRegExp(originalText), 'g'), newText); }); }); } catch (error) { console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error); } } function getTextNodesContaining(node, text) { let textNodes = []; if (node.nodeType === Node.TEXT_NODE && node.nodeValue.includes(text)) { textNodes.push(node); } else { node.childNodes.forEach(child => { textNodes = textNodes.concat(getTextNodesContaining(child, text)); }); } return textNodes; } function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } function setupElementHiding() { const iframe = document.getElementById('myIframe'); try { const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; if (!iframeDocument) return; hideUnwantedElements(); const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes.length) { hideUnwantedElements(); } }); }); observer.observe(iframeDocument.body, { childList: true, subtree: true }); } catch (error) { console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error); } } function handleDownload(event) { event.preventDefault(); const iframe = document.getElementById('myIframe'); const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; try { const images = iframeDocument.querySelectorAll('img'); if (images.length === 0) { alert("هیچ تصویری با فرمت JPEG برای دانلود یافت نشد."); return; } let jpegImages = []; images.forEach((img) => { if (img.src.endsWith('.jpeg') || img.src.endsWith('.jpg')) { jpegImages.push(img.src); } }); if (jpegImages.length === 0) { alert("هیچ تصویر ساخته شدهای برای دانلود یافت نشد."); return; } const numImages = jpegImages.length; if (confirm(`${numImages} تصویر ساخته شده پیدا شد.\nبرای دانلود روی "تأیید" کلیک کنید. بعد از باز شدن مرورگر روی تصویر محکم نگه دارید و بارگیری تصویر را انتخاب کنید.`)) { jpegImages.forEach((imageUrl) => { window.open(imageUrl, '_blank'); }); } } catch (error) { console.error("خطا در شناسایی تصاویر: ", error); alert("خطایی در شناسایی تصاویر رخ داد."); } } document.getElementById('downloadButton').addEventListener('click', handleDownload); document.getElementById('downloadButtonBottom').addEventListener('click', handleDownload); const modal = document.getElementById('myModal'); const closeBtn = document.getElementById('closeBtn'); const descriptionButton = document.getElementById('descriptionButton'); // نمایش پنجره توضیحات descriptionButton.addEventListener('click', function(event) { event.preventDefault(); modal.style.display = 'block'; }); // دکمه بستن داخل پنجره closeBtn.addEventListener('click', function() { modal.style.display = 'none'; }); // بستن پنجره در صورت کلیک خارج از آن window.onclick = function(event) { if (event.target == modal) { modal.style.display = 'none'; } } loadIframe(); startProgress(); - Assistant
در کد شما:
- مقدار مخفی شده در بالا: ۵.۵ سانتیمتر
- مقدار مخفی شده در پایین: ۳.۵ سانتیمتر
این مقادیر از طریق تنظیمات
top: -208.5px;برای بالا وheight: calc(100% + 132.3px);برای پایین اعمال شدهاند.