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>
برای انجام تغییرات مورد نظر شما — حذف پسزمینه نوار پیشرفت و پیام "لطفاً صبر کنید" و کوچکتر کردن دکمههای دانلود تصویر و توضیحات — میتوانید CSS را به شرح زیر ویرایش کنید:
حذف پسزمینه نوار پیشرفت و پیام لودینگ:
background-color از .loading تا پسزمینه شفاف شود.box-shadow برای حذف سایه.کوچکتر کردن دکمههای دانلود تصویر و توضیحات:
/* استایل کلی بدن صفحه */
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: none;
}
.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: 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: 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;
}
حذف پسزمینه و سایه لودینگ:
.loading، background-color: rgba(255, 255, 255, 0.8); را به background-color: transparent; تغییر دادیم تا پسزمینه شفاف شود.box-shadow: 0 0 10px rgba(0,0,0,0.1); را حذف کردهایم تا سایه نداشته باشد.کوچکتر کردن دکمهها:
.download-button و .description-button:
width از 140px به 120px کاهش یافته است.padding از 10px به 8px کاهش یافته است.font-size از 14px به 12px کاهش یافته است.این تغییرات باعث میشود که پسزمینه نوار پیشرفت و پیام لودینگ حذف شده و دکمههای دانلود تصویر و توضیحات اندازهی کوچکتری داشته باشند. اگر نیاز به تنظیمات بیشتری دارید یا تغییرات دیگری میخواهید اعمال کنید، لطفاً اطلاع دهید.
Not yet included in a published release.