Download script.js from alimoee/flashloan-arbitrage-bot-crypto-ninja: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/spaces/alimoee/flashloan-arbitrage-bot-crypto-ninja/resolve/main/script.js
- Command line
-
hf download hf://spaces/alimoee/flashloan-arbitrage-bot-crypto-ninja/script.js
-
curl -L -o script.js https://huggingface.co/spaces/alimoee/flashloan-arbitrage-bot-crypto-ninja/resolve/main/script.js
1.91 kB
| // Initialize app | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize Feather Icons | |
| feather.replace(); | |
| // Check if Web3 is injected | |
| if (typeof window.ethereum !== 'undefined') { | |
| console.log('MetaMask is installed!'); | |
| } else { | |
| alert('لطفا متامسک را نصب کنید!'); | |
| } | |
| // Connect Wallet Button Handler | |
| const connectWalletBtn = document.getElementById('connectWallet'); | |
| if (connectWalletBtn) { | |
| connectWalletBtn.addEventListener('click', async () => { | |
| try { | |
| const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); | |
| console.log('Connected:', accounts[0]); | |
| connectWalletBtn.textContent = `متصل: ${accounts[0].slice(0,6)}...${accounts[0].slice(-4)}`; | |
| } catch (error) { | |
| console.error('Error connecting wallet:', error); | |
| } | |
| }); | |
| } | |
| // Initialize animations | |
| const animatedElements = document.querySelectorAll('.fade-in, .slide-up'); | |
| animatedElements.forEach(el => { | |
| el.style.opacity = '0'; | |
| }); | |
| setTimeout(() => { | |
| animatedElements.forEach(el => { | |
| el.style.opacity = '1'; | |
| }); | |
| }, 100); | |
| }); | |
| // Theme switcher function | |
| function toggleTheme() { | |
| const html = document.documentElement; | |
| if (html.classList.contains('dark')) { | |
| html.classList.remove('dark'); | |
| localStorage.setItem('theme', 'light'); | |
| } else { | |
| html.classList.add('dark'); | |
| localStorage.setItem('theme', 'dark'); | |
| } | |
| } | |
| // Check for saved theme preference | |
| if (localStorage.getItem('theme') === 'dark' || | |
| (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) { | |
| document.documentElement.classList.add('dark'); | |
| } else { | |
| document.documentElement.classList.remove('dark'); | |
| } |