body {
margin: 0;
padding: 0;
overflow: hidden;
height: calc(var(--vh, 1vh) * 100);
background-color: #f0f0f0;
font-family: Arial, sans-serif;
text-align: center;
direction: rtl;
}
/* حالت عادی */
.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, 1vh) * 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 0.2s ease;
}
.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;
transition: background-color 0.3s;
}
#retryButton:hover {
background-color: #45a049;
}
/* اعلان */
.notification {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
padding: 20px 30px;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
z-index: 10003;
display: none;
text-align: center;
width: 90%;
max-width: 400px;
max-height: 80vh;
overflow-y: auto;
}
.notification-buttons {
display: flex;
justify-content: center;
margin-top: 20px;
flex-wrap: wrap;
}
.notification-buttons button {
background-color: #4CAF50;
color: #ffffff;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
.notification-buttons button:hover {
background-color: #45a049;
}
/* استایلهای مربوط به تصاویر و دکمه ذخیره */
.image-container {
margin-bottom: 20px;
}
.save-image-button {
background-color: #4CAF50;
color: #ffffff;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
}
.save-image-button:hover {
background-color: #45a049;
}
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');
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().toLowerCase().includes("c4ai's acceptable use policy".toLowerCase())
) {
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",
"Gemini coder",
"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.",
"Open Ai",
"OpenAi",
"open ai",
"openai"
];
const textsToReplace = {
"Aya Expanse": "هوش مصنوعی",
"Describe an image": "چه عکسی برات بسازم توضیحات تو بنویس تا در لحظه تبدیل به تصویر کنم(نسخه فلاکس رایگان)",
"Visualize with Aya": "🖼️ساخت تصاویر",
"Submit": "ارسال",
"Clear": "پاک",
"Load example prompt for:": "این نسخه رایگان است برای ساخت تصاویر زیباتر و با کیفیت تر به قسمت ساخت عکس مراجعه کنید و از فلاکس پرو پیشرفته استفاده کنید",
"Chat with Aya": "🤖چت",
"Open Ai": "هوش مصنوعی"
};
unwantedTexts.forEach(unwanted => {
const textNodes = getTextNodesContaining(iframeDocument.body, unwanted);
textNodes.forEach(node => {
const parentElement = node.parentElement;
if (parentElement) {
// مخفی کردن عنصر والد تا سطح مشخصی
let elementToHide = parentElement;
for (let i = 0; i < 3; i++) {
if (elementToHide.parentElement) {
elementToHide = elementToHide.parentElement;
}
}
elementToHide.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), 'gi'), newText);
});
});
} catch (error) {
console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error);
}
}
function getTextNodesContaining(node, text) {
let textNodes = [];
const searchText = text.toLowerCase();
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT, {
acceptNode: function(node) {
return node.nodeValue.toLowerCase().includes(searchText) ? 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) {
hideUnwantedElements();
});
mutationObserver.observe(iframeDocument.body, {
childList: true,
subtree: true,
attributes: true,
characterData: true
});
} catch (error) {
console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error);
}
}
retryButton.addEventListener('click', function() {
loadIframe();
});
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();
}
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();
توضیحات:
-
جایگزینی متون با حساسیت به حروف کوچک و بزرگ: در تابع getTextNodesContaining و هنگام جایگزینی متون، حساسیت به حروف کوچک و بزرگ را حذف کردیم تا تمامی موارد "Open Ai" به هر شکلی (مانند "open ai" یا "OpenAI") را شناسایی کنیم.
-
اضافه کردن متون ناخواسته: در آرایه unwantedTexts، تمامی شکلهای ممکن از "Open Ai" را اضافه کردیم تا در صورت مشاهده، عنصر حاوی آن را مخفی کنیم.
-
بهروزرسانی MutationObserver: تنظیمات MutationObserver را بهروزرسانی کردیم تا تغییرات در ویژگیها (attributes) و دادههای کاراکتری (characterData) را نیز مشاهده کند. این کار کمک میکند تا در صورت تغییرات دینامیک در DOM، متون ناخواسته بهدرستی مخفی شوند.
-
بررسی والدین عناصر: هنگام مخفی کردن عناصر، تا سه سطح از والدین را بررسی میکنیم تا اطمینان حاصل کنیم که عنصر مناسبی مخفی میشود.
با این تغییرات، متن "Open Ai" در تمامی بخشهای سایت (از جمله لیستهایی که پس از کلیک نمایش داده میشوند) مخفی خواهد شد و دیگر دیده نخواهد شد.