// ==UserScript== // @name Binance Alpha Farm Agent // @namespace http://baf.thuanle.me // @version 2025.07.30 // @author TL // @match https://www.binance.com/en/alpha/bsc/* // @run-at document-idle // @grant GM_setValue // @grant GM_getValue // ==/UserScript== (async () => { 'use strict'; // Utility functions const TL = { log: (msg, ...args) => console.log(`[TL] ${msg}`, ...args), delay: ms => new Promise(resolve => setTimeout(resolve, ms)), getEl: sel => document.querySelector(sel), waitForEl: async (sel, timeout = 10000) => { const start = Date.now(); while (Date.now() - start < timeout) { const el = document.querySelector(sel); if (el) return el; await TL.delay(100); } throw new Error(`waitForEl: Timeout waiting for ${sel}`); }, eventFillFloatInputById(id, value) { const input = document.getElementById(id); if (!input) return; const current = parseFloat(input.value); const target = parseFloat(value); if (Math.abs(current - target) < 1e-8) return; const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set; setter.call(input, value); input.dispatchEvent(new Event('input', { bubbles: true })); } }; // POP UP HELPER const PopupHelper = { defaultStyle: ` position: fixed; bottom: 20px; background: white; color: #000; border: 1px solid #ccc; padding: 12px 16px; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 999999; font-family: sans-serif; font-size: 12px; display: block !important; visibility: visible !important; opacity: 1 !important; `, createOrUpdatePopup(id, options = {}) { try { const { html = '', position = 'bottom-right', customStyle = '', onClick = null } = options; TL.log(`🔍 Creating/updating popup with ID: ${id}`); let popup = document.getElementById(id); if (!popup) { popup = document.createElement('div'); popup.id = id; document.body.appendChild(popup); TL.log(`🔍 Created new popup element with ID: ${id}`); } else { TL.log(`🔍 Found existing popup with ID: ${id}`); } // Set position based on position parameter let positionStyle = ''; switch (position) { case 'bottom-right': positionStyle = 'right: 20px;'; break; case 'bottom-left': positionStyle = 'left: 20px;'; break; case 'top-right': positionStyle = 'top: 20px; right: 20px;'; break; case 'top-left': positionStyle = 'top: 20px; left: 20px;'; break; case 'center': positionStyle = 'top: 50%; left: 50%; transform: translate(-50%, -50%);'; break; default: positionStyle = 'right: 20px;'; } // Apply styles const finalStyle = this.defaultStyle + positionStyle + customStyle; popup.style.cssText = finalStyle; TL.log(`🔍 Applied styles to popup: ${finalStyle.substring(0, 100)}...`); // Set content popup.innerHTML = html; TL.log(`🔍 Set HTML content to popup (length: ${html.length})`); // Add click handler if provided if (onClick && typeof onClick === 'function') { popup.onclick = onClick; } TL.log(`✅ Popup ${id} created/updated successfully`); return popup; } catch (error) { TL.log(`❌ Error in createOrUpdatePopup: ${error.message}`); return null; } }, removePopup(id) { const popup = document.getElementById(id); if (popup) { popup.remove(); } }, }; // Main script logic // show welcome popup PopupHelper.createOrUpdatePopup('welcome-popup', { html: `

Welcome to Binance Alpha Farm Agent

This script will help you manage your Binance Alpha Farm tasks more efficiently.

Click here to learn more.

`, onClick: () => { PopupHelper.removePopup('welcome-popup'); } }); })();