Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const urlInput = document.getElementById('urlInput');
+ const passwordInput = document.getElementById('passwordInput');
+ const accessButton = document.getElementById('accessButton');
+ const errorMessage = document.getElementById('errorMessage');
+ const proxyContent = document.getElementById('proxyContent');
+
+ const CORRECT_PASSWORD = 'xiaoiec123456';
+
+ accessButton.addEventListener('click', async () => {
+ const url = urlInput.value.trim();
+ const password = passwordInput.value;
+
+ // Clear previous error
+ errorMessage.textContent = '';
+
+ // Validate inputs
+ if (!url) {
+ errorMessage.textContent = 'Please enter a URL';
+ return;
+ }
+
+ if (!password) {
+ errorMessage.textContent = 'Please enter the password';
+ return;
+ }
+
+ if (password !== CORRECT_PASSWORD) {
+ errorMessage.textContent = 'Incorrect password';
+ return;
+ }
+
+ try {
+ // Here you would implement the actual proxy functionality
+ // This is a placeholder that would need to be replaced with server-side logic
+ const response = await fetch(`/proxy?url=${encodeURIComponent(url)}`, {
+ method: 'GET',
+ headers: {
+ 'Authorization': `Bearer ${password}`
+ }
+ });
+
+ if (!response.ok) {
+ throw new Error('Failed to access the requested website');
+ }
+
+ const content = await response.text();
+ proxyContent.innerHTML = content;
+
+ } catch (error) {
+ errorMessage.textContent = error.message;
+ }
+ });
+
+ // Add input validation and formatting
+ urlInput.addEventListener('input', () => {
+ if (!urlInput.value.startsWith('http')) {
+ urlInput.value = 'https://' + urlInput.value;
+ }
+ });
+ });