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
75
index.html
75
index.html
|
@ -257,8 +257,13 @@
|
||||||
// Wait for the page to load then focus
|
// Wait for the page to load then focus
|
||||||
frame.onload = () => {
|
frame.onload = () => {
|
||||||
try {
|
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
|
// 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');
|
const httpModal = document.createElement('div');
|
||||||
httpModal.className = 'modal http-modal show';
|
httpModal.className = 'modal http-modal show';
|
||||||
httpModal.innerHTML = `
|
httpModal.innerHTML = `
|
||||||
|
@ -274,20 +279,25 @@
|
||||||
document.body.appendChild(httpModal);
|
document.body.appendChild(httpModal);
|
||||||
|
|
||||||
// Handle button clicks
|
// Handle button clicks
|
||||||
httpModal.querySelector('.http-open-btn').addEventListener('click', () => {
|
const openBtn = httpModal.querySelector('.http-open-btn');
|
||||||
window.open(frame.src, '_blank');
|
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();
|
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();
|
httpModal.remove();
|
||||||
fumble(); // Skip to next site
|
fumble();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rest of existing onload code...
|
// 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") ||
|
||||||
|
@ -299,20 +309,51 @@
|
||||||
fumble();
|
fumble();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame.focus();
|
||||||
|
try {
|
||||||
|
frame.contentWindow.focus();
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore cross-origin errors
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Can't access title due to CORS - check if it's HTTP
|
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:')) {
|
if (frame.src.startsWith('http:')) {
|
||||||
fumble(); // Skip HTTP sites that we can't access
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
frame.focus();
|
|
||||||
try {
|
|
||||||
frame.contentWindow.focus();
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore cross-origin errors
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle load errors
|
// Handle load errors
|
||||||
|
|
Loading…
Reference in a new issue