<div class=”elementor-container custom-element” id=”my-container” style=”position: relative; padding: 20px; border: 1px solid #ddd;”>
<!– Iframe –>
<iframe id=”ninjaIframe”
allow=”autoplay; camera; microphone; fullscreen; picture-in-picture; display-capture; midi; geolocation;”
src=”https://www.publicmusic.it/ninja/?room=Publicmusic&autogain=1&echocancellation=1&record=1000&transparent&proaudio=4&zoom=0&easyexit&muted&mutespeaker”
width=”100%”
height=”800″
frameborder=”0″>
</iframe>
</div>
<!– Pulsante Chiudi –>
<div style=”text-align: center; margin-top: 20px;”>
<button class=”close-button” style=”background-color: #F5ECEC; color: white; border: none; padding: 10px 20px; font-size: 16px; cursor: pointer; border-radius: 5px;”>
❌
</button>
</div>
<script>
document.addEventListener(“DOMContentLoaded”, function () {
// Chiusura del contenitore con pulsante
document.querySelector(“.close-button”).addEventListener(“click”, function () {
const container = document.getElementById(“my-container”);
if (container) {
container.remove();
}
});
// Simulazione click nell’iframe
const iframeId = “ninjaIframe”;
let retryCount = 0;
const maxRetries = 10;
function checkIframePresence() {
const iframe = document.getElementById(iframeId);
if (iframe && iframe.contentWindow) {
handleIframeLoad(iframe);
return;
}
retryCount++;
if (retryCount < maxRetries) {
setTimeout(checkIframePresence, 1000);
}
}
function handleIframeLoad(iframe) {
try {
const iframeContent = iframe.contentWindow.document;
const containerButton = iframeContent.querySelector(“#container-3 button”);
const gowebcamButton = iframeContent.querySelector(“#gowebcam”);
if (containerButton) {
containerButton.click();
}
if (gowebcamButton && gowebcamButton.offsetParent !== null && !gowebcamButton.disabled) {
gowebcamButton.click();
} else {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === ‘attributes’ && mutation.target === gowebcamButton) {
if (gowebcamButton.offsetParent !== null && !gowebcamButton.disabled) {
gowebcamButton.click();
observer.disconnect();
}
}
});
});
observer.observe(gowebcamButton, { attributes: true });
}
} catch (error) {
// Silenziato
}
}
checkIframePresence();
});
</script>
Lascia un commento