به منظور انجام تغییرات مورد نظر شما، کد اصلی را به گونهای ویرایش کردهام که:
- لوگوی لینکدار به
https://aichatru.ru/fa کاملاً مخفی شود.
- دکمههای "دانلود تصویر" و "توضیحات" و تمامی بخشهای مرتبط با آنها حذف گردد.
در ادامه، کد کامل و اصلاحشده را مشاهده میکنید:
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<title>صفحه با iframe</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
height: 100vh;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
.iframe-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: none;
display: none; /* مخفی تا زمانی که سایت بارگذاری شود */
}
.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>
</head>
<body>
<!-- حذف دکمههای دانلود و توضیحات و پنجرههای مدال مرتبط -->
<div class="iframe-container">
<div class="loading" id="loadingContainer">
<div class="loading-message">لطفاً صبر کنید...</div>
<div class="progress">
<div class="progress-bar" id="progressBar"></div>
</div>
<div class="error-message" id="errorMessage">خسته شدم🥺 میخوای دوباره بسازم؟ مشکلی نیست آیپی عوض کن.</div>
<button id="retryButton">بارگذاری مجدد</button>
</div>
<iframe id="myIframe" sandbox="allow-scripts allow-same-origin allow-forms allow-modals" allow="clipboard-read; clipboard-write"></iframe>
</div>
<script>
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;
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:', '', 'aichatru.ru/fa/app', ''];
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 unwantedLinks = [
'https://gradio.app/',
'https://huggingface.co/spaces/fffiloni/PASD?duplicate=true',
'https://github.com/yangxy/PASD',
'https://huggingface.co/papers/2308.14469',
'https://aichatru.ru/fa', // اضافهشده
'https://aichatru.ru/fa/' // اضافهشده
];
// مخفی کردن لینکهای مشخصشده و تصاویر داخل آنها
unwantedLinks.forEach(url => {
const links = iframeDocument.querySelectorAll(`a[href="${url}"]`);
links.forEach(link => {
link.style.display = 'none';
// مخفی کردن تصاویر داخل لینک
const images = link.querySelectorAll('img');
images.forEach(img => {
img.style.display = 'none';
});
});
});
// مخفی کردن تصاویر با src مشخصشده
const images = iframeDocument.querySelectorAll('img');
images.forEach(img => {
const src = img.src;
if (unwantedLinks.includes(src)) {
img.style.display = 'none';
}
});
// مخفی کردن متون مشخصشده
const unwantedTexts = [
"Pixel-Aware Stable Diffusion for Realistic Image Super-resolution and Personalized Stylization",
"Made with Gradio",
"ساخته شده با gradio"
];
unwantedTexts.forEach(unwanted => {
const textNodes = getTextNodesContaining(iframeDocument.body, unwanted);
textNodes.forEach(node => {
const parentElement = node.parentElement;
if (parentElement) {
parentElement.style.display = 'none';
}
});
});
// جایگزینی متون مشخصشده
const textsToReplace = {
"PASD Magnify": "افزایش کیفیت تصاویر با برنامه هوش مصنوعی",
"Submit": "ساخت",
"Advanced settings": "تنظیمات پیشرفته",
"Prompt": "پرامپت (پرامپت رو به زبان انگلیسی وارد کنید)",
"You have exceeded your GPU quota": "محدودیت جی پی یو: انگار با ربات زیاد کار کردی! این محدودیت ۱۲ ساعت بعد برداشته میشه، اما اگه الان میخوای این محدودیت برداشته بشه امکانش هست. طبق ویدیو آموزشی داخل برنامه فیلترشکن پور لایت یک بار خاموش کن و دوباره روشن کن تا این محدودیت برداشته بشه.",
"Added": "چه چیزی اعمال بشه",
"Negative": "چه چیزی اعمال نشه",
"On mobile, the connection can break if this tab is unfocused or the device sleeps, losing your position in queue.": "اجرای دستور کاربر برای افزایش کیفیت عکس با برنامه هوش مصنوعی",
"Error": "خسته شدم🥺 میخوای دوباره بسازم؟ مشکلی نیست آیپی عوض کن",
"error": "خسته شدم🥺 میخوای دوباره بسازم؟ مشکلی نیست آیپی عوض کن"
};
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 = [];
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);
}
}
// بارگذاری iframe و شروع پروگرس
loadIframe();
startProgress();
</script>
</body>
</html>
تغییرات انجام شده:
-
حذف دکمهها و پنجرههای مدال:
- تمامی عناصر HTML مربوط به دکمههای دانلود و توضیحات به همراه پنجرههای مدال (
downloadModal و myModal) حذف شدند.
- در بخش CSS نیز تمام استایلهای مرتبط با این عناصر حذف گردید تا کد تمیز و بهینه باقی بماند.
-
مخفیسازی لوگوی لینکدار:
- در تابع
hideUnwantedElements، لینک https://aichatru.ru/fa به لیست unwantedLinks اضافه شد. این کار باعث میشود که هر لینک یا تصویری که به این آدرس اشاره دارد، کامل مخفی شود.
- همچنین، تصاویر داخل این لینک نیز به طور خودکار مخفی خواهند شد.
-
بهبود دسترسی به عناصر iframe:
- اطمینان حاصل شده است که تمامی تغییرات مورد نیاز پس از بارگذاری iframe اعمال میشوند و در صورت بروز خطا، پیام مناسبی نمایش داده میشود.
-
حذف کدهای غیر ضروری:
- تمامی کدهای مربوط به عملکردهای حذف شده (مانند دانلود تصاویر و نمایش توضیحات) حذف شدند تا کد نهایی سادهتر و کارآمدتر باشد.
توضیحات اضافی:
این کد اکنون به طور کامل دکمههای مورد نظر شما را حذف کرده و لوگوی لینکدار را مخفی میسازد. در صورت نیاز به هر گونه تغییرات بیشتر، لطفاً اطلاع دهید.