Интерактивный анализ истории ваших покупок
(() => {
const rows = document.querySelectorAll('tr.wallet_table_row');
const parseCurrency = (text) => {
if (!text || text.trim() === "") return null;
const clean = text.trim().replace(/\s+/g, ' ');
const match = clean.match(/^([+-]?)[^\d]*([\d.,]+)\s*(.*)$/);
if (!match) return null;
const sign = match[1] === '-' ? '-' : '';
const amount = match[2].replace(',', '.');
let currency = match[3] || clean.replace(/[\d.,+-]/g, '').trim();
if (clean.includes('$') && !currency.includes('USD')) {
currency = 'USD';
}
return {
amount: parseFloat(sign + amount),
currency: currency || "руб."
};
};
const data = Array.from(rows).map(row => {
const date = row.querySelector('.wht_date')?.innerText.trim() || null;
const onclick = row.getAttribute('onclick') || "";
const transactionLink = onclick.match(/'([^']+)'/)?.[1] || null;
const type = row.querySelector('.wht_type div')?.innerText.trim() || null;
const paymentMethod = row.querySelector('.wth_payment')?.innerText.trim().replace(/\s+/g, ' ') || null;
const itemsCell = row.querySelector('.wht_items');
let items = [];
if (itemsCell) {
const cellText = itemsCell.innerText;
if (cellText.includes('Торговая площадка Steam')) {
items.push("Торговая площадка Steam");
} else if (cellText.includes('Перевод валюты')) {
items.push(cellText.trim());
} else {
const itemDivs = itemsCell.querySelectorAll('div[style="clear: both"]');
if (itemDivs.length > 0) {
items = Array.from(itemDivs).map(div => div.innerText.trim());
} else {
const rawText = itemsCell.childNodes[0]?.textContent?.trim();
if (rawText) items.push(rawText);
}
}
}
return {
date,
transaction_link: transactionLink,
type,
payment_method: paymentMethod,
items: items,
total: parseCurrency(row.querySelector('.wht_total')?.innerText),
wallet_change: parseCurrency(row.querySelector('.wht_wallet_change')?.innerText),
wallet_balance: parseCurrency(row.querySelector('.wht_wallet_balance')?.innerText)
};
});
const json = JSON.stringify(data, null, 4);
const blob = new Blob([json], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = "steam_wallet_history.json";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
console.log("Готово! Данные строго типизированы, очищены от мусора и сохранены в файл.");
return data;
})();
или кликните для выбора файла