RE: Update Bot auto curation
You are viewing a single comment's thread:
part 4
...
// ========== AUTO-VOTE INDICATOR ==========
function showAutoVoteIndicator(totalPosts) {
let indicator = document.getElementById('auto-vote-indicator');
if (!indicator) {
indicator = document.createElement('div');
indicator.id = 'auto-vote-indicator';
indicator.style.cssText = position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(18, 18, 48, 0.98); border: 2px solid var(--neon-blue); border-radius: 15px; padding: 30px 40px; z-index: 10000; text-align: center; box-shadow: 0 8px 32px rgba(0, 212, 255, 0.5); animation: pulse-glow 2s infinite;;
document.body.appendChild(indicator);
}
indicator.innerHTML = `
<div style="font-size: 3rem; margin-bottom: 15px;">🤖</div>
<div style="font-family: 'Orbitron', sans-serif; font-size: 1.5rem; color: var(--neon-blue); margin-bottom: 10px;">AUTO-VOTE ACTIVE</div>
<div id="auto-vote-progress" style="font-size: 1.2rem; color: var(--neon-green);">0 / ${totalPosts}</div>
`;
indicator.style.display = 'block';
}
function updateAutoVoteIndicator(current, total) {
const progress = document.getElementById('auto-vote-progress');
if (progress) {
progress.textContent = `${current} / ${total}`;
}
}
function hideAutoVoteIndicator() {
const indicator = document.getElementById('auto-vote-indicator');
if (indicator) {
indicator.style.animation = 'fadeOut 0.5s forwards';
setTimeout(() => {
indicator.remove();
}, 500);
}
}
// ========== AUTO-REFRESH FUNCTIONS ==========
function clearAutoRefresh() {
if (autoRefreshTimer) {
clearInterval(autoRefreshTimer);
autoRefreshTimer = null;
const timerDisplay = document.getElementById('refresh-timer');
if (timerDisplay) {
timerDisplay.remove();
}
}
}
function scheduleAutoRefresh(delay = AUTO_REFRESH_DELAY) {
clearAutoRefresh();
let remainingTime = delay / 1000;
let timerDisplay = document.getElementById('refresh-timer');
if (!timerDisplay) {
timerDisplay = document.createElement('div');
timerDisplay.id = 'refresh-timer';
timerDisplay.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background: rgba(18, 18, 48, 0.95);
border: 1px solid rgba(0, 212, 255, 0.4);
border-radius: 8px;
padding: 12px 20px;
color: var(--neon-blue);
font-family: 'Orbitron', sans-serif;
font-size: 0.9rem;
z-index: 9999;
box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
animation: pulse-glow 2s infinite;
`;
document.body.appendChild(timerDisplay);
}
timerDisplay.textContent = `🔄 Refresh in ${remainingTime}s`;
autoRefreshTimer = setInterval(() => {
remainingTime--;
timerDisplay.textContent = `🔄 Refresh in ${remainingTime}s`;
if (remainingTime <= 0) {
clearAutoRefresh();
location.reload();
}
}, 1000);
}
// ========== EXPORT CSV ==========
function exportVotedAccountsCSV() {
if (voteSession.history.length === 0) {
alert('⚠️ No votes to export!');
return;
}
const uniqueAccounts = [...new Set(
voteSession.history.map(vote => vote.author.replace('@', ''))
)];
let csvContent = "username,post_url\n"; // header CSV
voteSession.history.forEach(vote => {
const username = vote.author.replace('@', '');
const postUrl = https://peakd.com/@${vote.author}/${vote.permlink};
csvContent += `${username},${postUrl}\n`;
});
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
const now = new Date();
const timestamp = now.toISOString().slice(0, 19).replace(/:/g, '-');
const filename = glyph_voters_${timestamp}.csv;
link.setAttribute('href', url);
link.setAttribute('download', filename);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
console.log(✅ Exported ${voteSession.history.length} votes with links);
}
// ========== AUTO-START ON PAGE LOAD ==========
window.addEventListener('DOMContentLoaded', () => {
loadVoteSession();
const savedAccount = localStorage.getItem(ACCOUNT_STORAGE_KEY);
if (savedAccount) {
document.getElementById('current-account-display').textContent = `@${savedAccount}`;
}
const eligibleCount = <?php echo count($eligible_posts); ?>;
// Auto-vote si activé ET posts disponibles
if (AUTO_VOTE_ENABLED && eligibleCount > 0) {
console.log(`🤖 AUTO-VOTE enabled: ${eligibleCount} posts detected`);
setTimeout(() => {
startAutoVote();
}, 2000); // Délai de 2s pour laisser charger la page
} else if (eligibleCount === 0) {
console.log("⚠️ No eligible posts - scheduling auto-refresh");
scheduleAutoRefresh();
}
// Ajoute le bouton d'export CSV
const historySection = document.getElementById('vote-history');
if (historySection) {
const clearButton = historySection.querySelector('button[onclick="clearVoteHistory()"]');
if (clearButton) {
const exportButton = document.createElement('button');
exportButton.textContent = '📊 Export CSV';
exportButton.onclick = exportVotedAccountsCSV;
exportButton.style.cssText = `
background: linear-gradient(45deg, #00d4ff, #b200ff);
color: white;
border: none;
padding: 10px 20px;
border-radius: 8px;
cursor: pointer;
font-weight: bold;
margin-right: 10px;
transition: all 0.3s;
font-family: 'Orbitron', sans-serif;
`;
exportButton.onmouseover = () => exportButton.style.transform = 'scale(1.05)';
exportButton.onmouseout = () => exportButton.style.transform = 'scale(1)';
clearButton.parentElement.insertBefore(exportButton, clearButton);
}
}
});
window.addEventListener('beforeunload', () => {
clearAutoRefresh();
});
// Ajoute l'animation fadeOut pour l'indicateur
const style = document.createElement('style');
style.textContent = `
@keyframes fadeOut {
from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
to { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}
`;
document.head.appendChild(style);
</script>
(html comment removed: ========== PATCH: Auto-Vote Play/Pause Control ========== )