trying differrent implementation.
This commit is contained in:
parent
66532191ac
commit
4e09927c4c
1 changed files with 40 additions and 44 deletions
84
index.html
84
index.html
|
@ -268,6 +268,30 @@
|
||||||
// Wait for the page to load then focus
|
// Wait for the page to load then focus
|
||||||
frame.onload = () => {
|
frame.onload = () => {
|
||||||
try {
|
try {
|
||||||
|
// 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');
|
||||||
|
const openBtn = document.getElementById('blockedOpenBtn');
|
||||||
|
|
||||||
|
blockedModal.classList.add('show');
|
||||||
|
|
||||||
|
retryBtn.onclick = () => {
|
||||||
|
blockedModal.classList.remove('show');
|
||||||
|
fumble();
|
||||||
|
};
|
||||||
|
|
||||||
|
openBtn.onclick = () => {
|
||||||
|
window.open(currentUrl, '_blank');
|
||||||
|
blockedModal.classList.remove('show');
|
||||||
|
fumble();
|
||||||
|
};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for error pages
|
||||||
const title = frame.contentWindow.document.title.toLowerCase();
|
const title = frame.contentWindow.document.title.toLowerCase();
|
||||||
if (
|
if (
|
||||||
title.includes("blocked") ||
|
title.includes("blocked") ||
|
||||||
|
@ -276,7 +300,19 @@
|
||||||
title.includes("cannot") ||
|
title.includes("cannot") ||
|
||||||
title.includes("denied")
|
title.includes("denied")
|
||||||
) {
|
) {
|
||||||
// Show blocked content modal
|
fumble(); // Just try another site for error pages
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.focus();
|
||||||
|
try {
|
||||||
|
frame.contentWindow.focus();
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore cross-origin errors - these are normal for HTTPS sites
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Only show blocked modal if it's an HTTP site
|
||||||
|
if (frame.src.startsWith('http:')) {
|
||||||
const blockedModal = document.getElementById('blockedModal');
|
const blockedModal = document.getElementById('blockedModal');
|
||||||
const retryBtn = document.getElementById('blockedRetryBtn');
|
const retryBtn = document.getElementById('blockedRetryBtn');
|
||||||
const openBtn = document.getElementById('blockedOpenBtn');
|
const openBtn = document.getElementById('blockedOpenBtn');
|
||||||
|
@ -295,53 +331,13 @@
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
// Otherwise ignore CORS errors - these are normal for HTTPS sites
|
||||||
// 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();
|
|
||||||
};
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame.focus();
|
|
||||||
try {
|
|
||||||
frame.contentWindow.focus();
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore cross-origin errors
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Also handle load errors
|
// Handle load errors
|
||||||
frame.onerror = () => {
|
frame.onerror = () => {
|
||||||
const blockedModal = document.getElementById('blockedModal');
|
fumble(); // Just try another site for load errors
|
||||||
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();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue