diff --git a/index.html b/index.html index 6d14970..b078342 100644 --- a/index.html +++ b/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,20 +309,51 @@ fumble(); return; } + + frame.focus(); + try { + frame.contentWindow.focus(); + } catch (e) { + // Ignore cross-origin errors + } } 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:')) { - 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 = ` + + `; + 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; } - } - - frame.focus(); - try { - frame.contentWindow.focus(); - } catch (e) { - // Ignore cross-origin errors - } }; // Handle load errors