testing http redirect in prod because it doesnt work anyway.
This commit is contained in:
parent
652aac0e0e
commit
21327c81ea
1 changed files with 58 additions and 17 deletions
69
index.html
69
index.html
|
@ -257,8 +257,13 @@
|
|||
// Wait for the page to load then focus
|
||||
frame.onload = () => {
|
||||
try {
|
||||
// Get the actual URL from the iframe
|
||||
const currentUrl = frame.contentWindow.location.href;
|
||||
console.log("Current URL:", currentUrl); // Debug log
|
||||
|
||||
// Check if it's an HTTP URL
|
||||
if (frame.src.startsWith('http:')) {
|
||||
if (currentUrl.startsWith('http:')) {
|
||||
console.log("HTTP URL detected, showing modal"); // Debug log
|
||||
const httpModal = document.createElement('div');
|
||||
httpModal.className = 'modal http-modal show';
|
||||
httpModal.innerHTML = `
|
||||
|
@ -274,20 +279,25 @@
|
|||
document.body.appendChild(httpModal);
|
||||
|
||||
// Handle button clicks
|
||||
httpModal.querySelector('.http-open-btn').addEventListener('click', () => {
|
||||
window.open(frame.src, '_blank');
|
||||
const openBtn = httpModal.querySelector('.http-open-btn');
|
||||
const skipBtn = httpModal.querySelector('.http-skip-btn');
|
||||
|
||||
openBtn.addEventListener('click', () => {
|
||||
console.log("Opening in new tab:", currentUrl); // Debug log
|
||||
window.open(currentUrl, '_blank');
|
||||
httpModal.remove();
|
||||
fumble(); // Load next site
|
||||
fumble();
|
||||
});
|
||||
|
||||
httpModal.querySelector('.http-skip-btn').addEventListener('click', () => {
|
||||
skipBtn.addEventListener('click', () => {
|
||||
console.log("Skipping site"); // Debug log
|
||||
httpModal.remove();
|
||||
fumble(); // Skip to next site
|
||||
fumble();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Rest of existing onload code...
|
||||
// Check for error pages
|
||||
const title = frame.contentWindow.document.title.toLowerCase();
|
||||
if (
|
||||
title.includes("blocked") ||
|
||||
|
@ -299,13 +309,6 @@
|
|||
fumble();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// Can't access title due to CORS - check if it's HTTP
|
||||
if (frame.src.startsWith('http:')) {
|
||||
fumble(); // Skip HTTP sites that we can't access
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
frame.focus();
|
||||
try {
|
||||
|
@ -313,6 +316,44 @@
|
|||
} catch (e) {
|
||||
// Ignore cross-origin errors
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Error in onload:", e); // Debug log
|
||||
// If we can't access the URL due to CORS, try using the src attribute
|
||||
if (frame.src.startsWith('http:')) {
|
||||
console.log("HTTP URL detected from src attribute"); // Debug log
|
||||
const httpUrl = frame.src;
|
||||
const httpModal = document.createElement('div');
|
||||
httpModal.className = 'modal http-modal show';
|
||||
httpModal.innerHTML = `
|
||||
<div class="modal-content">
|
||||
<h2>⚠️ HTTP Content</h2>
|
||||
<p>This website uses HTTP and cannot be displayed in the frame for security reasons.</p>
|
||||
<div class="http-modal-buttons">
|
||||
<button class="http-open-btn">Open in New Tab</button>
|
||||
<button class="http-skip-btn">Skip This Site</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(httpModal);
|
||||
|
||||
// Handle button clicks
|
||||
const openBtn = httpModal.querySelector('.http-open-btn');
|
||||
const skipBtn = httpModal.querySelector('.http-skip-btn');
|
||||
|
||||
openBtn.addEventListener('click', () => {
|
||||
console.log("Opening in new tab:", httpUrl); // Debug log
|
||||
window.open(httpUrl, '_blank');
|
||||
httpModal.remove();
|
||||
fumble();
|
||||
});
|
||||
|
||||
skipBtn.addEventListener('click', () => {
|
||||
console.log("Skipping site"); // Debug log
|
||||
httpModal.remove();
|
||||
fumble();
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// Handle load errors
|
||||
|
|
Loading…
Reference in a new issue