Spaces:
Running

sandbox / index.html
cghbfg's picture
Add 3 files
46570c0 verified
Raw History Blame Contribute Delete
20.2 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ProxySandbox Browser</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
#browser-frame {
height: calc(100vh - 150px);
}
.tab {
transition: all 0.2s ease;
}
.tab.active {
border-bottom: 3px solid #3b82f6;
}
.tab:hover:not(.active) {
background-color: #f3f4f6;
}
.url-input:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}
.dropdown-content {
display: none;
position: absolute;
right: 0;
background-color: white;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
border-radius: 0.5rem;
}
.dropdown:hover .dropdown-content {
display: block;
}
#loading-bar {
height: 3px;
width: 0%;
background-color: #3b82f6;
transition: width 0.3s ease;
}
.proxy-indicator {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { opacity: 0.6; }
50% { opacity: 1; }
100% { opacity: 0.6; }
}
</style>
</head>
<body class="bg-gray-100">
<div class="flex flex-col h-screen">
<!-- Header -->
<div class="bg-white shadow-md">
<div class="flex items-center justify-between px-4 py-2">
<div class="flex items-center space-x-2">
<div class="text-blue-500 font-bold text-xl flex items-center">
<i class="fas fa-globe mr-2"></i>
ProxySandbox
</div>
<div class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded-full">CLOUDFLARE</div>
</div>
<div class="flex items-center space-x-4">
<div class="relative dropdown">
<button class="flex items-center space-x-1 text-gray-600 hover:text-gray-900">
<span>Settings</span>
<i class="fas fa-chevron-down text-xs"></i>
</button>
<div class="dropdown-content mt-2 py-2">
<a href="#" class="block px-4 py-2 text-gray-700 hover:bg-gray-100" id="new-tab-btn"><i class="fas fa-plus mr-2"></i>New Tab</a>
<a href="#" class="block px-4 py-2 text-gray-700 hover:bg-gray-100"><i class="fas fa-history mr-2"></i>History</a>
<a href="#" class="block px-4 py-2 text-gray-700 hover:bg-gray-100"><i class="fas fa-bookmark mr-2"></i>Bookmarks</a>
<div class="border-t my-1"></div>
<a href="#" class="block px-4 py-2 text-gray-700 hover:bg-gray-100" id="clear-cache-btn"><i class="fas fa-broom mr-2"></i>Clear Cache</a>
<a href="#" class="block px-4 py-2 text-gray-700 hover:bg-gray-100"><i class="fas fa-info-circle mr-2"></i>About</a>
</div>
</div>
</div>
</div>
<div id="loading-bar"></div>
</div>
<!-- Tab Bar -->
<div class="bg-white border-b flex items-center px-2 overflow-x-auto">
<div class="flex space-x-1" id="tab-container">
<div class="tab active flex items-center px-3 py-2 text-sm font-medium cursor-pointer" data-tab-id="1">
<span>New Tab</span>
<button class="ml-2 text-gray-400 hover:text-gray-600 close-tab">
<i class="fas fa-times text-xs"></i>
</button>
</div>
<button class="flex items-center px-3 py-2 text-gray-500 hover:bg-gray-100" id="add-tab-btn">
<i class="fas fa-plus"></i>
</button>
</div>
</div>
<!-- Browser Controls -->
<div class="bg-white px-4 py-3 flex items-center space-x-2 shadow-sm">
<button class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full back-btn">
<i class="fas fa-arrow-left"></i>
</button>
<button class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full forward-btn">
<i class="fas fa-arrow-right"></i>
</button>
<button class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full refresh-btn">
<i class="fas fa-redo"></i>
</button>
<div class="flex-1 flex">
<div class="relative flex-1">
<input type="text" id="url-input" class="url-input w-full py-2 px-4 bg-gray-100 rounded-full pl-10 focus:bg-white focus:border-blue-300 border" placeholder="Search or enter website URL">
<div class="absolute left-3 top-2.5 text-gray-500">
<i class="fas fa-search"></i>
</div>
<div class="absolute right-3 top-2.5 text-blue-500 proxy-indicator" title="Cloudflare Proxy Active">
<i class="fas fa-cloud"></i>
</div>
</div>
<button id="go-button" class="ml-2 px-4 py-2 bg-blue-500 text-white rounded-full hover:bg-blue-600">
Go
</button>
</div>
<button class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full" id="security-btn">
<i class="fas fa-shield-alt"></i>
</button>
<button class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full" id="menu-btn">
<i class="fas fa-ellipsis-h"></i>
</button>
</div>
<!-- Browser Frame -->
<div class="flex-1 overflow-hidden">
<iframe id="browser-frame" class="w-full border-0" src="about:blank"></iframe>
</div>
<!-- Status Bar -->
<div class="bg-gray-800 text-white text-xs px-4 py-1 flex justify-between items-center">
<div id="status-text" class="text-gray-300">Ready</div>
<div class="flex items-center space-x-3">
<span id="security-status" class="text-green-400"><i class="fas fa-lock"></i> Secure</span>
<span id="page-load-time">0.0s</span>
<span id="proxy-status" class="text-blue-300"><i class="fas fa-cloud"></i> Cloudflare Proxy</span>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// DOM Elements
const urlInput = document.getElementById('url-input');
const goButton = document.getElementById('go-button');
const browserFrame = document.getElementById('browser-frame');
const loadingBar = document.getElementById('loading-bar');
const statusText = document.getElementById('status-text');
const securityStatus = document.getElementById('security-status');
const pageLoadTime = document.getElementById('page-load-time');
const tabContainer = document.getElementById('tab-container');
const addTabBtn = document.getElementById('add-tab-btn');
const newTabBtn = document.getElementById('new-tab-btn');
const clearCacheBtn = document.getElementById('clear-cache-btn');
const backBtn = document.querySelector('.back-btn');
const forwardBtn = document.querySelector('.forward-btn');
const refreshBtn = document.querySelector('.refresh-btn');
// Tab management
let tabs = [];
let currentTabId = 1;
class Tab {
constructor(id, title = 'New Tab', url = 'about:blank') {
this.id = id;
this.title = title;
this.url = url;
this.history = [url];
this.historyIndex = 0;
}
goBack() {
if (this.historyIndex > 0) {
this.historyIndex--;
return this.history[this.historyIndex];
}
return null;
}
goForward() {
if (this.historyIndex < this.history.length - 1) {
this.historyIndex++;
return this.history[this.historyIndex];
}
return null;
}
navigate(url) {
// If we're not at the end of history, truncate forward history
if (this.historyIndex < this.history.length - 1) {
this.history = this.history.slice(0, this.historyIndex + 1);
}
this.history.push(url);
this.historyIndex++;
this.url = url;
// Update title from URL if it's a new tab
if (this.title === 'New Tab' && url !== 'about:blank') {
this.title = new URL(url).hostname;
}
}
}
// Create initial tab
tabs.push(new Tab(currentTabId));
function createTabElement(tab) {
const tabEl = document.createElement('div');
tabEl.className = 'tab flex items-center px-3 py-2 text-sm font-medium cursor-pointer';
tabEl.dataset.tabId = tab.id;
const titleSpan = document.createElement('span');
titleSpan.textContent = tab.title;
const closeBtn = document.createElement('button');
closeBtn.className = 'ml-2 text-gray-400 hover:text-gray-600 close-tab';
closeBtn.innerHTML = '<i class="fas fa-times text-xs"></i>';
tabEl.appendChild(titleSpan);
tabEl.appendChild(closeBtn);
return tabEl;
}
function switchTab(tabId) {
const tab = tabs.find(t => t.id === tabId);
if (!tab) return;
currentTabId = tabId;
// Update UI
document.querySelectorAll('.tab').forEach(t => {
t.classList.toggle('active', parseInt(t.dataset.tabId) === tabId);
});
// Update URL input
urlInput.value = tab.url === 'about:blank' ? '' : tab.url;
// Load the URL in iframe
browserFrame.src = tab.url;
}
function addNewTab() {
const newTabId = Math.max(...tabs.map(t => t.id), 0) + 1;
const newTab = new Tab(newTabId);
tabs.push(newTab);
const tabEl = createTabElement(newTab);
tabContainer.insertBefore(tabEl, addTabBtn);
switchTab(newTabId);
}
function closeTab(tabId) {
if (tabs.length <= 1) {
// Don't close the last tab
return;
}
const tabIndex = tabs.findIndex(t => t.id === tabId);
if (tabIndex === -1) return;
tabs.splice(tabIndex, 1);
// Remove tab element
const tabEl = document.querySelector(`.tab[data-tab-id="${tabId}"]`);
if (tabEl) tabEl.remove();
// Switch to another tab
if (currentTabId === tabId) {
switchTab(tabs[0].id);
}
}
// Event listeners for tab management
addTabBtn.addEventListener('click', addNewTab);
newTabBtn.addEventListener('click', addNewTab);
tabContainer.addEventListener('click', function(e) {
const tabEl = e.target.closest('.tab');
const closeBtn = e.target.closest('.close-tab');
if (closeBtn) {
e.stopPropagation();
const tabId = parseInt(tabEl.dataset.tabId);
closeTab(tabId);
} else if (tabEl) {
const tabId = parseInt(tabEl.dataset.tabId);
switchTab(tabId);
}
});
// Navigation functions
function loadUrl(url) {
if (!url) return;
const currentTab = tabs.find(t => t.id === currentTabId);
if (!currentTab) return;
// Add https:// if not present
if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('about:')) {
url = 'https://' + url;
}
// Validate URL
try {
new URL(url);
} catch (e) {
// Try with https://
try {
url = 'https://' + url;
new URL(url);
} catch (e) {
statusText.textContent = 'Invalid URL';
setTimeout(() => statusText.textContent = 'Ready', 2000);
return;
}
}
statusText.textContent = 'Loading...';
loadingBar.style.width = '30%';
const loadStartTime = new Date().getTime();
// Use Cloudflare Worker proxy
const proxyUrl = `/proxy/${encodeURIComponent(url)}`;
// Update tab history
currentTab.navigate(url);
// Update tab title
const tabEl = document.querySelector(`.tab[data-tab-id="${currentTab.id}"]`);
if (tabEl) {
const titleSpan = tabEl.querySelector('span');
if (titleSpan) {
titleSpan.textContent = currentTab.title;
}
}
// Simulate loading progress
const progressInterval = setInterval(() => {
const currentWidth = parseInt(loadingBar.style.width);
if (currentWidth < 90) {
loadingBar.style.width = (currentWidth + 5) + '%';
}
}, 300);
browserFrame.src = proxyUrl;
browserFrame.onload = function() {
clearInterval(progressInterval);
loadingBar.style.width = '100%';
// Calculate load time
const loadEndTime = new Date().getTime();
const loadTime = (loadEndTime - loadStartTime) / 1000;
pageLoadTime.textContent = loadTime.toFixed(1) + 's';
statusText.textContent = 'Done';
// Hide loading bar after a delay
setTimeout(() => {
loadingBar.style.width = '0%';
}, 500);
// Update URL input with the actual URL (without proxy)
urlInput.value = url;
// Update security status (simplified)
if (url.startsWith('https://')) {
securityStatus.innerHTML = '<i class="fas fa-lock"></i> Secure';
securityStatus.className = 'text-green-400';
} else if (url.startsWith('http://')) {
securityStatus.innerHTML = '<i class="fas fa-unlock"></i> Not Secure';
securityStatus.className = 'text-red-400';
} else {
securityStatus.innerHTML = '<i class="fas fa-globe"></i> Local';
securityStatus.className = 'text-gray-400';
}
};
browserFrame.onerror = function() {
clearInterval(progressInterval);
loadingBar.style.width = '0%';
statusText.textContent = 'Failed to load page';
securityStatus.innerHTML = '<i class="fas fa-exclamation-triangle"></i> Error';
securityStatus.className = 'text-red-400';
};
}
// Event listeners
goButton.addEventListener('click', function() {
loadUrl(urlInput.value.trim());
});
urlInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
loadUrl(urlInput.value.trim());
}
});
backBtn.addEventListener('click', function() {
const currentTab = tabs.find(t => t.id === currentTabId);
if (!currentTab) return;
const url = currentTab.goBack();
if (url) {
loadUrl(url);
}
});
forwardBtn.addEventListener('click', function() {
const currentTab = tabs.find(t => t.id === currentTabId);
if (!currentTab) return;
const url = currentTab.goForward();
if (url) {
loadUrl(url);
}
});
refreshBtn.addEventListener('click', function() {
const currentTab = tabs.find(t => t.id === currentTabId);
if (!currentTab || !currentTab.url) return;
loadUrl(currentTab.url);
});
clearCacheBtn.addEventListener('click', function() {
// This is just a UI effect since we can't actually clear the iframe cache
statusText.textContent = 'Cache cleared';
setTimeout(() => statusText.textContent = 'Ready', 2000);
});
// Initial load
urlInput.value = 'google.com';
loadUrl('google.com');
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=cghbfg/sandbox" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>