diff --git a/agent.user.js b/agent.user.js index a5a600d..050c59f 100644 --- a/agent.user.js +++ b/agent.user.js @@ -41,8 +41,8 @@ // ====== Utility ====== const TL = { - log: (msg, ...args) => GM_log(`[TL] ${msg}`, ...args), - error: (msg, ...args) => GM_log(`[TL] [ERROR] ${msg}`, ...args), + log: (msg, ...args) => GM_log(`[TL]\n${msg}`, ...args), + error: (msg, ...args) => GM_log(`[TL] [ERROR] ❌\n${msg}`, ...args), noti: (title, text, timeout = 2500) => { if (typeof GM_notification === 'function') { GM_notification({ title, text, timeout }); @@ -75,7 +75,7 @@ let data = text; const isJSON = /content-type:\s*application\/json/i.test(resp.responseHeaders || ''); if (isJSON) { try { data = JSON.parse(text); } catch { } } - TL.log(`[GM] ${resp.status} ${url}`, data); + TL.log(`${init.method} ${resp.status} ${url}`, data); resolve({ status: resp.status, ok: resp.status >= 200 && resp.status < 300, @@ -143,7 +143,7 @@ const msg = `Switched to ${nsv.label} (${nsv.url})`; TL.log(msg); TL.noti('BAF Server Switched', msg); - + await TL.delay(300); location.reload(); } catch (e) { @@ -175,6 +175,21 @@ } + + // ====== Main ====== + async function welcome_message() { + + const s = await BAF.getServer(); + const res = await BAF.ping(); + const resStr = + `Server: ${s.label} (${s.url})\n` + + `Status: ${res.ok ? 'Connected ✅' : 'Failed ❌'} (${res.status})`; + + TL.log(resStr); + } + + // ====== Khởi tạo ====== + await welcome_message(); await createGM_Menu(); })(); \ No newline at end of file