o1-mini-2024-09-12· OpenAI
WildChat-4.8M (AI2)
<p> </p> <style> /* تنظیمات پایه برای body و html / html, body { margin: 0;…
- User
/* متغیر CSS برای ارتفاع نمایشگر */ :root { --vh: 100%; } /* حالت عادی */ .iframe-container.normal { position: relative; width: 100%; height: 100vh; overflow: hidden; } .iframe-container.normal iframe { width: 100%; height: 100%; border: none; display: none; position: relative; top: 0; } /* حالت تمام صفحه */ .iframe-container.fullscreen { position: fixed; top: 0; left: 0; width: 100%; height: calc(var(--vh) * 100); overflow: hidden; z-index: 1; } .iframe-container.fullscreen iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; display: block; } /* استایلهای مشترک */ .loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; z-index: 10000; } .loading-message { margin-bottom: 20px; font-size: 18px; } .progress { width: 80%; max-width: 400px; height: 20px; background-color: #ddd; border-radius: 5px; overflow: hidden; } .progress-bar { height: 100%; width: 0; background-color: #4caf50; transition: width 1s; } .error-message { display: none; color: red; margin-top: 20px; font-size: 16px; text-align: center; } #retryButton { display: none; margin-top: 10px; padding: 10px 20px; font-size: 16px; cursor: pointer; background-color: #4caf50; color: white; border: none; border-radius: 5px; } </style>let progress = 0; const progressBar = document.getElementById('progressBar'); const retryButton = document.getElementById('retryButton'); const errorMessage = document.getElementById('errorMessage'); const loadingContainer = document.getElementById('loadingContainer'); let interval; let iframeLoadedFlag = false; let observer; 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'; const iframeContainer = document.querySelector('.iframe-container'); iframeContainer.classList.remove('normal'); iframeContainer.classList.add('fullscreen'); document.getElementById('myIframe').style.display = 'block'; modifyIframeContent(); setupMutationObserver(); } function iframeError() { clearInterval(interval); loadingContainer.style.display = 'flex'; retryButton.style.display = 'block'; errorMessage.style.display = 'block'; } function loadIframe() { fetch(siteURL, { method: 'HEAD', mode: 'no-cors' }) .then(() => { const iframe = document.getElementById('myIframe'); iframe.src = siteURL; iframe.onload = iframeLoaded; iframe.onerror = iframeError; }) .catch(() => { iframeError(); }); } 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 setVh() { let vh = window.innerHeight * 0.01; document.documentElement.style.setProperty('--vh', `${vh}px`); } setVh(); window.addEventListener('resize', setVh); loadIframe(); startProgress(); function modifyIframeContent() { const iframe = document.getElementById('myIframe'); try { const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; if (!iframeDocument) return; // قطع اتصال MutationObserver if (observer) observer.disconnect(); // مخفی کردن بخش "To learn more about Llama Vision, visit our blog post." const secondText = 'To learn more about Llama Vision, visit our blog post.'; const secondTextNodes = getTextNodesContaining(iframeDocument.body, secondText); secondTextNodes.forEach(node => { const parentElement = node.parentElement; if (parentElement) { parentElement.style.display = 'none'; } }); // مخفی کردن متن "our blog post" اگر به صورت مجزا وجود دارد const blogPostText = 'our blog post'; const blogPostNodes = getTextNodesContaining(iframeDocument.body, blogPostText); blogPostNodes.forEach(node => { const parentElement = node.parentElement; if (parentElement) { parentElement.style.display = 'none'; } }); // مخفی کردن بخش اول متن و جایگزینی آن با متن جدید const firstText = 'Try Multimodal Llama by Meta with transformers in this demo. Upload an image, and start chatting about it, or simply try one of the examples below.'; const firstTextNodes = getTextNodesContaining(iframeDocument.body, firstText); firstTextNodes.forEach(node => { node.textContent = 'جدیدترین نسخه چت بات متا با تحلیل تصاویر. یک تصویر آپلود کنید و درباره آن چت کنید و یا یکی از نمونه های پایین رو امتحان کنید.'; }); // اتصال مجدد MutationObserver if (observer) observer.observe(iframeDocument.body, { childList: true, subtree: true }); } 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 setupMutationObserver() { const iframe = document.getElementById('myIframe'); try { const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; if (!iframeDocument) return; observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes.length) { modifyIframeContent(); } }); }); observer.observe(iframeDocument.body, { childList: true, subtree: true }); } catch (error) { console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error); } } </script> - Assistant