Compare commits

...

4 commits

Author SHA1 Message Date
dwebmm
05c909787a added http error detection. 2025-01-21 02:39:08 -06:00
dwebmm
7e9107f9f2 Revert "Reverted back to 4cd4110 before changes were made to monitoring. Trying"
This reverts commit 97f3a78f9d.

revert
2025-01-21 02:35:10 -06:00
dwebmm
92628b6dc5 Revert "Reverted back to 4cd4110 before changes were made to monitoring. Trying"
This reverts commit 495bda967f487a8e3ea040b4dc057fe6ca9817ae.

push

push
2025-01-21 02:33:16 -06:00
dwebmm
97f3a78f9d Reverted back to 4cd4110 before changes were made to monitoring. Trying
new implementation for failed pulls.

Added modal for when content is blocked or fails to load
2025-01-21 02:32:02 -06:00
2 changed files with 87 additions and 108 deletions

View file

@ -191,6 +191,17 @@
</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>
<iframe
id="contentFrame"
@ -257,47 +268,6 @@
// 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 (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") ||
@ -317,48 +287,53 @@
// 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);
// 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');
// Handle button clicks
const openBtn = httpModal.querySelector('.http-open-btn');
const skipBtn = httpModal.querySelector('.http-skip-btn');
blockedModal.classList.add('show');
openBtn.addEventListener('click', () => {
console.log("Opening in new tab:", httpUrl); // Debug log
window.open(httpUrl, '_blank');
httpModal.remove();
retryBtn.onclick = () => {
blockedModal.classList.remove('show');
fumble();
});
};
skipBtn.addEventListener('click', () => {
console.log("Skipping site"); // Debug log
httpModal.remove();
openBtn.onclick = () => {
window.open(frame.src, '_blank');
blockedModal.classList.remove('show');
fumble();
});
};
return;
}
// For other errors, just try another site
fumble();
}
};
// Handle load errors
frame.onerror = () => {
fumble(); // Try again if loading fails
// Also update error handler to check for mixed content
frame.onerror = (error) => {
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
}
};
};

View file

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