Created
February 4, 2017 09:29
-
-
Save Dehax/5b8f2d8e8c5831ea3934033042db7281 to your computer and use it in GitHub Desktop.
Steam Market Sales Total at https://steamcommunity.com/market/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'https://steamcommunity.com/market/myhistory/render/?query=&start=0&count=1', false); | |
xhr.send(); | |
if (xhr.status != 200) { | |
alert(xhr.status + ': ' + xhr.statusText); | |
throw new Error(); | |
} | |
var totalCount = JSON.parse(xhr.responseText)['total_count']; | |
xhr.open('GET', 'https://steamcommunity.com/market/myhistory/render/?query=&start=0&count=' + totalCount, false); | |
xhr.send(); | |
if (xhr.status != 200) { | |
alert(xhr.status + ': ' + xhr.statusText); | |
throw new Error(); | |
} | |
var el = document.createElement('div'); | |
el.innerHTML = JSON.parse(xhr.responseText)['results_html']; | |
var sum = 0.0; | |
var list = [].slice.call(el.querySelectorAll('.market_recent_listing_row')); | |
list = list.filter(function (item) { | |
return item.children[3].children.length > 1 && item.children[3].children[1].innerText.trim().startsWith('Покупатель'); | |
}); | |
list.forEach(function (item, i, arr) { | |
sum += parseFloat(item.children[2].innerText.replace(/,/, '.')); | |
}); | |
alert('Вы заработали на продаже карточек в Steam: ' + sum.toFixed(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment