Skip to content

Instantly share code, notes, and snippets.

@Windowsfreak
Last active April 23, 2026 20:37
Show Gist options
  • Select an option

  • Save Windowsfreak/874fc29dcd416ecdd75c104491b5c523 to your computer and use it in GitHub Desktop.

Select an option

Save Windowsfreak/874fc29dcd416ecdd75c104491b5c523 to your computer and use it in GitHub Desktop.
// Precondition: logged into https://portal.tagmarkets.com/, visiting any page, and knowing the access token from CopyX.
(async function (token) {
if (!token || token === 'PASTE_YOUR_TOKEN_HERE') {
console.error("❌ Please provide your Bearer token as an argument.");
return;
}
const headers = {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
};
try {
console.log("%cπŸš€ Starting Bulk Profit Withdrawal...", "color: #00ff00; font-weight: bold; font-size: 14px;");
// 1. Fetch Strategies to get account logins
const fetchStrategies = async (status) => {
const url = `https://tagxapi.tagmarkets.com/follower-hub/strategies?status=${status}`;
const res = await fetch(url, { headers });
if (!res.ok) throw new Error(`Failed to fetch ${status} strategies: ${res.status}`);
return await res.json();
};
console.log("πŸ“‘ Fetching strategy lists (active & inactive)...");
const [active, inactive] = await Promise.all([
fetchStrategies('active'),
fetchStrategies('inactive')
]);
const allStrategies = [...active, ...inactive];
const logins = [...new Set(allStrategies.map(s => s.mt_account))].filter(Boolean);
if (logins.length === 0) {
console.warn("⚠️ No accounts found in strategies list.");
return;
}
console.log(`πŸ” Found ${logins.length} unique account(s). Checking available profits...`);
// 2. & 3. Process each account async: Fetch profit -> Withdraw if > 0
const results = await Promise.all(logins.map(async (login) => {
try {
// Fetch Available Profit
const profitUrl = `https://tagxapi.tagmarkets.com/follower-hub/followers/${login}/available-profit`;
const profitRes = await fetch(profitUrl, { headers });
if (!profitRes.ok) {
return { login, status: 'error', message: `Check failed (HTTP ${profitRes.status})` };
}
const profitData = await profitRes.json();
const amount = profitData.available_profit || 0;
if (amount <= 0) {
return { login, status: 'skipped', amount: 0, message: 'No profit available' };
}
// Initiate Withdrawal
console.log(`🏦 %c[${login}] Initiating withdrawal of $${amount}...`, "color: #3498db;");
const withdrawRes = await fetch('https://tagxapi.tagmarkets.com/follower-hub/withdrawal/profit', {
method: 'POST',
headers,
body: JSON.stringify({
login: login.toString(),
amount: parseFloat(amount)
})
});
const withdrawData = await withdrawRes.json();
if (!withdrawRes.ok) {
return { login, status: 'failed', amount, message: withdrawData.detail || 'Withdrawal rejected' };
}
return { login, status: 'success', amount, message: 'Withdrawal successful' };
} catch (err) {
return { login, status: 'error', message: err.message };
}
}));
// Summary and Success Message
console.log("\n" + "=".repeat(50));
console.log("%cπŸ“Š WITHDRAWAL SUMMARY", "font-weight: bold; font-size: 14px;");
console.log("=".repeat(50));
const stats = {
totalChecked: results.length,
success: results.filter(r => r.status === 'success').length,
failed: results.filter(r => r.status === 'failed').length,
skipped: results.filter(r => r.status === 'skipped').length,
errors: results.filter(r => r.status === 'error').length,
totalWithdrawn: results.filter(r => r.status === 'success').reduce((sum, r) => sum + r.amount, 0).toFixed(2)
};
// Display results in a clean table
console.table(results.map(r => ({
Account: r.login,
Status: r.status.toUpperCase(),
Amount: r.amount > 0 ? `$${r.amount.toFixed(2)}` : '-',
Info: r.message
})));
const summaryStyle = "font-weight: bold; font-size: 12px;";
console.log(`%cπŸ’° Total Withdrawn: $${stats.totalWithdrawn}`, "color: #2ecc71; " + summaryStyle);
console.log(`%cπŸ“ˆ Results: ${stats.success} Success | ${stats.failed} Failed | ${stats.skipped} Skipped | ${stats.errors} Errors`, summaryStyle);
if (stats.success > 0) {
console.log("%cβœ… All eligible profits have been queued for withdrawal.", "color: #2ecc71; font-weight: bold;");
} else {
console.log("%cℹ️ No withdrawals were processed.", "color: #f1c40f; font-weight: bold;");
}
} catch (error) {
console.error("❌ Critical error in withdrawal flow:", error.message);
}
})('PASTE_YOUR_TOKEN_HERE');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment