File size: 9,904 Bytes
c69853d 0a7e263 c69853d 0a7e263 c69853d 0a7e263 c69853d 0a7e263 c69853d 0a7e263 c69853d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
document.addEventListener('DOMContentLoaded', function() {
// Initialize session status
let sessionStatus = 'ANONYMOUS';
let lastUpdateTime = null;
let activeCookies = {};
// DOM elements
const cookieInput = document.getElementById('cookieInput');
const injectCookieBtn = document.getElementById('injectCookie');
const sessionStatusElement = document.getElementById('sessionStatus');
const lastUpdateElement = document.getElementById('lastUpdate');
const cookieListElement = document.getElementById('cookieList');
const proxyUrlInput = document.getElementById('proxyUrl');
const aiCoreSelect = document.getElementById('aiCore');
const initBootBtn = document.getElementById('initBoot');
const inputStream = document.getElementById('inputStream');
const executeChainBtn = document.getElementById('executeChain');
const responseStream = document.getElementById('responseStream');
// Update UI with current session status
function updateSessionUI() {
sessionStatusElement.textContent = sessionStatus;
sessionStatusElement.className = 'px-2 py-1 rounded text-xs font-medium ';
switch(sessionStatus) {
case 'ESTABLISHED':
sessionStatusElement.classList.add('bg-green-100', 'dark:bg-green-900', 'text-green-800', 'dark:text-green-200');
break;
case 'ANONYMOUS':
sessionStatusElement.classList.add('bg-yellow-100', 'dark:bg-yellow-900', 'text-yellow-800', 'dark:text-yellow-200');
break;
case 'ERROR':
sessionStatusElement.classList.add('bg-red-100', 'dark:bg-red-900', 'text-red-800', 'dark:text-red-200');
break;
default:
sessionStatusElement.classList.add('bg-gray-100', 'dark:bg-gray-700', 'text-gray-800', 'dark:text-gray-200');
}
lastUpdateElement.textContent = lastUpdateTime ? new Date(lastUpdateTime).toLocaleString() : 'Never';
updateCookieList();
}
// Update the cookie list display
function updateCookieList() {
if (Object.keys(activeCookies).length === 0) {
cookieListElement.innerHTML = '<div class="p-2 bg-gray-100 dark:bg-gray-700 rounded">No cookies detected</div>';
return;
}
cookieListElement.innerHTML = '';
for (const [name, value] of Object.entries(activeCookies)) {
const isSecure = name.startsWith('__Secure-') || name.startsWith('__Host-');
const cookieElement = document.createElement('div');
cookieElement.className = 'p-2 bg-gray-100 dark:bg-gray-700 rounded flex justify-between items-center';
cookieElement.innerHTML = `
<span class="truncate flex-1">${name}</span>
${isSecure ? '<i data-feather="lock" class="text-blue-500 ml-2 w-4 h-4"></i>' : ''}
`;
cookieListElement.appendChild(cookieElement);
}
feather.replace();
}
// Parse cookie header string
function parseCookieHeader(header) {
const cookies = {};
header.split(';').forEach(pair => {
const [name, value] = pair.trim().split('=');
if (name && value) {
cookies[name] = value;
}
});
return cookies;
}
// Simulate cookie injection
function injectCookies() {
const header = cookieInput.value.trim();
if (!header) {
showResponse('Error: No cookie header provided', 'error');
return;
}
try {
activeCookies = parseCookieHeader(header);
sessionStatus = activeCookies['__Secure-1PSID'] ? 'ESTABLISHED' : 'ANONYMOUS';
lastUpdateTime = new Date();
// Simulate handshake
setTimeout(() => {
showResponse('Cookie injection successful. Session established.', 'success');
updateSessionUI();
// Start session monitoring
startSessionMonitor();
}, 1000);
} catch (error) {
showResponse(`Error parsing cookies: ${error.message}`, 'error');
sessionStatus = 'ERROR';
updateSessionUI();
}
}
// Start monitoring session changes
function startSessionMonitor() {
// In a real implementation, this would monitor document.cookie or API responses
setInterval(() => {
// Simulate occasional session updates
if (Math.random() > 0.8) {
lastUpdateTime = new Date();
updateSessionUI();
}
}, 5000);
}
// Show response in the terminal
function showResponse(message, type = 'info') {
const responseElement = document.createElement('div');
responseElement.className = `terminal-output ${type}`;
responseElement.innerHTML = `[${new Date().toLocaleTimeString()}] <span class="${type}">${message}</span>`;
responseStream.appendChild(responseElement);
responseStream.scrollTop = responseStream.scrollHeight;
}
// Execute inference chain
function executeChain() {
const input = inputStream.value.trim();
if (!input) {
return;
}
// Add user message to chat
const chatContainer = document.getElementById('chatContainer');
const userMessage = document.createElement('div');
userMessage.className = 'chat-message user-message mb-3 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 shadow-sm max-w-3/4 ml-auto';
userMessage.innerHTML = `
<div class="flex items-start justify-end">
<div>
<p class="font-medium text-blue-600 dark:text-blue-400 mb-1 text-right">You</p>
<p class="text-gray-700 dark:text-gray-300">${input}</p>
</div>
<div class="flex-shrink-0 bg-blue-100 dark:bg-blue-800 rounded-full p-2 ml-3">
<i data-feather="user" class="text-blue-500 dark:text-blue-400 w-4 h-4"></i>
</div>
</div>
`;
chatContainer.appendChild(userMessage);
chatContainer.scrollTop = chatContainer.scrollHeight;
// Clear input
inputStream.value = '';
// Show typing indicator
const typingIndicator = document.createElement('div');
typingIndicator.className = 'chat-message ai-message mb-3 p-3 rounded-lg bg-white dark:bg-gray-800 shadow-sm max-w-3/4';
typingIndicator.innerHTML = `
<div class="flex items-start">
<div class="flex-shrink-0 bg-blue-100 dark:bg-blue-900 rounded-full p-2 mr-3">
<i data-feather="cpu" class="text-blue-500 dark:text-blue-400 w-4 h-4"></i>
</div>
<div>
<p class="font-medium text-blue-600 dark:text-blue-400 mb-1">AI Assistant</p>
<p class="text-gray-700 dark:text-gray-300 typing">Typing...</p>
</div>
</div>
`;
chatContainer.appendChild(typingIndicator);
chatContainer.scrollTop = chatContainer.scrollHeight;
// Simulate AI processing
setTimeout(() => {
// Remove typing indicator
chatContainer.removeChild(typingIndicator);
// Add AI response
const aiResponse = document.createElement('div');
aiResponse.className = 'chat-message ai-message mb-3 p-3 rounded-lg bg-white dark:bg-gray-800 shadow-sm max-w-3/4';
aiResponse.innerHTML = `
<div class="flex items-start">
<div class="flex-shrink-0 bg-blue-100 dark:bg-blue-900 rounded-full p-2 mr-3">
<i data-feather="cpu" class="text-blue-500 dark:text-blue-400 w-4 h-4"></i>
</div>
<div>
<p class="font-medium text-blue-600 dark:text-blue-400 mb-1">AI Assistant</p>
<p class="text-gray-700 dark:text-gray-300">I've processed your request successfully. This confirms the system is communicating with the AI backend. How else can I assist you?</p>
</div>
</div>
`;
chatContainer.appendChild(aiResponse);
chatContainer.scrollTop = chatContainer.scrollHeight;
feather.replace();
}, 1500);
}
// Initialize boot sequence
function initiateBoot() {
const proxyUrl = proxyUrlInput.value.trim();
const aiCore = aiCoreSelect.value;
showResponse(`Initiating boot sequence with ${aiCore} core...`, 'info');
setTimeout(() => {
if (aiCore === 'gemini') {
showResponse("Connecting to Gemini cloud services...", 'info');
setTimeout(() => {
if (proxyUrl) {
showResponse(`Proxy configured: ${proxyUrl}`, 'success');
}
showResponse("Gemini connection established. Ready for inference.", 'success');
}, 1500);
} else {
showResponse("Loading local transformers model...", 'info');
setTimeout(() => {
showResponse("Local model loaded successfully. Ready for inference.", 'success');
}, 2500);
}
}, 1000);
}
// Event listeners
injectCookieBtn.addEventListener('click', injectCookies);
executeChainBtn.addEventListener('click', executeChain);
initBootBtn.addEventListener('click', initiateBoot);
// Initialize UI
updateSessionUI();
feather.replace();
}); |