Skip to content

Instantly share code, notes, and snippets.

@korden32
Created September 20, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korden32/4648c77865f6250f1ec8 to your computer and use it in GitHub Desktop.
Save korden32/4648c77865f6250f1ec8 to your computer and use it in GitHub Desktop.
Steam In-Game purchases export
// ==UserScript==
// @name Steam In-Game purchases export
// @author KorDen
// @version 0.0.1
// @grant none
// @include https://store.steampowered.com/account/history*
// ==/UserScript==
( function() {
$J('.wallet_history_table').before('<a class="btn_small btn_blue_white_innerfade" id="btnExport"><span>Export in-game purchases...</span></a><br><br>');
$J('#btnExport').click(exportPurchaseHistory);
})();
var csvData = "";
var current = 1;
function exportPurchaseHistory() {
csvData = "#;Item Type;Item;Price;Acted;Actor URL;Transaction ID\n";
$J('.wallet_table_row[onclick]:visible').each(function () {
var row = $J(this);
if(row.attr('onclick').indexOf("steamcommunity.com") == -1 && row.find('.wht_type > div').html().indexOf('In-Game') == 0) {
row.show();
var transId = $J(this).attr("onclick").match(/transid=(\d+)&/)[1];
var type = row.find(".wht_items > div:not(.wth_payment)").html().trim().replace(';','_');
var item = row.find(".wht_items > div.wth_payment").html().trim().replace(';','_');
var acted = row.find(".wht_date").html();
var price = row.find(".wht_total").html();
var dt = new Date(Date.parse(acted));
acted = dt.getDate() + '.' + (dt.getMonth() + 1) + '.' + dt.getFullYear();
price = price.trim().replace(/( pуб.|\$)/,'');
csvData += current + ';' + type + ';' + item + '; -' + price.trim() + ';' + acted + ';In-game;' + transId + ';\n';
current++
} else {
row.hide();
}
});
//$J('#load_more_button').click();
$J('#btnExport').after(' <a class="btn_small btn_darkblue_white_innerfade" id="histExpDoCSV" download="storehistory.csv"><span>Export to CSV</span></a> \
<a class="btn_small btn_darkblue_white_innerfade" id="histExpDoTXT"><span>Show CSV in textarea</span></a>');
$J('#histExpDoCSV').click(doCSV);
$J('#histExpDoTXT').click(doTXT);
}
function doCSV() {
$J('#histExpDoCSV').attr('href', "data:application/csv;charset=utf-8," + encodeURIComponent(csvData));
}
function doTXT() {
$J('#histExpDoTXT').after("<br><br><textarea cols=100 rows=20 style='background-color: rgba(0, 0, 0, 0); color:#fff;'>" + csvData + "</textarea>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment