const siteURL = 'https://akhaliq-anychat.hf.space';
const excludeUrls = new Set([
'https://yanze-pulid.hf.space/--replicas/3t64n/file=/tmp/gradio/7567beceda2541f726af7beb4c9aa857b4a96b77/liuyifei.png',
'https://prodiazenafey-faceswap.hf.space/file=/tmp/gradio/44ce6237aa956835c13beb89ae4c83f8afea7edb/example3.jpg',
'https://cohereforai-aya-expanse.hf.space/gradio_api/file=/tmp/gradio/195e9bc39ae67221fa523905a8a7f36b44bb03ebd3310192cf2ad0235b29fc1b/AyaExpanse.png'
]);
const progressBar = document.getElementById('progressBar');
const retryButton = document.getElementById('retryButton');
const errorMessage = document.getElementById('errorMessage');
const loadingContainer = document.getElementById('loadingContainer');
const iframe = document.getElementById('myIframe');
const downloadButton = document.getElementById('downloadButton');
const descriptionButton = document.getElementById('descriptionButton');
const promptButton = document.getElementById('promptButton');
let iframeLoadedFlag = false;
let mutationObserver = null;
let debounceTimeout = null;
let startTime = null;
let progressInterval = null;
function hideUnwantedElements() {
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) return;
// مخفی یا جایگزین کردن تصاویر مشخصشده
const images = iframeDocument.querySelectorAll('img');
images.forEach(img => {
if (img.src.endsWith('.png')) {
img.src = 'https://app.puzzley.net/uploads/user/Jydo/هوش%20مصنوعی/Negar_1731256487636.png';
}
});
// مخفی کردن لینکهای مشخصشده
const linksToHide = new Set([
'https://docs.cohere.com/docs/c4ai-acceptable-use-policy',
'https://gradio.app/',
'https://huggingface.co/openai/whisper-large-v3-turbo',
'https://groq.com/',
'http://neets.ai/',
'https://huggingface.co/black-forest-labs/FLUX.1-schnell'
]);
const links = iframeDocument.querySelectorAll('a');
links.forEach(link => {
if (
linksToHide.has(link.href) ||
link.textContent.trim().includes("C4AI's Acceptable Use Policy")
) {
link.style.display = 'none';
}
});
// مخفی یا جایگزین کردن متون مشخصشده
const unwantedTexts = [
"C4AI Aya Expanse is a state-of-art model with highly advanced capabilities to connect the world across languages.",
"You can use this space to chat, speak and visualize with Aya Expanse in 23 languages.",
"Made with gradio",
"Whisper large-v3-turbo",
"Groq",
"تتت",
"Speak with Aya",
"neets.ai",
"Flux Schnell",
"This space uses Aya Expanse for translating multilingual prompts and generating detailed image descriptions and Flux Schnell for Image Generation.",
"To enable voice interaction with Aya Expanse, this space uses Whisper large-v3-turbo and Groq for STT and neets.ai for TTS."
];
const textsToReplace = {
"Aya Expanse": "هوش مصنوعی",
"Describe an image": "چه عکسی برات بسازم توضیحات تو بنویس تا در لحظه تبدیل به تصویر کنم(نسخه فلاکس رایگان)",
"Visualize with Aya": "🖼️ساخت تصاویر",
"Submit": "ارسال",
"Clear": "پاک",
"Load example prompt for:": "این نسخه رایگان است برای ساخت تصاویر زیباتر و با کیفیت تر به قسمت ساخت عکس مراجعه کنید و از فلاکس پرو پیشرفته استفاده کنید",
"Chat with Aya": "🤖چت",
"Aya": "هوش مصنوعی"
};
unwantedTexts.forEach(unwanted => {
const textNodes = getTextNodesContaining(iframeDocument.body, unwanted);
textNodes.forEach(node => {
const parentElement = node.parentElement;
if (parentElement) {
parentElement.style.display = 'none';
}
});
});
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 = [];
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT, {
acceptNode: function(node) {
return node.nodeValue.includes(text) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
}
}, false);
while(walker.nextNode()) {
textNodes.push(walker.currentNode);
}
return textNodes;
}
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function iframeLoaded() {
iframeLoadedFlag = true;
clearInterval(progressInterval);
// Animate progress bar to 100% over 4 seconds
progressBar.style.transition = 'width 4s linear';
progressBar.style.width = '100%';
// After 4 seconds, hide loading and show iframe
setTimeout(() => {
hideLoadingAndShowIframe();
}, 4000);
}
function iframeError() {
clearInterval(progressInterval);
errorMessage.style.display = 'block';
retryButton.style.display = 'block';
progressBar.style.width = '0%';
progressBar.style.transition = 'none';
}
function setupElementHiding() {
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) return;
hideUnwantedElements();
// استفاده از MutationObserver با تنظیمات بهینه
if (mutationObserver) {
mutationObserver.disconnect();
}
mutationObserver = new MutationObserver(function(mutations) {
if (debounceTimeout) {
clearTimeout(debounceTimeout);
}
debounceTimeout = setTimeout(() => {
hideUnwantedElements();
}, 500); // تاخیر 500 میلیثانیه
});
mutationObserver.observe(iframeDocument.body, {
childList: true,
subtree: true
});
} catch (error) {
console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error);
}
}
retryButton.addEventListener('click', function() {
loadIframe();
});
// تابع ایجاد اعلان ساده
function createNotification(messageText, buttonsArray) {
// حذف اعلانهای قبلی
const existingNotifications = document.querySelectorAll('.notification');
existingNotifications.forEach(notif => notif.remove());
const notificationDiv = document.createElement('div');
notificationDiv.classList.add('notification');
notificationDiv.style.display = 'block';
// پیام
const messageSpan = document.createElement('div');
messageSpan.innerHTML = messageText;
notificationDiv.appendChild(messageSpan);
// دکمهها
if (buttonsArray.length > 0) {
const buttonsDiv = document.createElement('div');
buttonsDiv.classList.add('notification-buttons');
buttonsArray.forEach((btn) => {
const button = document.createElement('button');
button.innerText = btn.text;
button.onclick = () => {
btn.onclick();
if (!btn.preventClose) {
notificationDiv.style.display = 'none';
}
};
buttonsDiv.appendChild(button);
});
notificationDiv.appendChild(buttonsDiv);
}
document.body.appendChild(notificationDiv);
return notificationDiv;
}
function handleDownload(event) {
event.preventDefault();
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
try {
const images = iframeDocument.querySelectorAll('img');
if (images.length === 0) {
alert("هیچ تصویری با فرمت WEBP برای دانلود یافت نشد.");
return;
}
let webpImages = [];
images.forEach((img) => {
if (img.src.endsWith('.webp') && !excludeUrls.has(img.src)) {
webpImages.push(img.src);
}
});
webpImages = webpImages.slice(0, 4);
if (webpImages.length === 0) {
alert("هیچ تصویر ساخته شدهای یافت نشد.");
return;
}
// ایجاد محتوای اعلان با تصاویر و دکمههای ذخیره
const notificationContent = webpImages.map((imageUrl, index) => `
<div class="image-container">
<img src="${imageUrl}" alt="Image ${index+1}" style="max-width:100%; height:auto;">
<button class="save-image-button" data-image-url="${imageUrl}"> ذخیره و دانلود تصویر</button>
</div>
`).join('');
// نمایش اعلان
const imageNotification = createNotification(
notificationContent,
[
{
text: 'بستن',
onclick: () => {}
}
]
);
// افزودن رویداد کلیک به دکمههای ذخیره تصویر
const saveButtons = imageNotification.querySelectorAll('.save-image-button');
saveButtons.forEach(button => {
button.addEventListener('click', () => {
const imageUrl = button.getAttribute('data-image-url');
processImage(imageUrl);
});
});
} catch (error) {
console.error("خطا در شناسایی تصاویر: ", error);
alert("خطایی در شناسایی تصاویر رخ داد.");
}
}
// تابع برای آپلود تصویر به سرور و دریافت لینک از دامنه خودتان
function processImage(imageUrl) {
// نمایش پیام ساخت لینک دانلود
const buildingLinkNotification = createNotification('در حال ساخت لینک دانلود، لطفاً صبر کنید...', []);
// دریافت تصویر به صورت blob
fetch(imageUrl)
.then(response => response.blob())
.then(blob => {
// آمادهسازی فرم دیتا
const formData = new FormData();
formData.append('image', blob, 'downloaded_image.webp');
// ارسال تصویر به upload.php
return fetch('https://www.aisada.ir/hamed/upload.php', { // آدرس کامل upload.php در سرور خودتان
method: 'POST',
body: formData,
mode: 'cors'
});
})
.then(response => response.json())
.then(data => {
buildingLinkNotification.style.display = 'none';
if (data.success) {
// نمایش اعلان با دکمه دانلود
createNotification(
'لینک دانلود تصویر آماده شد.',
[
{
text: 'دانلود',
onclick: () => {
window.open(data.url, '_blank');
}
},
{
text: 'بستن',
onclick: () => {}
}
]
);
} else {
alert('خطا در آپلود تصویر: ' + data.message);
}
})
.catch(error => {
buildingLinkNotification.style.display = 'none';
console.error('خطا:', error);
alert('خطا در آپلود تصویر');
});
}
downloadButton.addEventListener('click', handleDownload);
// پنجره توضیحات
descriptionButton.addEventListener('click', function(event) {
event.preventDefault();
createNotification('ربات هوشمند برنامه <span style="color: #008080;">هوش مصنوعی</span><br>با قابلیت ساخت تصاویر در لحظه<br>و گفتگو پیشرفته<br>ساخت تصاویر این ربات از متن فارسی پشتیبانی میکند و شما میتوانید به فارسی هر تصویری که خواستید را تولید کنید.<br>این ربات هیچ محدودیت برای تولید تصاویر ندارد هر چقدر خواستید میتونید تولید کنید و همچنین برای تولید تصاویر حرفه ای تر روی دکمهP کلیک کنید و از پرامپت های حرفه ای در قسمت متن تصویری که میسازید قرار دهید.<br>در بعضی مواقع اگر تصاویر پشت سر هم تولید نشد یک بار دکمه پاک را کلیک کنید یا از صفحه خارج شوید دوباره وارد شوید.', [
{ text: 'بستن', onclick: () => {} }
]);
});
// پنجره پرامپتها
promptButton.addEventListener('click', function(event) {
event.preventDefault();
showPromptCategories();
});
function showPromptCategories() {
const categories = {
"lighting": "پرامپتهای نورپردازی 💡",
"special_lighting": "پرامپتهای خاص نورپردازی ✨",
"details_quality": "پرامپتهای جزئیات و کیفیت 🔍",
"punk": "پرامپتهای Punk 🎸",
"landscape": "پرامپتهای منظره 🌄",
"colors": "پرامپتهای رنگ 🎨",
"artist_style": "پرامپتهای استایل هنرمندان 🖌️",
"iranian_art_identity": "پرامپتهای هویت هنری ایرانی 🏺",
"iranian_set_design": "پرامپتهای فضاسازی ایرانی 🏙️"
};
let categoriesHtml = '<div class="category-container">';
Object.keys(categories).forEach(key => {
categoriesHtml += `
<button class="category-button" data-key="${key}">${categories[key]}</button>
`;
});
categoriesHtml += '</div>';
createNotification(`<div>${categoriesHtml}</div>`, [
{ text: 'بستن', onclick: () => {} }
]);
// افزودن رویداد کلیک به دکمههای دستهبندی
const categoryButtons = document.querySelectorAll('.category-button');
categoryButtons.forEach(button => {
button.addEventListener('click', () => {
const key = button.getAttribute('data-key');
showPrompts(key);
});
});
}
function showPrompts(categoryKey) {
const promptsData = {
"lighting": [
{ "text": "Cinematic lighting", "translation": "نورپردازی سینمایی" },
{ "text": "Soft lighting", "translation": "نورپردازی نرم" },
{ "text": "Softbox lighting", "translation": "نورپردازی با سافتباکس" },
{ "text": "Bright lighting", "translation": "نورپردازی روشن" },
{ "text": "Ambient lighting", "translation": "نورپردازی محیطی" },
{ "text": "Silhouetted", "translation": "سایهدار" },
{ "text": "Flat lighting", "translation": "نورپردازی تخت" },
{ "text": "Backlit Volumetric lighting", "translation": "نورپردازی حجمی پسزمینه" }
],
"special_lighting": [
{ "text": "Neon", "translation": "نئون" },
{ "text": "Holographic", "translation": "هولوگرافیک" },
{ "text": "Glow", "translation": "تابان" },
{ "text": "Bioluminescent", "translation": "زیستتاب" },
{ "text": "Rimlight", "translation": "نور حاشیهای" },
{ "text": "Silhouetted", "translation": "سایهدار" }
],
"details_quality": [
{ "text": "Ultra photoreal", "translation": "فوقالعاده واقعگرایانه" },
{ "text": "Intricate details", "translation": "جزئیات پیچیده" },
{ "text": "Photorealistic", "translation": "فوتورئالیستی" },
{ "text": "Hyper detailed", "translation": "بسیار جزئیاتدار" },
{ "text": "Ultra detailed", "translation": "فوقالعاده جزئیاتدار" },
{ "text": "Extremely detailed", "translation": "بسیار پرجزئیات" },
{ "text": "4K", "translation": "4K" },
{ "text": "8K", "translation": "8K" },
{ "text": "Super resolution", "translation": "وضوح فوقالعاده" },
{ "text": "High resolution", "translation": "وضوح بالا" }
],
"punk": [
{ "text": "Steampunk", "translation": "استیمپانک" },
{ "text": "Cloudpunk", "translation": "کلودپانک" },
{ "text": "Cyberpunk", "translation": "سایبرپانک" },
{ "text": "Forestpunk", "translation": "فورستپانک" },
{ "text": "Decopunk", "translation": "دکوپانک" },
{ "text": "Atompunk", "translation": "اتمپانک" },
{ "text": "Dieselpunk", "translation": "دیزلپانک" },
{ "text": "Biopunk", "translation": "بیوپانک" },
{ "text": "Dinopunk", "translation": "دینوپانک" },
{ "text": "Cassettepunk", "translation": "کاستپانک" },
{ "text": "Dollupunk", "translation": "دالاپانک" },
{ "text": "Catholicpunk", "translation": "کاتولیکپانک" },
{ "text": "Clockpunk", "translation": "کلاکپانک" }
],
"landscape": [
{ "text": "Surreal landscape", "translation": "منظره سورئال" },
{ "text": "Unreal landscape", "translation": "منظره غیرواقعی" },
{ "text": "Fantasy landscape", "translation": "منظره فانتزی" },
{ "text": "Sci-fi landscape", "translation": "منظره علمی-تخیلی" },
{ "text": "Desert landscape", "translation": "منظره بیابانی" },
{ "text": "Tropical paradise", "translation": "بهشت گرمسیری" },
{ "text": "Rainforest scenery", "translation": "منظره جنگل بارانی" },
{ "text": "Expansive mountain range", "translation": "زنجیره کوهستانی گسترده" }
],
"colors": [
{ "text": "Retro colors", "translation": "رنگهای رترو" },
{ "text": "Vivid colors", "translation": "رنگهای زنده" },
{ "text": "Pastel colors", "translation": "رنگهای پاستلی" },
{ "text": "Neon colors", "translation": "رنگهای نئونی" },
{ "text": "Earthy tones", "translation": "رنگهای خاکی" },
{ "text": "Primary colors", "translation": "رنگهای اصلی" },
{ "text": "Monochromatic colors", "translation": "رنگهای تکرنگ" },
{ "text": "Jewel tones", "translation": "رنگهای جواهری" }
],
"artist_style": [
{ "text": "Leonardo da Vinci", "translation": "لئوناردو داوینچی" },
{ "text": "Michelangelo", "translation": "میکلآنجلو" },
{ "text": "Rembrandt", "translation": "رمبراندت" },
{ "text": "Vermeer", "translation": "ورمیر" },
{ "text": "Jean-Antoine Watteau", "translation": "ژان-آنتوان واتو" },
{ "text": "Eugene Delacroix", "translation": "اوژن دلاکروا" },
{ "text": "Claude Monet", "translation": "کلود مونه" },
{ "text": "Georges Seurat", "translation": "ژرژ سورا" },
{ "text": "Vincent van Gogh", "translation": "ونسان ون گوگ" },
{ "text": "Edvard Munch", "translation": "ادوارد مونک" },
{ "text": "Gustav Klimt", "translation": "گوستاو کلیمت" },
{ "text": "Pablo Picasso", "translation": "پابلو پیکاسو" },
{ "text": "Henri Matisse", "translation": "هانری ماتیس" },
{ "text": "Rene Magritte", "translation": "رنه ماگریت" },
{ "text": "Georgia O'Keeffe", "translation": "جورجیا اوکیف" },
{ "text": "Salvador Dalí", "translation": "سالوادور دالی" },
{ "text": "Edward Hopper", "translation": "ادوارد هاپر" },
{ "text": "Frida Kahlo", "translation": "فریدا کالو" },
{ "text": "Jackson Pollock", "translation": "جکسون پولاک" },
{ "text": "Andy Warhol", "translation": "اندی وارهول" }
],
"iranian_art_identity": [
{ "text": "Persian Carpet Weaving", "translation": "قالیبافی ایرانی" },
{ "text": "Persian Tilework", "translation": "کاشیکاری ایرانی" },
{ "text": "Persian Miniature Painting", "translation": "نگارگری ایرانی" },
{ "text": "Persian Calligraphy", "translation": "خوشنویسی ایرانی" },
{ "text": "Traditional Textiles", "translation": "منسوجات سنتی" },
{ "text": "Woodcarving", "translation": "منبتکاری" },
{ "text": "Persian Embroidery", "translation": "گلدوزی ایرانی" },
{ "text": "Persian Mirrorwork", "translation": "آینهکاری ایرانی" },
{ "text": "Termeh Weaving", "translation": "بافت ترمه" },
{ "text": "Persian Jewelry", "translation": "جواهرسازی ایرانی" }
],
"iranian_set_design": [
{ "text": "Tehran clothe", "translation": "لباس تهرانی" },
{ "text": "Tehran woman", "translation": "زن تهرانی" },
{ "text": "Tehran man", "translation": "مرد تهرانی" },
{ "text": "Modern Persian vibe", "translation": "حس و حال مدرن پارسی" },
{ "text": "Persian art", "translation": "هنر پارسی" },
{ "text": "Tehran atmosphere", "translation": "فضای تهران" },
{ "text": "Esfahan vibe", "translation": "حس و حال اصفهان" },
{ "text": "Qajar art", "translation": "هنر قاجار" },
{ "text": "Princess Qajar", "translation": "شاهزاده قاجار" },
{ "text": "Persian empire", "translation": "امپراتوری پارس" }
]
};
const prompts = promptsData[categoryKey];
if (!prompts) return;
let promptsHtml = '<div class="prompt-container">';
prompts.forEach(prompt => {
promptsHtml += `
<div class="prompt-item">
<div class="prompt-text">${prompt.text} (${prompt.translation})</div>
<button class="prompt-copy-button" data-text="${prompt.text}">کپی</button>
</div>
`;
});
promptsHtml += '</div>';
createNotification(`<div>${promptsHtml}</div>`, [
{ text: 'بازگشت', onclick: () => showPromptCategories() },
{ text: 'بستن', onclick: () => {} }
]);
// افزودن رویداد کلیک به دکمههای کپی
const copyButtons = document.querySelectorAll('.prompt-copy-button');
copyButtons.forEach(button => {
button.addEventListener('click', () => {
const text = button.getAttribute('data-text');
copyText(text);
});
});
}
// تابع کپی کردن متن
function copyText(text) {
navigator.clipboard.writeText(text).then(() => {
alert("متن با موفقیت کپی شد: " + text);
}).catch(err => {
console.error("خطا در کپی کردن متن: ", err);
alert("خطایی در کپی کردن متن رخ داد.");
});
}
function hideLoadingAndShowIframe() {
loadingContainer.style.display = 'none';
const iframeContainer = document.querySelector('.iframe-container');
iframeContainer.classList.remove('normal');
iframeContainer.classList.add('fullscreen');
iframe.style.display = 'block';
hideUnwantedElements();
setupElementHiding();
// نمایش دکمهها پس از بارگذاری iframe
downloadButton.style.display = 'flex';
descriptionButton.style.display = 'flex';
promptButton.style.display = 'flex';
}
function loadIframe() {
clearInterval(progressInterval);
progressBar.style.width = '0%';
progressBar.style.transition = 'none';
loadingContainer.style.display = 'flex';
errorMessage.style.display = 'none';
retryButton.style.display = 'none';
iframe.style.display = 'none';
iframeLoadedFlag = false;
// Reset progress bar
progressBar.style.width = '0%';
progressBar.style.transition = 'width 0.2s ease';
// Start simulated progress up to 90%
let progress = 0;
startTime = Date.now();
progressInterval = setInterval(() => {
if (progress < 90) {
progress += Math.random() * 5; // Increment by random value to simulate progress
if (progress > 90) progress = 90;
progressBar.style.width = progress + '%';
}
}, 200); // Update every 200ms
// Load the iframe
fetch(siteURL, { method: 'HEAD', mode: 'no-cors' })
.then(() => {
iframe.src = siteURL;
iframe.onload = iframeLoaded;
iframe.onerror = iframeError;
})
.catch(() => {
iframeError();
});
}
// شروع بارگذاری iframe
loadIframe();
</script>
برای حذف تمام دکمهها و امکانات مربوط به آنها (از جمله دکمه "پی" و دکمههای دیگر) از کد HTML و JavaScript ارائهشده، میتوانید مراحل زیر را دنبال کنید:
حذف دکمهها از HTML: تمام کد HTML مرتبط با دکمهها را حذف کنید.
حذف کد JavaScript مرتبط: تمام کد JavaScript که به این دکمهها و عملکرد آنها بینظمی دارد را هم حذف کنید.
در این کد تنها دکمههای "توضیحات"، "پرونده" و "پی" پاک شدهاند و دیگر هیچ تغییری در کدهای موجود و عملکردها ایجاد نشده است. اگر باز هم نیاز به تغییر خاصی دارید، لطفاً بفرمایید.