o1-mini-2024-09-12· OpenAI
WildChat-4.8M (AI2)
<p> </p> <style> /* استایل کلی بدن صفحه / body { margin: 0; padding: 0; overflow:…
- Usercode
- Assistant
/* کانتینر iframe */
.iframe-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
/* استایلهای iframe */
iframe {
width: 100%;
height: 100%;
border: none;
display: none; /* مخفی تا بارگذاری شود */
position: relative;
}
/* استایلهای لودینگ */
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
z-index: 10000;
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.loading-message {
margin-bottom: 20px;
font-size: 18px;
color: #333;
}
.progress {
width: 80%;
max-width: 400px;
height: 20px;
background-color: #ddd;
border-radius: 10px;
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;
}
/* دکمههای دانلود و توضیحات */
.download-button, .description-button {
display: block;
width: 140px;
color: white;
text-align: center;
padding: 10px;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
position: fixed;
top: 10px;
z-index: 10001;
text-decoration: none;
}
.download-button {
background-color: #4CAF50;
right: 10px;
}
.description-button {
background-color: rgb(84, 110, 122);
left: 10px;
}
.download-button:hover, .description-button:hover {
background-color: #45a049;
}
/* سبک پنجرههای مودال */
.modal {
display: none;
position: fixed;
z-index: 10002;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
background-color: #fefefe;
margin: 10% auto;
padding: 20px;
border: 1px solid #888;
width: 90%;
max-width: 500px;
text-align: center;
border-radius: 5px;
}
.modal-button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
.close-btn {
background-color: #f44336;
color: white;
}
.translate-btn {
background-color: #4CAF50;
color: white;
}
.translate-btn:hover {
background-color: #45a049;
}
.image-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 20px;
}
.image-item {
margin: 10px;
text-align: center;
}
.image-item img {
width: 100px;
height: 100px;
object-fit: cover;
border-radius: 5px;
margin-bottom: 5px;
}
.image-item button {
background-color: #4CAF50;
color: white;
padding: 5px 10px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
}
.image-item button:hover {
background-color: #45a049;
}
/* دکمه دانلود در پایین صفحه */
.download-button-bottom {
position: fixed;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
padding: 10px;
border-radius: 5px;
color: white;
text-align: center;
font-size: 14px;
text-decoration: none;
z-index: 10001;
cursor: pointer;
}
.download-button-bottom:hover {
background-color: #45a049;
}
</style>
// تابعی برای پیدا کردن نودهای متنی که شامل متن مشخصی هستند
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() {
const siteURL = 'https://fffiloni-pasd.hf.space/--replicas/aieqz/'; // آدرس iframe
const excludeUrls = [
// URL های مورد نظر برای استثنا (در صورت نیاز اضافه کنید)
];
let progress = 0;
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 interval;
let iframeLoadedFlag = false;
// متونی که باید مخفی شوند
const unwantedLinks = [
'https://gradio.app/',
'https://huggingface.co/spaces/fffiloni/PASD?duplicate=true',
'https://github.com/yangxy/PASD',
'https://huggingface.co/papers/2308.14469'
];
// متونی که باید مخفی شوند
const unwantedTexts = [
"Pixel-Aware Stable Diffusion for Realistic Image Super-resolution and Personalized Stylization",
"Made with Gradio",
"ساخته شده با gradio"
];
// متونی که باید جایگزین شوند
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": "خسته شدم🥺 میخوای دوباره بسازم؟ مشکلی نیست آیپی عوض کن"
};
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';
iframe.style.display = 'block';
try {
hideUnwantedElements();
setupElementHiding();
} catch (e) {
console.error('Cannot access iframe content:', e);
}
}
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';
iframe.style.display = 'none';
loadIframe();
startProgress();
});
function loadIframe() {
fetch(siteURL, { method: 'HEAD', mode: 'no-cors' })
.then(() => {
iframe.src = siteURL;
iframe.onload = iframeLoaded;
iframe.onerror = iframeError;
})
.catch(() => {
iframeError();
});
}
function hideUnwantedElements() {
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) return;
// مخفی کردن لینکهای ناخواسته و تصاویر داخل آنها
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';
}
});
// مخفی کردن متون مشخصشده
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), 'gi'), newText);
});
});
} catch (error) {
console.error("Cannot access iframe content: ", error);
}
}
function setupElementHiding() {
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("Cannot access iframe content: ", error);
}
}
function handleDownload(event) {
event.preventDefault();
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
const images = iframeDocument.querySelectorAll('img');
if (images.length === 0) {
alert("هیچ تصویری برای دانلود یافت نشد.");
return;
}
let jpegImages = [];
images.forEach((img) => {
if ((img.src.endsWith('.jpeg') || img.src.endsWith('.jpg')) && !img.src.includes('data:image')) {
jpegImages.push(img.src);
}
});
if (jpegImages.length === 0) {
alert("هیچ تصویر ساخته شدهای برای دانلود یافت نشد.");
return;
}
const imageContainer = document.getElementById('imageContainer');
imageContainer.innerHTML = '';
jpegImages.forEach((imageUrl, index) => {
const imageItem = document.createElement('div');
imageItem.classList.add('image-item');
imageItem.innerHTML = `
<img src="${imageUrl}" alt="Image ${index + 1}">
<button onclick="downloadImage('${imageUrl}')">دانلود</button>
`;
imageContainer.appendChild(imageItem);
});
document.getElementById('downloadModal').style.display = 'block';
} catch (error) {
console.error("خطا در شناسایی تصاویر: ", error);
alert("خطایی در شناسایی تصاویر رخ داد.");
}
}
window.downloadImage = function(imageUrl) {
if (confirm("برای دانلود تصویر روی تایید کلیک کنید و بعد از باز شدن مرورگر روی تصویر محکم نگهدارید و بارگیری تصویر را کلیک کنید.")) {
window.open(imageUrl, '_blank');
}
}
document.getElementById('downloadButton').addEventListener('click', handleDownload);
document.getElementById('downloadButtonBottom').addEventListener('click', handleDownload);
// مدیریت پنجره مودال دانلود
const downloadModal = document.getElementById('downloadModal');
const closeDownloadModalBtn = document.getElementById('closeDownloadModalBtn');
closeDownloadModalBtn.addEventListener('click', function() {
downloadModal.style.display = 'none';
});
// مدیریت پنجره مودال توضیحات
const descriptionModal = document.getElementById('descriptionModal');
const descriptionButton = document.getElementById('descriptionButton');
const closeDescriptionBtn = document.getElementById('closeDescriptionBtn');
const translateBtn = document.getElementById('translateBtn');
descriptionButton.addEventListener('click', function(event) {
event.preventDefault();
descriptionModal.style.display = 'block';
});
closeDescriptionBtn.addEventListener('click', function() {
descriptionModal.style.display = 'none';
});
translateBtn.addEventListener('click', function() {
window.open('https://translate.google.com/?hl=fa&sl=fa&tl=en&op=translate', '_blank');
});
// بستن پنجره مودال با کلیک خارج از آن
window.addEventListener('click', function(event) {
if (event.target == downloadModal) {
downloadModal.style.display = 'none';
}
if (event.target == descriptionModal) {
descriptionModal.style.display = 'none';
}
});
// شروع بارگذاری iframe و نوار پیشرفت
loadIframe();
startProgress();
})();
</script>
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<title>افزایش کیفیت تصاویر با هوش مصنوعی</title>
<style>
/* استایل کلی بدن صفحه */
body {
margin: 0;
padding: 0;
overflow: hidden;
height: 100vh;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
/* کانتینر iframe */
.iframe-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
/* استایلهای iframe */
iframe {
width: 100%;
height: 100%;
border: none;
display: none; /* مخفی تا بارگذاری شود */
position: relative;
}
/* استایلهای لودینگ */
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
z-index: 10000;
background-color: transparent; /* حذف پسزمینه */
padding: 20px;
border-radius: 10px;
/* box-shadow: 0 0 10px rgba(0,0,0,0.1); حذف سایه */
}
.loading-message {
margin-bottom: 20px;
font-size: 18px;
color: #333;
}
/* حذف نوار پیشرفت */
/*
.progress {
width: 80%;
max-width: 400px;
height: 20px;
background-color: #ddd;
border-radius: 10px;
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: 8px 16px; /* کوچکتر کردن دکمه */
font-size: 14px; /* کوچکتر کردن فونت */
cursor: pointer;
background-color: #4caf50;
color: white;
border: none;
border-radius: 5px;
}
/* دکمههای دانلود و توضیحات */
.download-button, .description-button {
display: block;
width: 120px; /* کوچکتر کردن عرض */
color: white;
text-align: center;
padding: 8px; /* کوچکتر کردن پدینگ */
border-radius: 5px;
cursor: pointer;
font-size: 12px; /* کوچکتر کردن فونت */
transition: background-color 0.3s;
position: fixed;
top: 10px;
z-index: 10001;
text-decoration: none;
}
.download-button {
background-color: #4CAF50;
right: 10px;
}
.description-button {
background-color: rgb(84, 110, 122);
left: 10px;
}
.download-button:hover, .description-button:hover {
background-color: #45a049;
}
/* سبک پنجرههای مودال */
.modal {
display: none;
position: fixed;
z-index: 10002;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
background-color: #fefefe;
margin: 10% auto;
padding: 20px;
border: 1px solid #888;
width: 90%;
max-width: 500px;
text-align: center;
border-radius: 5px;
}
.modal-button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
.close-btn {
background-color: #f44336;
color: white;
}
.translate-btn {
background-color: #4CAF50;
color: white;
}
.translate-btn:hover {
background-color: #45a049;
}
.image-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 20px;
}
.image-item {
margin: 10px;
text-align: center;
}
.image-item img {
width: 100px;
height: 100px;
object-fit: cover;
border-radius: 5px;
margin-bottom: 5px;
}
.image-item button {
background-color: #4CAF50;
color: white;
padding: 5px 10px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
}
.image-item button:hover {
background-color: #45a049;
}
/* دکمه دانلود در پایین صفحه */
.download-button-bottom {
position: fixed;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
padding: 8px 16px; /* کوچکتر کردن پدینگ */
border-radius: 5px;
color: white;
text-align: center;
font-size: 12px; /* کوچکتر کردن فونت */
text-decoration: none;
z-index: 10001;
cursor: pointer;
}
.download-button-bottom:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<!-- دکمههای دانلود و توضیحات -->
<p style="position: fixed; top: 10px; width: 100%; display: flex; justify-content: space-between; padding: 0 10px; z-index: 10001;">
<a href="#" class="download-button" id="downloadButton">📥 دانلود</a>
<a href="#" class="description-button" id="descriptionButton">توضیحات</a>
</p>
<!-- پنجره مودال برای نمایش تصاویر دانلود -->
<div id="downloadModal" class="modal">
<div class="modal-content">
<p style="text-align: center;">تصاویر شناساییشده</p>
<div class="image-container" id="imageContainer"></div>
<button class="modal-button close-btn" id="closeDownloadModalBtn">بستن</button>
</div>
</div>
<!-- پنجره مودال برای نمایش توضیحات -->
<div id="descriptionModal" class="modal">
<div class="modal-content">
<p style="text-align: center;">افزایش کیفیت تصاویر</p>
<p style="text-align: center;">با <span style="color: #008080;">هوش مصنوعی</span></p>
<p style="text-align: center;">وضوح تصاویر را با استفاده از پیشرفتهترین مدل بالا ببرید.</p>
<p style="text-align: center;">عکسهای تار و پیکسلی را با این هوش مصنوعی افزایش دهید.</p>
<button class="modal-button translate-btn" id="translateBtn">مترجم</button>
<button class="modal-button close-btn" id="closeDescriptionBtn">بستن</button>
</div>
</div>
<!-- لودینگ و iframe -->
<div class="iframe-container">
<div class="loading" id="loadingContainer">
<div class="loading-message">لطفاً صبر کنید...</div>
<!-- نوار پیشرفت حذف شده -->
<div class="error-message" id="errorMessage">خسته شدم🥺 میخوای دوباره بسازم؟ مشکلی نیست آیپی عوض کن.</div>
<button id="retryButton">بارگذاری مجدد</button>
</div>
<!-- افزودن ویژگیهای sandbox و allow به iframe -->
<iframe id="myIframe" sandbox="allow-scripts allow-same-origin allow-forms allow-modals" allow="clipboard-read; clipboard-write"></iframe>
</div>
<!-- دکمه دانلود تصویر در پایین صفحه -->
<p>
<a href="#" class="download-button-bottom" id="downloadButtonBottom">📥 دانلود</a>
</p>
<script>
// تابعی برای فرار از کاراکترهای ویژه در RegExp
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
// تابعی برای پیدا کردن نودهای متنی که شامل متن مشخصی هستند
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() {
const siteURL = 'https://fffiloni-pasd.hf.space/--replicas/aieqz/'; // آدرس iframe
const excludeUrls = [
// URL های مورد نظر برای استثنا (در صورت نیاز اضافه کنید)
];
let progress = 0;
// 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 interval;
let iframeLoadedFlag = false;
// متونی که باید مخفی شوند
const unwantedLinks = [
'https://gradio.app/',
'https://huggingface.co/spaces/fffiloni/PASD?duplicate=true',
'https://github.com/yangxy/PASD',
'https://huggingface.co/papers/2308.14469'
];
// متونی که باید مخفی شوند
const unwantedTexts = [
"Pixel-Aware Stable Diffusion for Realistic Image Super-resolution and Personalized Stylization",
"Made with Gradio",
"ساخته شده با gradio"
];
// متونی که باید جایگزین شوند
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": "خسته شدم🥺 میخوای دوباره بسازم؟ مشکلی نیست آیپی عوض کن"
};
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';
iframe.style.display = 'block';
try {
hideUnwantedElements();
setupElementHiding();
} catch (e) {
console.error('Cannot access iframe content:', e);
}
}
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';
iframe.style.display = 'none';
loadIframe();
startProgress();
});
function loadIframe() {
fetch(siteURL, { method: 'HEAD', mode: 'no-cors' })
.then(() => {
iframe.src = siteURL;
iframe.onload = iframeLoaded;
iframe.onerror = iframeError;
})
.catch(() => {
iframeError();
});
}
function hideUnwantedElements() {
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) return;
// مخفی کردن لینکهای ناخواسته و تصاویر داخل آنها
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';
}
});
// مخفی کردن متون مشخصشده
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), 'gi'), newText);
});
});
} catch (error) {
console.error("Cannot access iframe content: ", error);
}
}
function setupElementHiding() {
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("Cannot access iframe content: ", error);
}
}
function handleDownload(event) {
event.preventDefault();
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
const images = iframeDocument.querySelectorAll('img');
if (images.length === 0) {
alert("هیچ تصویری برای دانلود یافت نشد.");
return;
}
let jpegImages = [];
images.forEach((img) => {
if ((img.src.endsWith('.jpeg') || img.src.endsWith('.jpg')) && !img.src.includes('data:image')) {
jpegImages.push(img.src);
}
});
if (jpegImages.length === 0) {
alert("هیچ تصویر ساخته شدهای برای دانلود یافت نشد.");
return;
}
const imageContainer = document.getElementById('imageContainer');
imageContainer.innerHTML = '';
jpegImages.forEach((imageUrl, index) => {
const imageItem = document.createElement('div');
imageItem.classList.add('image-item');
imageItem.innerHTML = `
<img src="${imageUrl}" alt="Image ${index + 1}">
<button onclick="downloadImage('${imageUrl}')">دانلود</button>
`;
imageContainer.appendChild(imageItem);
});
document.getElementById('downloadModal').style.display = 'block';
} catch (error) {
console.error("خطا در شناسایی تصاویر: ", error);
alert("خطایی در شناسایی تصاویر رخ داد.");
}
}
window.downloadImage = function(imageUrl) {
if (confirm("برای دانلود تصویر روی تایید کلیک کنید و بعد از باز شدن مرورگر روی تصویر محکم نگهدارید و بارگیری تصویر را کلیک کنید.")) {
window.open(imageUrl, '_blank');
}
}
document.getElementById('downloadButton').addEventListener('click', handleDownload);
document.getElementById('downloadButtonBottom').addEventListener('click', handleDownload);
// مدیریت پنجره مودال دانلود
const downloadModal = document.getElementById('downloadModal');
const closeDownloadModalBtn = document.getElementById('closeDownloadModalBtn');
closeDownloadModalBtn.addEventListener('click', function() {
downloadModal.style.display = 'none';
});
// مدیریت پنجره مودال توضیحات
const descriptionModal = document.getElementById('descriptionModal');
const descriptionButton = document.getElementById('descriptionButton');
const closeDescriptionBtn = document.getElementById('closeDescriptionBtn');
const translateBtn = document.getElementById('translateBtn');
descriptionButton.addEventListener('click', function(event) {
event.preventDefault();
descriptionModal.style.display = 'block';
});
closeDescriptionBtn.addEventListener('click', function() {
descriptionModal.style.display = 'none';
});
translateBtn.addEventListener('click', function() {
window.open('https://translate.google.com/?hl=fa&sl=fa&tl=en&op=translate', '_blank');
});
// بستن پنجره مودال با کلیک خارج از آن
window.addEventListener('click', function(event) {
if (event.target == downloadModal) {
downloadModal.style.display = 'none';
}
if (event.target == descriptionModal) {
descriptionModal.style.display = 'none';
}
});
// شروع بارگذاری iframe و نوار پیشرفت
loadIframe();
startProgress();
})();
</script>
</body>
</html>
Not yet included in a published release.