trying differrent implementation.

This commit is contained in:
dwebmm 2025-01-21 02:45:10 -06:00
parent 66532191ac
commit 4e09927c4c

View file

@ -268,14 +268,9 @@
// Wait for the page to load then focus
frame.onload = () => {
try {
const title = frame.contentWindow.document.title.toLowerCase();
if (
title.includes("blocked") ||
title.includes("error") ||
title.includes("refused") ||
title.includes("cannot") ||
title.includes("denied")
) {
// Check if it's an HTTP URL first
const currentUrl = frame.contentWindow.location.href;
if (currentUrl.startsWith('http:')) {
// Show blocked content modal
const blockedModal = document.getElementById('blockedModal');
const retryBtn = document.getElementById('blockedRetryBtn');
@ -289,30 +284,23 @@
};
openBtn.onclick = () => {
window.open(frame.src, '_blank');
window.open(currentUrl, '_blank');
blockedModal.classList.remove('show');
fumble();
};
return;
}
} catch (e) {
// Show blocked content modal for CORS errors too
const blockedModal = document.getElementById('blockedModal');
const retryBtn = document.getElementById('blockedRetryBtn');
const openBtn = document.getElementById('blockedOpenBtn');
blockedModal.classList.add('show');
retryBtn.onclick = () => {
blockedModal.classList.remove('show');
fumble();
};
openBtn.onclick = () => {
window.open(frame.src, '_blank');
blockedModal.classList.remove('show');
fumble();
};
// Check for error pages
const title = frame.contentWindow.document.title.toLowerCase();
if (
title.includes("blocked") ||
title.includes("error") ||
title.includes("refused") ||
title.includes("cannot") ||
title.includes("denied")
) {
fumble(); // Just try another site for error pages
return;
}
@ -320,12 +308,11 @@
try {
frame.contentWindow.focus();
} catch (e) {
// Ignore cross-origin errors
// Ignore cross-origin errors - these are normal for HTTPS sites
}
};
// Also handle load errors
frame.onerror = () => {
} catch (e) {
// Only show blocked modal if it's an HTTP site
if (frame.src.startsWith('http:')) {
const blockedModal = document.getElementById('blockedModal');
const retryBtn = document.getElementById('blockedRetryBtn');
const openBtn = document.getElementById('blockedOpenBtn');
@ -342,6 +329,15 @@
blockedModal.classList.remove('show');
fumble();
};
return;
}
// Otherwise ignore CORS errors - these are normal for HTTPS sites
}
};
// Handle load errors
frame.onerror = () => {
fumble(); // Just try another site for load errors
};
};