<p> </p> <style> body { margin: 0; padding: 0; overflow: hidden; height: 100vh;…
- Usercode
- Assistant
.iframe-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: none;
display: none;
position: relative;
top: 0;
}
.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;
}
.download-button, .description-button {
display: block;
width: 120px;
color: white;
text-align: center;
padding: 6px;
border-radius: 5px;
cursor: pointer;
font-size: 11px;
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: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
text-align: center;
border-radius: 5px;
}
.modal-button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
.cancel-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;
}
.image-item {
margin: 10px;
text-align: center;
}
.image-item img {
width: 80px;
height: 80px;
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: 15px 50px;
border-radius: 5px;
color: white;
text-align: center;
font-size: 14px;
text-decoration: none;
z-index: 10001;
cursor: pointer;
min-width: 250px;
width: auto;
white-space: nowrap;
}
.download-button-bottom:hover {
background-color: #45a049;
}
</style>
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 hideUnwantedImage() {
const iframe = document.getElementById('myIframe');
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
// Hide the specific image
const images = iframeDocument.querySelectorAll('img');
images.forEach(img => {
if (img.src === 'https://prodiazenafey-faceswap.hf.space/file=/tmp/gradio/44ce6237aa956835c13beb89ae4c83f8afea7edb/example3.jpg') {
img.style.display = 'none';
}
});
}
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';
hideUnwantedImage();
}
function iframeError() {
clearInterval(interval);
loadingContainer.style.display = 'flex';
retryButton.style.display = 'block';
errorMessage.style.display = 'block';
}
function loadIframe() {
fetch(siteURL, { method: 'HEAD', mode: 'no-cors' })
.then(() => {
const iframe = document.getElementById('myIframe');
iframe.src = siteURL;
iframe.onload = iframeLoaded;
iframe.onerror = iframeError;
})
.catch(() => {
iframeError();
});
}
function handleDownload(event) {
event.preventDefault();
const iframe = document.getElementById('myIframe');
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
try {
const images = iframeDocument.querySelectorAll('img');
if (images.length === 0) {
alert("هیچ تصویری با فرمت PNG برای دانلود یافت نشد.");
return;
}
let pngImages = [];
images.forEach((img) => {
if (img.src.endsWith('.png') && !excludeUrls.includes(img.src)) {
pngImages.push(img.src);
}
});
pngImages = pngImages.slice(0, 4);
if (pngImages.length === 0) {
alert("هیچ تصویر ساخته شدهای یافت نشد.");
return;
}
const imageContainer = document.getElementById('imageContainer');
imageContainer.innerHTML = '';
pngImages.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('myModal').style.display = 'block';
} catch (error) {
console.error("خطا در شناسایی تصاویر: ", error);
alert("خطایی در شناسایی تصاویر رخ داد.");
}
}
function downloadImage(imageUrl) {
const confirmModal = document.createElement('div');
confirmModal.style.cssText = `
position: fixed;
z-index: 10003;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
`;
const modalContent = document.createElement('div');
modalContent.style.cssText = `
background-color: #fefefe;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
text-align: center;
border-radius: 5px;
`;
modalContent.innerHTML = `
<p style="margin-bottom: 20px;">برای دانلود تصویر روی تایید کلیک کنید و بعد از باز شدن مرورگر روی تصویر محکم نگه دارید و بارگیری تصویر را کلیک کنید.</p>
<button id="confirmDownload" style="
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-right: 10px;
">تایید</button>
<button id="cancelDownload" style="
background-color: #f44336;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
">لغو</button>
`;
confirmModal.appendChild(modalContent);
document.body.appendChild(confirmModal);
document.getElementById('confirmDownload').addEventListener('click', function() {
window.open(imageUrl, '_blank');
document.body.removeChild(confirmModal);
});
document.getElementById('cancelDownload').addEventListener('click', function() {
document.body.removeChild(confirmModal);
});
confirmModal.addEventListener('click', function(event) {
if (event.target === confirmModal) {
document.body.removeChild(confirmModal);
}
});
}
// Event Listeners
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();
});
document.getElementById('downloadButton').addEventListener('click', handleDownload);
document.getElementById('downloadButtonBottom').addEventListener('click', handleDownload);
const modal = document.getElementById('myModal');
const closeBtn = document.getElementById('closeBtn');
closeBtn.addEventListener('click', function() {
modal.style.display = 'none';
});
window.addEventListener('click', function(event) {
if (event.target == modal) {
modal.style.display = 'none';
}
if (event.target == descriptionModal) {
descriptionModal.style.display = 'none';
}
});
const descriptionModal = document.getElementById('myDescriptionModal');
const descriptionButton = document.getElementById('descriptionButton');
const closeDescriptionBtn = document.getElementById('closeDescriptionBtn');
descriptionButton.addEventListener('click', function(event) {
event.preventDefault();
descriptionModal.style.display = 'block';
});
closeDescriptionBtn.addEventListener('click', function() {
descriptionModal.style.display = 'none';
});
// Add a mutation observer to continuously check for and hide the unwanted image
function setupImageHiding() {
const iframe = document.getElementById('myIframe');
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
hideUnwantedImage();
}
});
});
observer.observe(iframeDocument.body, {
childList: true,
subtree: true
});
}
// Initialize
loadIframe();
startProgress();
// Add event listener for iframe load to setup image hiding
document.getElementById('myIframe').addEventListener('load', function() {
setTimeout(setupImageHiding, 1000); // Delay to ensure iframe content is loaded
});
</script>
به منظور اطمینان از این که تصویر مورد نظر به محض بارگذاری سایت در iframe به سرعت و به طور خودکار مخفی شود، میتوان تغییرات زیر را در کد شما اعمال کرد:
حذف تأخیر زمانی (setTimeout): به جای استفاده از setTimeout با تأخیر یک ثانیه، تابع setupImageHiding را بلافاصله پس از بارگذاری iframe فراخوانی کنید.
فراخوانی فوری hideUnwantedImage: در داخل setupImageHiding، تابع hideUnwantedImage را بلافاصله پس از تنظیم ناظر Mutation فراخوانی کنید تا اطمینان حاصل شود که تصویر غیر مطلوب بلافاصله پس از افزودن به DOM مخفی شود.
در زیر نسخه کامل و اصلاح شده کد شما ارائه شده است:
<!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-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: none;
display: none;
position: relative;
top: 0;
}
.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;
}
.download-button, .description-button {
display: block;
width: 120px;
color: white;
text-align: center;
padding: 6px;
border-radius: 5px;
cursor: pointer;
font-size: 11px;
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: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
text-align: center;
border-radius: 5px;
}
.modal-button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
.cancel-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;
}
.image-item {
margin: 10px;
text-align: center;
}
.image-item img {
width: 80px;
height: 80px;
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: 15px 50px;
border-radius: 5px;
color: white;
text-align: center;
font-size: 14px;
text-decoration: none;
z-index: 10001;
cursor: pointer;
min-width: 250px;
width: auto;
white-space: nowrap;
}
.download-button-bottom:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<p>
<a href="#" class="download-button" id="downloadButton">دانلود تصویر 📥</a>
<a href="#" class="description-button" id="descriptionButton">توضیحات</a>
</p>
<div id="myModal" class="modal">
<div class="modal-content">
<p style="text-align: center;">تصاویر شناساییشده</p>
<div class="image-container" id="imageContainer"></div>
<button class="modal-button cancel-btn" id="closeBtn">بستن</button>
</div>
</div>
<div id="myDescriptionModal" class="modal">
<div class="modal-content">
<p style="text-align: center;">رنگی کردن تصاویر با <span style="color: #339966;">هوش مصنوعی</span></p>
<p style="text-align: center;">عکس های قدیمی و سیاه سفید رو آپلود کنید و شگفت زده شوید.</p>
<p style="text-align: center;">این هوش مصنوعی از جدید ترین تکنولوژی استفاده میکنه و خروجی های این ابزار از کیفیت خیلی بالایی برخوردار است.</p>
<button class="modal-button cancel-btn" id="closeDescriptionBtn">بستن</button>
</div>
</div>
<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">بارگیری زیاد طول کشید.<br />در صورت عدم بارگذاری، فیلترشکن خود را روشن کنید.</div>
<button id="retryButton">بارگذاری مجدد</button>
</div>
<iframe id="myIframe"></iframe>
</div>
<p>
<a href="#" class="download-button-bottom" id="downloadButtonBottom">دانلود تصویر 📥</a>
</p>
<script>
const siteURL = 'https://prodiazenafey-faceswap.hf.space/';
const excludeUrls = [
'https://yanze-pulid.hf.space/--replicas/3t64n/file=/tmp/gradio/7567beceda2541f726af7beb4c9aa857b4a96b77/liuyifei.png',
'https://yanze-pulid.hf.space/--replicas/3t64n/file=/tmp/gradio/7567beceda2541f726af7beb4c9aa857b4a96b77/liuyifei.png',
'https://prodiazenafey-faceswap.hf.space/file=/tmp/gradio/44ce6237aa956835c13beb89ae4c83f8afea7edb/example3.jpg'
];
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 hideUnwantedImage() {
const iframe = document.getElementById('myIframe');
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) return;
// Hide the specific image
const images = iframeDocument.querySelectorAll('img');
images.forEach(img => {
if (img.src === 'https://prodiazenafey-faceswap.hf.space/file=/tmp/gradio/44ce6237aa956835c13beb89ae4c83f8afea7edb/example3.jpg') {
img.style.display = 'none';
}
});
} catch (error) {
console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", 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';
document.getElementById('myIframe').style.display = 'block';
hideUnwantedImage();
}
function iframeError() {
clearInterval(interval);
loadingContainer.style.display = 'flex';
retryButton.style.display = 'block';
errorMessage.style.display = 'block';
}
function loadIframe() {
fetch(siteURL, { method: 'HEAD', mode: 'no-cors' })
.then(() => {
const iframe = document.getElementById('myIframe');
iframe.src = siteURL;
iframe.onload = iframeLoaded;
iframe.onerror = iframeError;
})
.catch(() => {
iframeError();
});
}
function handleDownload(event) {
event.preventDefault();
const iframe = document.getElementById('myIframe');
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) {
alert("نمیتوان به محتوای iframe دسترسی پیدا کرد.");
return;
}
const images = iframeDocument.querySelectorAll('img');
if (images.length === 0) {
alert("هیچ تصویری با فرمت PNG برای دانلود یافت نشد.");
return;
}
let pngImages = [];
images.forEach((img) => {
if (img.src.endsWith('.png') && !excludeUrls.includes(img.src)) {
pngImages.push(img.src);
}
});
pngImages = pngImages.slice(0, 4);
if (pngImages.length === 0) {
alert("هیچ تصویر ساخته شدهای یافت نشد.");
return;
}
const imageContainer = document.getElementById('imageContainer');
imageContainer.innerHTML = '';
pngImages.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('myModal').style.display = 'block';
} catch (error) {
console.error("خطا در شناسایی تصاویر: ", error);
alert("خطایی در شناسایی تصاویر رخ داد.");
}
}
function downloadImage(imageUrl) {
const confirmModal = document.createElement('div');
confirmModal.style.cssText = `
position: fixed;
z-index: 10003;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
`;
const modalContent = document.createElement('div');
modalContent.style.cssText = `
background-color: #fefefe;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
text-align: center;
border-radius: 5px;
`;
modalContent.innerHTML = `
<p style="margin-bottom: 20px;">برای دانلود تصویر روی تایید کلیک کنید و بعد از باز شدن مرورگر روی تصویر محکم نگه دارید و بارگیری تصویر را کلیک کنید.</p>
<button id="confirmDownload" style="
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-right: 10px;
">تایید</button>
<button id="cancelDownload" style="
background-color: #f44336;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
">لغو</button>
`;
confirmModal.appendChild(modalContent);
document.body.appendChild(confirmModal);
document.getElementById('confirmDownload').addEventListener('click', function() {
window.open(imageUrl, '_blank');
document.body.removeChild(confirmModal);
});
document.getElementById('cancelDownload').addEventListener('click', function() {
document.body.removeChild(confirmModal);
});
confirmModal.addEventListener('click', function(event) {
if (event.target === confirmModal) {
document.body.removeChild(confirmModal);
}
});
}
// Event Listeners
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();
});
document.getElementById('downloadButton').addEventListener('click', handleDownload);
document.getElementById('downloadButtonBottom').addEventListener('click', handleDownload);
const modal = document.getElementById('myModal');
const closeBtn = document.getElementById('closeBtn');
closeBtn.addEventListener('click', function() {
modal.style.display = 'none';
});
window.addEventListener('click', function(event) {
if (event.target == modal) {
modal.style.display = 'none';
}
if (event.target == descriptionModal) {
descriptionModal.style.display = 'none';
}
});
const descriptionModal = document.getElementById('myDescriptionModal');
const descriptionButton = document.getElementById('descriptionButton');
const closeDescriptionBtn = document.getElementById('closeDescriptionBtn');
descriptionButton.addEventListener('click', function(event) {
event.preventDefault();
descriptionModal.style.display = 'block';
});
closeDescriptionBtn.addEventListener('click', function() {
descriptionModal.style.display = 'none';
});
// ناظر Mutation برای مخفی کردن تصویر غیر مطلوب
function setupImageHiding() {
const iframe = document.getElementById('myIframe');
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) return;
hideUnwantedImage(); // مخفی کردن فوری تصویر غیر مطلوب
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
hideUnwantedImage();
}
});
});
observer.observe(iframeDocument.body, {
childList: true,
subtree: true
});
} catch (error) {
console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error);
}
}
// Initialize
loadIframe();
startProgress();
// افزودن ناظر Mutation بلافاصله پس از بارگذاری iframe
document.getElementById('myIframe').addEventListener('load', function() {
setupImageHiding(); // حذف setTimeout و فراخوانی مستقیم
});
</script>
</body>
</html>
حذف setTimeout در فراخوانی setupImageHiding:
document.getElementById('myIframe').addEventListener('load', function() {
setupImageHiding(); // حذف setTimeout و فراخوانی مستقیم
});
فراخوانی فوری hideUnwantedImage در setupImageHiding:
function setupImageHiding() {
const iframe = document.getElementById('myIframe');
try {
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDocument) return;
hideUnwantedImage(); // مخفی کردن فوری تصویر غیر مطلوب
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
hideUnwantedImage();
}
});
});
observer.observe(iframeDocument.body, {
childList: true,
subtree: true
});
} catch (error) {
console.error("نمیتوان به محتوای iframe دسترسی پیدا کرد: ", error);
}
}
اضافه کردن بررسی دسترسی به محتوای iframe و مدیریت خطاها:
به دلیل احتمال وجود محدودیتهای مربوط به سیاستهای امنیتی مرورگر (CORS)، بهتر است در داخل توابع hideUnwantedImage و setupImageHiding از try-catch استفاده شود تا در صورت بروز خطا، پیام مناسبی در کنسول نمایش داده شود.
اطمینان از بارگذاری کامل iframe قبل از اجرای ناظر Mutation:
با حذف تأخیر زمانی و اجرای مستقیم setupImageHiding پس از بارگذاری iframe، اطمینان حاصل میشود که ناظر Mutation بلافاصله پس از بارگذاری iframe فعال شود و هرگونه تغییر در DOM به سرعت شناسایی و مدیریت شود.
این تغییرات به شما کمک میکند تا تصویر مورد نظر به محض بارگذاری سایت در iframe به سرعت و به طور خودکار مخفی شود بدون نیاز به تعامل کاربر.
Not yet included in a published release.