Compare commits
4 commits
21327c81ea
...
05c909787a
Author | SHA1 | Date | |
---|---|---|---|
|
05c909787a | ||
|
7e9107f9f2 | ||
|
92628b6dc5 | ||
|
97f3a78f9d |
2 changed files with 87 additions and 108 deletions
171
index.html
171
index.html
|
@ -191,6 +191,17 @@
|
||||||
</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"
|
||||||
|
@ -256,109 +267,73 @@
|
||||||
|
|
||||||
// Wait for the page to load then focus
|
// Wait for the page to load then focus
|
||||||
frame.onload = () => {
|
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 (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 = `
|
|
||||||
<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();
|
|
||||||
});
|
|
||||||
|
|
||||||
skipBtn.addEventListener('click', () => {
|
|
||||||
console.log("Skipping site"); // Debug log
|
|
||||||
httpModal.remove();
|
|
||||||
fumble();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame.focus();
|
|
||||||
try {
|
try {
|
||||||
frame.contentWindow.focus();
|
const title = frame.contentWindow.document.title.toLowerCase();
|
||||||
|
if (
|
||||||
|
title.includes("blocked") ||
|
||||||
|
title.includes("error") ||
|
||||||
|
title.includes("refused") ||
|
||||||
|
title.includes("cannot") ||
|
||||||
|
title.includes("denied")
|
||||||
|
) {
|
||||||
|
fumble();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.focus();
|
||||||
|
try {
|
||||||
|
frame.contentWindow.focus();
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore cross-origin errors
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Ignore cross-origin errors
|
// Only show modal for mixed content errors
|
||||||
}
|
if (e.toString().includes("mixed active content")) {
|
||||||
} catch (e) {
|
const blockedModal = document.getElementById('blockedModal');
|
||||||
console.log("Error in onload:", e); // Debug log
|
const retryBtn = document.getElementById('blockedRetryBtn');
|
||||||
// If we can't access the URL due to CORS, try using the src attribute
|
const openBtn = document.getElementById('blockedOpenBtn');
|
||||||
if (frame.src.startsWith('http:')) {
|
|
||||||
console.log("HTTP URL detected from src attribute"); // Debug log
|
blockedModal.classList.add('show');
|
||||||
const httpUrl = frame.src;
|
|
||||||
const httpModal = document.createElement('div');
|
retryBtn.onclick = () => {
|
||||||
httpModal.className = 'modal http-modal show';
|
blockedModal.classList.remove('show');
|
||||||
httpModal.innerHTML = `
|
fumble();
|
||||||
<div class="modal-content">
|
};
|
||||||
<h2>⚠️ HTTP Content</h2>
|
|
||||||
<p>This website uses HTTP and cannot be displayed in the frame for security reasons.</p>
|
openBtn.onclick = () => {
|
||||||
<div class="http-modal-buttons">
|
window.open(frame.src, '_blank');
|
||||||
<button class="http-open-btn">Open in New Tab</button>
|
blockedModal.classList.remove('show');
|
||||||
<button class="http-skip-btn">Skip This Site</button>
|
fumble();
|
||||||
</div>
|
};
|
||||||
</div>
|
return;
|
||||||
`;
|
}
|
||||||
document.body.appendChild(httpModal);
|
// For other errors, just try another site
|
||||||
|
fumble();
|
||||||
// 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
|
// Also update error handler to check for mixed content
|
||||||
frame.onerror = () => {
|
frame.onerror = (error) => {
|
||||||
fumble(); // Try again if loading fails
|
if (error && error.toString().includes("mixed active content")) {
|
||||||
|
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
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
24
styles.css
24
styles.css
|
@ -911,17 +911,17 @@ main:hover .floating-button {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.http-modal .modal-content {
|
.blocked-modal .modal-content {
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.http-modal-buttons {
|
.blocked-modal-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.http-open-btn, .http-skip-btn {
|
.blocked-retry-btn, .blocked-open-btn {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
border: none;
|
border: none;
|
||||||
|
@ -932,29 +932,33 @@ main:hover .floating-button {
|
||||||
transition: background-color 0.3s ease;
|
transition: background-color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.http-open-btn {
|
.blocked-retry-btn {
|
||||||
background-color: #ff4500;
|
background-color: #ff4500;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .http-open-btn {
|
.dark-mode .blocked-retry-btn {
|
||||||
background-color: #ff6b4a;
|
background-color: #ff6b4a;
|
||||||
}
|
}
|
||||||
|
|
||||||
.http-open-btn:hover {
|
.blocked-retry-btn:hover {
|
||||||
background-color: #ff5722;
|
background-color: #ff5722;
|
||||||
}
|
}
|
||||||
|
|
||||||
.http-skip-btn {
|
.blocked-open-btn {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .http-skip-btn {
|
.dark-mode .blocked-open-btn {
|
||||||
background-color: #2a2a2a;
|
background-color: #2a2a2a;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.http-skip-btn:hover {
|
.blocked-open-btn:hover {
|
||||||
background-color: #e0e0e0;
|
background-color: #e0e0e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark-mode .blocked-open-btn:hover {
|
||||||
|
background-color: #333;
|
||||||
|
}
|
Loading…
Reference in a new issue