Compare commits

..

No commits in common. "05c909787a52e8d7a06454d5efaa87ed3df48eaa" and "21327c81eacda088975ed344fff08dcc387270c1" have entirely different histories.

2 changed files with 108 additions and 87 deletions

View file

@ -191,17 +191,6 @@
</div> </div>
</div> </div>
<div id="blockedModal" class="modal blocked-modal">
<div class="modal-content">
<h2>⚠️ Content Blocked</h2>
<p>This content cannot be displayed due to security restrictions.</p>
<div class="blocked-modal-buttons">
<button id="blockedRetryBtn" class="blocked-retry-btn">Try Another Site</button>
<button id="blockedOpenBtn" class="blocked-open-btn">Open in New Tab</button>
</div>
</div>
</div>
<main> <main>
<iframe <iframe
id="contentFrame" id="contentFrame"
@ -267,73 +256,109 @@
// Wait for the page to load then focus // Wait for the page to load then focus
frame.onload = () => { frame.onload = () => {
try { try {
const title = frame.contentWindow.document.title.toLowerCase(); // Get the actual URL from the iframe
if ( const currentUrl = frame.contentWindow.location.href;
title.includes("blocked") || console.log("Current URL:", currentUrl); // Debug log
title.includes("error") ||
title.includes("refused") || // Check if it's an HTTP URL
title.includes("cannot") || if (currentUrl.startsWith('http:')) {
title.includes("denied") console.log("HTTP URL detected, showing modal"); // Debug log
) { 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:", currentUrl); // Debug log
window.open(currentUrl, '_blank');
httpModal.remove();
fumble(); fumble();
return; });
}
frame.focus(); skipBtn.addEventListener('click', () => {
try { console.log("Skipping site"); // Debug log
frame.contentWindow.focus(); httpModal.remove();
} catch (e) { fumble();
// Ignore cross-origin errors });
} return;
} catch (e) { }
// Only show modal for mixed content errors
if (e.toString().includes("mixed active content")) {
const blockedModal = document.getElementById('blockedModal');
const retryBtn = document.getElementById('blockedRetryBtn');
const openBtn = document.getElementById('blockedOpenBtn');
blockedModal.classList.add('show'); // Check for error pages
const title = frame.contentWindow.document.title.toLowerCase();
retryBtn.onclick = () => { if (
blockedModal.classList.remove('show'); title.includes("blocked") ||
fumble(); title.includes("error") ||
}; title.includes("refused") ||
title.includes("cannot") ||
openBtn.onclick = () => { title.includes("denied")
window.open(frame.src, '_blank'); ) {
blockedModal.classList.remove('show');
fumble();
};
return;
}
// For other errors, just try another site
fumble(); fumble();
return;
}
frame.focus();
try {
frame.contentWindow.focus();
} 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;
} }
}; };
// Also update error handler to check for mixed content // Handle load errors
frame.onerror = (error) => { frame.onerror = () => {
if (error && error.toString().includes("mixed active content")) { fumble(); // Try again if loading fails
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();
};
} else {
fumble(); // For other errors, just try another site
}
}; };
}; };

View file

@ -911,17 +911,17 @@ main:hover .floating-button {
text-decoration: underline; text-decoration: underline;
} }
.blocked-modal .modal-content { .http-modal .modal-content {
max-width: 400px; max-width: 400px;
} }
.blocked-modal-buttons { .http-modal-buttons {
display: flex; display: flex;
gap: 10px; gap: 10px;
margin-top: 20px; margin-top: 20px;
} }
.blocked-retry-btn, .blocked-open-btn { .http-open-btn, .http-skip-btn {
flex: 1; flex: 1;
padding: 12px; padding: 12px;
border: none; border: none;
@ -932,33 +932,29 @@ main:hover .floating-button {
transition: background-color 0.3s ease; transition: background-color 0.3s ease;
} }
.blocked-retry-btn { .http-open-btn {
background-color: #ff4500; background-color: #ff4500;
color: white; color: white;
} }
.dark-mode .blocked-retry-btn { .dark-mode .http-open-btn {
background-color: #ff6b4a; background-color: #ff6b4a;
} }
.blocked-retry-btn:hover { .http-open-btn:hover {
background-color: #ff5722; background-color: #ff5722;
} }
.blocked-open-btn { .http-skip-btn {
background-color: #f0f0f0; background-color: #f0f0f0;
color: #333; color: #333;
} }
.dark-mode .blocked-open-btn { .dark-mode .http-skip-btn {
background-color: #2a2a2a; background-color: #2a2a2a;
color: #fff; color: #fff;
} }
.blocked-open-btn:hover { .http-skip-btn:hover {
background-color: #e0e0e0; background-color: #e0e0e0;
} }
.dark-mode .blocked-open-btn:hover {
background-color: #333;
}